<?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 Alon Robinson on Medium]]></title>
        <description><![CDATA[Stories by Alon Robinson on Medium]]></description>
        <link>https://medium.com/@AlonNola?source=rss-ebb0b5e38ce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0N-XNGuJNAcAJlVp_Wd3og.png</url>
            <title>Stories by Alon Robinson on Medium</title>
            <link>https://medium.com/@AlonNola?source=rss-ebb0b5e38ce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 10:47:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@AlonNola/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[A Little setTimeout Fun]]></title>
            <link>https://medium.com/@AlonNola/a-little-settimeout-fun-eee2a801f34d?source=rss-ebb0b5e38ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/eee2a801f34d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-gotchas]]></category>
            <category><![CDATA[settimeout]]></category>
            <dc:creator><![CDATA[Alon Robinson]]></dc:creator>
            <pubDate>Mon, 25 Apr 2016 17:02:25 GMT</pubDate>
            <atom:updated>2016-04-25T23:26:51.519Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you know the difference between this function:</p><pre>setTimeout(console.log(&#39;FOO&#39;), 3000);</pre><p>and this function:</p><pre>setTimeout(function(){console.log(&#39;FOO&#39;);}, 3000);</pre><p>DON’T CHEAT!</p><p>The first one has console.log being invoked with the argument ‘FOO’, which causes the function to execute immediately and pass the returned value to setTimeout as an argument. JavaScript returns undefined for functions that aren’t made to return a value, so the console will log ‘FOO’ right away and pass undefined to setTimeout. The function now looks like this:</p><pre>setTimeout(undefined, 3000);</pre><p>setTimeout will now try to invoke undefined, because it expects the first argument to be a function. In the Chrome console, this does not throw an error, although you would expect it to throw ‘undefined is not a function’.</p><p>The second has console.log wrapped in an anonymous function. This gets invoked by the setTimeout function, which makes it be called after a 3 second wait period.</p><p>Another way to solve this issue would be to use <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind">function binding</a> like so:</p><pre>setTimeout(console.log.bind(console, &#39;FOO&#39;), 3000);</pre><p>This binds the value ‘FOO’ to this particular instance of console.log using console as the thisArg, but does not invoke the function, allowing it to be called by setTimeout.</p><p>So if you plan on using setTimeout, don’t execute your functions inside of it, unless you planned on passing the returned value of that function to setTimeout.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eee2a801f34d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tail Call Optimization & ES6]]></title>
            <link>https://medium.com/@AlonNola/tail-call-optimization-es6-ebee1cf6c3c7?source=rss-ebb0b5e38ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebee1cf6c3c7</guid>
            <category><![CDATA[tail-call-optimization]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es6]]></category>
            <dc:creator><![CDATA[Alon Robinson]]></dc:creator>
            <pubDate>Tue, 22 Mar 2016 00:02:17 GMT</pubDate>
            <atom:updated>2016-03-22T00:36:16.791Z</atom:updated>
            <content:encoded><![CDATA[<p>In programming languages that have tail call recursion implemented improperly, the programs using them can take up lots and lots of space in memory. This is why, in JavaScript ES5 and below, you get “Max Call Stack Exceeded” errors. The stack that was created from the previous call was never dropped, and so it takes up space until there is none left. Here’s a look into what happens:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*rntPCB8ylDEICZlDlEu26g.png" /><figcaption>Previous stacks are not dropped from memory.</figcaption></figure><p>In other languages, if the program no longer needs the previous stack created from the last function call, it will drop it out of memory, resulting in constant space. The good news is that ES6 introduces proper tail call optimization into JavaScript!</p><h3>Vocabulary You Should Know</h3><h4><strong>Tail Position</strong></h4><ul><li>This is the last instruction in a function before the return statement.</li></ul><pre>var tailPos = function (x) {<br>  var y = x * 2;<br>  return x + y; // &lt;--- This is the tail position<br>};</pre><ul><li>In the above example, the last instruction before the function returns is to add x and y.</li><li>* A function can have multiple tail positions.</li></ul><pre>var tailPos = function (x) {<br>  if(x === 0) {<br>    return x; // &lt;--- This is the tail position<br>  }<br>  var y = x * 2;<br>  return x + y; // &lt;--- This is also the tail position<br>};</pre><h4>Tail Call</h4><ul><li>This is a function call in the tail position.</li></ul><pre>var someFunc = function () {<br>  return &#39;Yo!&#39;; // &lt;--- This is the tail position<br>};</pre><pre>var tailPos = function () {<br>  return someFunc(); // &lt;--- This is the tail position &amp; tail call<br>};</pre><ul><li>In *proper* tail call implementation, the tail call does not need to maintain any of the variables in its current stack. But you can call any function call in the tail position a tail call.</li></ul><h4>Close Call</h4><ul><li>This looks like a tail call, but is not. If you examine more closely, the function call is not the last instruction to execute.</li></ul><pre>var someFunc = function () {<br>  return 2;<br>}</pre><pre>var closeCall = function () {<br>  return 1 + someFunc();<br>}</pre><ul><li>The last instruction is to add 1 to the evaluation of someFunc(). This is not proper tail call because it has to return back to the current stack to finish execution.</li></ul><p>Lets look at an example!</p><pre>function factorial (n) {<br>  <strong>if</strong> (x &lt;= 1) {<br>    <strong>return</strong> 1;<br>  } <strong>else</strong> {<br>    <strong>return</strong> n * factorial(n-1);<br>  }<br>}</pre><p>This is not a proper tail call, because the last operation is multiplication.</p><pre><strong>function</strong> factorial(num) {<br>  <strong>function</strong> recurs(n, accum) {<br>    <strong>if</strong> (x &lt;= 1) {<br>      <strong>return</strong> acc;<br>    } <strong>else</strong> {<br>      <strong>return</strong> facRec(n-1, n*accum);<br>    }<br>  }  <br>  <strong>return</strong> recurs(num, 1);<br>}</pre><p>Since we have recurs as a tail call, this is considered a proper tail call, and will thus be optimized in ES6! The stacks that are no longer needed will be thrown away!</p><p>We will get more into details of how this works next post when we talk about <strong><em>trampolines </em></strong>and implementing TCO in ES5!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebee1cf6c3c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Remove the Hash from Angularjs URLs]]></title>
            <link>https://medium.com/@AlonNola/remove-the-hash-from-angularjs-urls-872fd76d993f?source=rss-ebb0b5e38ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/872fd76d993f</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angularjs]]></category>
            <dc:creator><![CDATA[Alon Robinson]]></dc:creator>
            <pubDate>Fri, 19 Feb 2016 07:19:51 GMT</pubDate>
            <atom:updated>2016-02-19T07:19:51.694Z</atom:updated>
            <content:encoded><![CDATA[<p>By default, Angularjs URLs have a hash in them, in the format of <a href="http://www.example.com/#/about.">www.example.com/#/about.</a> This can be pretty annoying to look at, but there is a way around this!</p><p>In your config file, use the $locationProvider and set HTML5 mode to true.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*4UPSjWJ0G3y_xXYTgJ-trg.png" /></figure><p>Then in your index.html page, set the base href to ‘/’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*DU6hzJEvhfuRdCIyGbChGA.png" /></figure><p>Alternatively, you can pass an object into the $locationProvider.html5Mode function and make a base URL not required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*OazUSwQaLxBGYJnOY_QIvg.png" /></figure><p>This will enable you to have normal looking URLs!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=872fd76d993f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Auto-include JavaScript Files to your main HTML file with Grunt]]></title>
            <link>https://medium.com/@AlonNola/auto-include-javascript-files-to-your-main-html-file-with-grunt-87bbe9ace9d1?source=rss-ebb0b5e38ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/87bbe9ace9d1</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[grunt]]></category>
            <dc:creator><![CDATA[Alon Robinson]]></dc:creator>
            <pubDate>Fri, 19 Feb 2016 03:16:43 GMT</pubDate>
            <atom:updated>2016-02-19T03:16:43.961Z</atom:updated>
            <content:encoded><![CDATA[<p>If you use AngularJS or any other MVC which promotes code modularity and separation of concerns, you will likely have a LOT of JavaScript files floating around. In order for your application to work properly, you will have to include each JS file one by one. In the beginning of your project, this may seem manageable, but as your project grows and grows with more files, and bower components, it will save you a lot of time and headache to have them added automatically!</p><p>Enter Grunt. Grunt is a JS task runner that does a lot of neat things for you like concatenating, uglifying and linting JS files, and minifying CSS files to name a few common tasks. Let’s see how we can configure this to make our lives easier! **If you have never used Grunt before, I suggest going to the official Getting Started guide.</p><p>After we have Grunt installed, we want to install the dependencies we will use. We will be using grunt-include-source. Install this via NPM like so:</p><pre>npm install grunt-include-source --save-dev</pre><p>In our Gruntfile, we have to load our tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*qLh_EBpG_p15gm1lFOiDag.png" /></figure><p>Next we want to set up our task configurations inside of our grunt.initConfig function so we can tell Grunt how we want them to run. We will start with includeSource.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*7LCNomanG_WpeJG8AGnLqg.png" /></figure><p>Your basePath is where includeSource will look for your files at. You can set up your templates for how the script and link tags will be included in your HTLM file here as well.</p><p>‘myTarget’ (you can name this anything) specifies the template you will use(on the right of the colon), and which file the scripts will be included in (on the left).</p><p>I decided to put the template and index.html file in the same directory. The template is almost exactly like your regular html file. The difference is you include comments which includeSource reads and uses to add the sources to your HTML file. This is how my template looks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*7PRt_h6jkMpp26UTLj_5kQ.png" /></figure><p>Now I can register a grunt task, so that every time I call it, it will add the JS files I need.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*HOzgADrCM5dWDVfUiL8dlg.png" /></figure><p>In the terminal, in the root directory of my folder, I type in “grunt build” and BLAMMO!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*WjPgtOYfZQp0xRrRV-JSbQ.png" /><figcaption>BLAMMO!</figcaption></figure><p>Obviously, running “grunt build” in the terminal every time isn’t optimal, but you can set up a watch task via grunt-contrib-watch to check for whenever you add or delete a file and update the index.html file. You can also use grunt-wiredep to include all of your bower component files. But more on those later! Hope this helps to automate your life :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87bbe9ace9d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Communicating Between Webpages and Chrome Extensions]]></title>
            <link>https://medium.com/@AlonNola/communicating-between-webpages-and-chrome-extensions-f32c326bbfd9?source=rss-ebb0b5e38ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/f32c326bbfd9</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[google]]></category>
            <dc:creator><![CDATA[Alon Robinson]]></dc:creator>
            <pubDate>Fri, 22 Jan 2016 18:03:21 GMT</pubDate>
            <atom:updated>2016-01-22T18:03:21.990Z</atom:updated>
            <content:encoded><![CDATA[<p>Creating a simple Chrome Extension is a fairly easy task to do, and Google has great documentation on how to do this. However, adding other features to the extension makes it increasingly difficult. Today was my first time doing anything with a Chrome extension, but my group was tasked with adding features to an existing Chrome extension. The app is a bookmarking utility, which allowed for users to login and save bookmarks. Due to time constraints, however, the group we inherited the code base from was only able to make it work for the first user that signed up. Any users after that were unable to save bookmarks.</p><p>The last group hardcoded in that the bookmarks would all be saved to the user with the ID of 1. This seemed simple enough to fix; just change it so that the user it was saved to would be updated whenever someone else logged in. We would gain access to the user ID because it was stored in the browsers localStorage. This proved to be quite problematic, as Chrome extensions run as another webpage in the background, and localStorage is not shared between tabs, or browsers. I tried many things so I would like to give you a rundown of what NOT to do, before I tell you how I solved the problem.</p><p>1. Local Storage Event</p><p>Every time you add or remove something from localStorage, it emits an event that can be listened to from other tabs. This sounded so promising, but I soon learned that the tabs had to have the same origin. This means that you have to open the same url in multiple tabs in order for this to work.</p><p>2. Using content script to receive a message from a webpage, and send that message to the Chrome extension.</p><p>This is the one that had me the most excited. You just add the content script object to the manifest.json file and specify which files you want to use. It doesn’t work because in your app’s html file, it sends an event via the document. The content.js file is supposed to listen for it, and then send the message to the chrome extension. This runs into the same problems as before, the two webpages are unable to listen to one another’s DOM events.</p><p>I solved the problem in a much simpler way, which I saw many times before it clicked in my head. Chrome has documentation on <a href="https://developer.chrome.com/extensions/messaging#external-webpage">sending messages from webpages to chrome extensions</a>. You add an “externally_connectable” object to your manifest. This will specify which webpages you want to allow to communicate with your extension (in this case, localhost, since I was developing on my machine). Then you add those webpages to the permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*1MLWw07Gp_ubeRF0hRxrJw.png" /></figure><p>In your app’s main html page, add a script tag that fires off an event using chrome.runtime.sendmessage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*O-OuQanZxj-WmqBlCqjPWw.png" /></figure><p>Then have your Chrome extension listen for that event in the background.js file and respond accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*VZZ6HKz4CbZguDpvsZ6bIw.png" /></figure><p>I used this to send over the localStorage data to the Chrome extension whenever someone is logged in. Having this data allowed me to update the users, and allow multiple profiles to be able to save bookmarks! Hope this helps! Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f32c326bbfd9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Chrome Extensions Pt. 1]]></title>
            <link>https://medium.com/@AlonNola/creating-chrome-extensions-pt-1-a6e063e63d4d?source=rss-ebb0b5e38ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6e063e63d4d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Alon Robinson]]></dc:creator>
            <pubDate>Fri, 04 Dec 2015 04:06:55 GMT</pubDate>
            <atom:updated>2015-12-04T04:08:18.153Z</atom:updated>
            <content:encoded><![CDATA[<p>Even after I began learning to code, I never thought about creating a Google Chrome extension. They have always been one of those things that I didn’t put too much thought into, as I only have a few of them, which I barely use. That changed this week when my group inherited a code base that was a Chrome Extension for bookmarking webpages. Then I was forced to wonder how they were made. Fortunately, there is <a href="https://developer.chrome.com/extensions/getstarted">good documentation</a> on it.</p><p>The great thing about Chrome extensions is they are made in almost the exact same way you would make any other web app. You need a manifest, which specifies important information that the extension needs to run, javascript file/s, and an optional html file for the button that pops up in the browser.</p><p>Let’s make a simple Chrome extension that grabs our GPS coordinates and displays them!</p><h4>The Manifest</h4><p>The manifest is a json file with important information the extension needs. For now we will create a simple one.</p><pre>{<br>  &quot;manifest_version&quot;: 2,<br><br>  &quot;name&quot;: &quot;My First Chrome Extension&quot;,<br>  &quot;description&quot;: &quot;Gimme yo location!&quot;,<br>  &quot;version&quot;: &quot;1.0&quot;,<br>  &quot;icons&quot;: {<br>    &quot;48&quot;: &quot;location.png&quot;<br>  },<br>  &quot;browser_action&quot;: {<br>    &quot;default_icon&quot;: &quot;location.png&quot;,<br>    &quot;default_popup&quot;: &quot;popup.html&quot;<br>  },<br>  &quot;permissions&quot;: [<br>    &quot;geolocation&quot;<br>  ]<br>}</pre><p>The browser action allows us to make a clickable icon next to the address bar. It references popup.html as to what it looks like, and location.png for its icon. Icons just sets the image in the Chrome extensions window. We are going to use the geolocation permission, which allows us to use the HTML5 geolocation API in the Chrome extension. I used <a href="https://lh5.ggpht.com/j40P2o40AM4-H0y20CzU-Qo4vllefct00WH9Be_OwfyHZl0DuyWqNn8joDKnFl8D03Y=w300">this icon</a> for the extension.</p><h4>The Popup</h4><p>Next we want to create our popup.html file. This is written pretty much like a regular HTML file, CSS and all. In it we will have a button that we use to get our location and display it in the popup.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Locator&lt;/title&gt;<br>    &lt;script src=”popup.js”&gt;&lt;/script&gt;<br>  &lt;/head&gt;<br> &lt;body&gt;<br>   &lt;h2&gt;Locator&lt;/h2&gt;<br>   &lt;hr /&gt;<br>   &lt;button id=”locator”&gt;Get Location&lt;/button&gt;<br>   &lt;/body&gt;<br>&lt;/html&gt;</pre><p>As you can see, this is plain HTML. Nothing special.</p><h4>The Popup Script</h4><p>Time to create our popup.js file. This is going to be the logic we use to grab the users current location and display it in the popup. We will be using vanilla JavaScript, since it makes no sense to import the jQuery library for a few lines of code.</p><pre>//dont execute script until DOM has loaded<br>document.addEventListener(‘DOMContentLoaded’, function() {<br>  var locButton = document.getElementById(‘locator’);</pre><pre>  //listen for user to click button<br>  locButton.addEventListener(‘click’, function(){</pre><pre>    //grab current position <br>    navigator.geolocation.getCurrentPosition(function(position) {</pre><pre>    //create a paragraph and append to body<br>      var p = document.createElement(‘p’);<br>      p.innerHTML = position.coords.latitude + “, “ + position.coords.longitude;<br>      document.getElementsByTagName(‘body’)[0].appendChild(p);</pre><pre>    });<br>  })<br>}, false)</pre><p>This is all the code we need!</p><h4>Using Your Extension</h4><p>Now that we have made our extension, let’s actually use it! Head on over to your Chrome extensions window by typing chrome://extensions/ in the address bar. Check the box that says “Developer Mode”, and a dropdown will appear. Click on “Load Unpacked Extension”, navigate to the folder with your files in it and voila! Now we have a locator icon next to the address bar, and if you click the button, the coordinates of your position will popup!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sFeaVInP6311ZNwDn64V0A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6e063e63d4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The M in MVP]]></title>
            <link>https://medium.com/@AlonNola/the-m-in-mvp-8c89b9b46523?source=rss-ebb0b5e38ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c89b9b46523</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[hack-reactor]]></category>
            <category><![CDATA[mvp]]></category>
            <dc:creator><![CDATA[Alon Robinson]]></dc:creator>
            <pubDate>Mon, 23 Nov 2015 05:02:55 GMT</pubDate>
            <atom:updated>2015-11-23T16:01:45.597Z</atom:updated>
            <content:encoded><![CDATA[<p>MVP in programming speak is not Most Valuable Player. It stands for Minimum Viable Product. This is used to describe the core features your application needs to be functional and do what it is supposed to do and nothing more. This is particularly useful for hackathons, prototyping your apps, and market analysis to get consumer feedback. It gives you a good sense of how much it will take to build the app, how to implement certain features, if your other ideas for additional features will actually work for what it is you are doing, and in the case of market analysis, if your app just plain old sucks.</p><p>During Week 6 of Hack Reactor, we were presented with our first group project. This was a four day long sprint that consisted of creating anything you and your team wanted to do from scratch. My team decided to go with an idea I had come up with during the solo project, starting from scratch and making it mobile using Ionic and AngularJS. The app is called (much to my objection!) Bus It Baby, and alerts a user riding the bus when they are within a user-specified distance from their stop. This way, users can focus on other things while riding, as opposed to constantly checking if they reached their stop.</p><p>The sprint started off with LOTS AND LOTS of planning and discussion. We spent about half the sprint planning what the app would look like, how it would function, and learning the technologies we needed to get it done. After so much planning, we had an amazing app drawn up, with all sorts of features: Oauth login, database for storing users favorite routes, a start button to start the tracking, subway support, interaction with users phone to allow them to choose their own alarm, etc. All of these things expanded outside of the basic features of the app we were building, and were going to take a lot more time than we had to implement, especially because we were learning new technologies at the same time. So on the 3rd day of our group project we began our coding and quickly realized that everything we were trying to implement were extra features, and we had not yet completed the MVP! One of our team members spent a good portion of the day(and night) trying to figure out how to access the users phone storage for the alarms. One spent a long time dealing with Oauth. I spent a long time trying to get all the bus information from New York City’s MTA API (which, I might add, is not very user friendly).</p><p>Because we had such a short amount of time left to complete the project, our next meeting consisted of lots of “yeah, let’s throw that out too” and “nah, we don’t actually need that”. So we ended up throwing out a lot of the features and got it down to <a href="https://pbs.twimg.com/media/Bnj9J3RIMAMPJdT.jpg">the real MVP</a>. We used only one bus and it’s stops, tracked the users location, and implemented our distance calculation algorithm to track wether the user has gotten within the specified distance of their stop. Our MVP was completed in no time and we were able to make it look nice and presentable! After this we were able to work on adding additional functionality like adding Oauth login and the alarm notification.</p><p>In the end, this was a great lesson on project scoping. We learned to start with a truly minimum viable product that can be explained in one sentence (especially if you only have 4 days), and work our way up from there. This helps you to maintain focus of what it is you are trying to accomplish without being distracted by all the other cool features that are not necessary for a working application. And also if you only have a short amount of time, you can spend less time planning and more time coding :)! This is a major lesson I will carry with me on into our next 4 day group project, and then our 4 week long thesis project! Happy coding, y’all!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c89b9b46523" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working with Angular $scope]]></title>
            <link>https://medium.com/@AlonNola/working-with-angular-scope-7d42be1a410d?source=rss-ebb0b5e38ce------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d42be1a410d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angularjs]]></category>
            <dc:creator><![CDATA[Alon Robinson]]></dc:creator>
            <pubDate>Sun, 15 Nov 2015 01:24:10 GMT</pubDate>
            <atom:updated>2015-11-15T01:24:10.661Z</atom:updated>
            <content:encoded><![CDATA[<p>If you haven’t yet heard of AngularJS, you are either new to the world of programming(as I was a few months back), or you have been under a rock. Angular is Google’s genius child that has been setting the world wide web ablaze. Although there is a bit of a learning curve with Angular, especially if you have never used an MVC framework, once you begin to get the hang of it, it begins to get fun.</p><p>Today I was presented with a problem of making a number on an HTML page count up or down with button clicks. The problem was that there were three different controllers that had to interact with one another. One was the parent scope and the other two were child scoped. Here is the HTML:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br> &lt;head&gt;<br> &lt;script src=”<a href="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js">http://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js</a>&quot;&gt;&lt;/script&gt;<br> &lt;script src=”./count.js”&gt;&lt;/script&gt;<br> &lt;/head&gt;<br>&lt;body&gt;<br> &lt;div ng-app=”count”&gt;<br> <br>  &lt;h1 ng-controller=”countCtrl”&gt; {{ count.number }} &lt;/h1&gt;<br> <br>  &lt;button ng-controller=”incrCtrl” ng-click=”count.number =   count.number + 1&quot;&gt;Increment!&lt;/button&gt;</pre><pre>  &lt;button ng-controller=”decrCtrl” ng-click=”decrement()”&gt;Decrement! &lt;/button&gt;<br> &lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>And here is the JavaScript:</p><pre>var app = angular.module(‘count’, []);</pre><pre>app.controller(‘countCtrl’,function()<br> <br> }])<br> .controller(‘incrCtrl’,function(){</pre><pre>}])<br>.controller(‘decrCtrl’,function(){<br>   <br> }])</pre><p>One of the ways you can solve this problem is by creating a factory or service and using dependency injection. But Angular also gives you access to what’s called the root scope. The documentation says: “Each Angular application has exactly one root scope, but may have several child scopes…When new scopes are created, they are added as children of their parent scope. This creates a tree structure which parallels the DOM where they’re attached.”</p><p>The great thing about this is that you can have your controllers emit events that the parent scopes can listen for. I set up an event called “decr” to be emitted whenever someone clicked the decrement button. The parent scope then listened for it and responded by decreasing the count.</p><pre>var app = angular.module(‘count’, []);</pre><pre>app.controller(‘countCtrl’,[‘$scope’,’$rootScope’,function($scope,$rootScope)<br> //add these to rootScope so all have access through inheritance<br>   $rootScope.count = {};<br>   $rootScope.count.number = 3;<br>   $rootScope.$on(‘decr’, function(){<br>     //only countdown if number is greater than 0<br>     if($rootScope.count.number &gt; 0){<br>       $rootScope.count.number — ;<br>     }<br>   })<br> }])<br> .controller(‘incrCtrl’, [‘$scope’,function($scope){</pre><pre>}])<br>.controller(‘decrCtrl’, [‘$scope’, ‘$rootScope’,function($scope, $rootScope){<br>   $scope.decrement = function(){<br>   //emit event to parent scope similar to backbone trigger<br>     $rootScope.$emit(‘decr’);<br>   }<br> }])</pre><p>Angular has really great documentation and lots of tutorials around the web to get you started. So try it out you won’t be disappointed!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d42be1a410d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>