<?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 Justin Michot on Medium]]></title>
        <description><![CDATA[Stories by Justin Michot on Medium]]></description>
        <link>https://medium.com/@jsmichot?source=rss-201643f7075a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*IaBGvI9oGqkvelYb.</url>
            <title>Stories by Justin Michot on Medium</title>
            <link>https://medium.com/@jsmichot?source=rss-201643f7075a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 03:44:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jsmichot/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[Web App Install Banner]]></title>
            <link>https://medium.com/@jsmichot/web-app-install-banner-6ce904cfdf59?source=rss-201643f7075a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ce904cfdf59</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[pwa]]></category>
            <category><![CDATA[web-app-install-banner]]></category>
            <category><![CDATA[web-app-manifest]]></category>
            <dc:creator><![CDATA[Justin Michot]]></dc:creator>
            <pubDate>Wed, 21 Mar 2018 12:27:59 GMT</pubDate>
            <atom:updated>2018-03-21T12:27:59.928Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*SUahkd6Akb87fsP6E0kXyw.png" /></figure><p>Web App Install Banners allow users to add your web application to their home-screen or desktop from the browser. Showing this option to users requires your site to be served over HTTPS with an active Service Worker. Then you need to write a manifest detailing (defining/creating the install banner). Finally, you will need to insert/link the manifest to the application at the proper location.</p><p>Create a Manifest</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XZsydsh7zOXTw038cPRSdQ.png" /></figure><p>The manifest is a .json file. Conventionally the file will be named manifest.json. Above is the minimum amount of information to include in your manifest. I will explain how each property is used. However, there are more properties to add for specific customization:</p><p>name: displayed when the user is prompted to download the app</p><p>short_name: displayed on the user’s home-screen / desktop post-download</p><p>description: encapsulates the essence of your application to the user</p><p>icons: the image displayed on the user’s home-screen</p><p>start_url: the endpoint the user will be directed to upon clicking the icon</p><p>display: <em>fullscreen</em> or <em>standalone</em> (w/out browser address bar)</p><p>Link the file to your App</p><p>The file should be placed within the same directory as the index.html. Within the &lt;head&gt; tag of the index.html you can link to the manifest.json and your Service Worker will takeover from there: Chrome uses visit frequency heuristics to determine when to display the banner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*8ya-TZFjf2pcTikSysERbA.png" /></figure><p>Making a web application installable is can be easy after you have HTTPS and a Service Worker. These are new technologies and growing fast. Allowing your app to installed, downloaded, and instantly accessed from a home-screen is a convienent feature to offer users. Have a great day and Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ce904cfdf59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Facebook Authentication]]></title>
            <link>https://medium.com/@jsmichot/facebook-authentication-344988f46503?source=rss-201643f7075a------2</link>
            <guid isPermaLink="false">https://medium.com/p/344988f46503</guid>
            <category><![CDATA[facebook-auth]]></category>
            <category><![CDATA[facebook]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[auth]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Justin Michot]]></dc:creator>
            <pubDate>Wed, 14 Mar 2018 02:34:11 GMT</pubDate>
            <atom:updated>2018-03-14T12:17:37.096Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AQiUtC__3tJxZenW.png" /></figure><p>Authentication is the process of proving something to be true, genuine, or valid. Implementing Facebook Authentication, therefore, is relying on facebook to “authenticate” those who use your application. Facebook probably has more resources than you do. When it comes to authenticating users of a social media style app (that is, it is important for users to be who they say they are) there is no reason to reinvent the wheel. Of course, this is not a perfect science and facebook cannot gurarantee users are who they say they are. Either way, facebook gets you just about as close as you can get to accurate authentication while not having to spend any money for the service and only having to write a few lines of code. I will show you one method to implement facebook authentication efficiently in a nodeJS application using two npm packages: the <em>passport-facebook-token</em> along with the <em>jsonwebtoken</em>.</p><p>I will cover the process in 5 steps:</p><ol><li>create application at developers.facebook.com</li><li>import dependencies into your application</li><li>write code for the middleware</li><li>handle routing</li><li>secure routes and identify users with JWT</li></ol><p>Step 1: Create Application at developers.facebook.com</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*eAuiBrJaXubdgAqkm26VLg.png" /></figure><p>If you are requiring users to have a facebook account, it makes sense that the developer will need a facebook account too. Once you are at <em>developers.facebook.com</em> then you can create a new app from your dashboard. There will be a drop-down menu near the top-left corner of the screen that will show a list of your current applications and allow you to create a new application. Facebook offers tutorials to help implement the authentication but we are going to import some other libraries to make the process even more efficient.</p><p>Step 2: Import Dependencies into your Application</p><p>First we need the Facebook SDK (Software Development Kit). From the index.html at the top level of the application, you can insert the following script tag inside the &lt;head&gt;:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*zbXHAU99g_pMEJ8XmJXZfQ.png" /></figure><p>I am not going to cover the frontend any further at this time. However, once the server is implemented correctly. The frontend is a matter of control flow and making calls to the server at the right time. Seeing a call to the server will not be helpful if outside of the greater context of where it goes in your application. Thus, I will highlight a solid authentication process in the backend that can be used to control the flow of your application client-side.</p><p>I will use three npm packages to do the heavy lifting on the back-end: <em>passport, passport-facebook-token</em> along with the <em>jsonwebtoken</em>. These packages can be installed and saved into the package.json file via the following commands in the terminal from the root directory of your application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*_C0zV5MX-MbcqY9YhefdEA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*QcOO40tOy3YXbxXK4WhZQg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*FsRKdLuhML20_I_WAPniIQ.png" /></figure><p>Step 3: Write Code for the Middleware</p><p>Now that the middleware is installed. I can import them into the NodeJS server using Express:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iwIBJYvjd2dl0rP2zsf6_w.png" /></figure><p>Now we can implement the FacebookTokenStrategy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*cNPX86On6OQipqwqKR_HMw.png" /></figure><p>The Strategy above requires a clientID and clientSecret. These are found at developers.facebook.com. From the application’s dashboard (previously created above) you can access the id and secret by clicking “Basic” from the Settings dropdown menu on the left side of the screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HuT1Llnh-6bMhxY4cxgQwg.png" /></figure><p>You will need to provide a Display Name, App Domain, and Contact Email. Most Importantly is the App Domain. Only requests from the domains provided here will authenticate users. During development, <em>localhost</em> will suffice. Once deployed, however, the domain of the deployed app must be provided.</p><p>Once authenticated, Facebook will respond with the user’s public profile and email address per the scope I defined (which will be covered in the next step). What you do with this information is pertinent to the functionality of your specific application. Here, I call a helper function from an imported file. This function create’s a new user if that user does not already exist. Outlined in the object that gets passed into addNewUser is indicative of the information I am receiving from facebook.</p><p>Step 4: Handle Routing</p><p>Next, we need to set a route to implement the strategy that is defined above. I set the endpoint to ‘/auth/facebook’ but it could be anything as long as the request from the client is made to the correct endpoint:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*usr8t1m6ZbmRlQ5LZVsk2g.png" /></figure><p>Passport is used to implement the ‘facebook-token’ strategy. Then, the user’s Facebook id is used to create a JWT (JSON Web Token). The encoded token is salted with the secret: ‘secret’. Hence, to decode the token the ‘secret’ must be provided. Furthermore, I set the token to expire in one hour. Finally, the token is returned to the client.</p><p>Step 5: Secure Routes and Identify Users with JWT</p><p>This completes the process of setting up a NodeJS server to authenticate users using Facebook. However, if you are also developing routes that deliver data sensitive to individual users, then the JWT can be used to provide security to this information and link the correct data to the correct user. The example below requires any route that provides sensitive information to carry the user’s JWT as a parameter. All requests with that parameter will first be authenticated prior to the actual route being handled. If the authentication fails then the request will be immediately rejected. If the authentication is successful, then the request will be routed appropriately:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*3Y3GJN28KIxG0EOzZM0jlg.png" /></figure><p>Any route that you want to secure with by requiring the JWT can use the endpoint ‘/:token’ to trigger the router.param functionality:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*oxuZLJ3bDgnd_AkYzo4IGA.png" /></figure><p>Any calls to ‘/api/currentUser/:token’ will be authorized before the route handling function is executed. And that wraps up authenticating users with Facebook and securing/identifying user data with JSON Web Tokens. I hope this information proves helpful! Happy Coding!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r8kbxnFl1K2RTzyw8FispA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=344988f46503" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PWA; Service Workers]]></title>
            <link>https://medium.com/@jsmichot/pwa-service-workers-70414a6d96c7?source=rss-201643f7075a------2</link>
            <guid isPermaLink="false">https://medium.com/p/70414a6d96c7</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[progressive-web-app]]></category>
            <category><![CDATA[service-worker]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[pwa]]></category>
            <dc:creator><![CDATA[Justin Michot]]></dc:creator>
            <pubDate>Wed, 07 Mar 2018 03:46:12 GMT</pubDate>
            <atom:updated>2018-03-07T03:46:12.700Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/638/0*PYzkUP5Op7Zivfiy." /></figure><p>Functionality that use to be exclusive to native (mobile) applications are now possible within a web application. This new school tech combines the functionality of a web and native application into one app to rule them all: a Progressive Web Application (PWA). A Service Worker is a powerful tool that developer’s can use to implement much of what makes a Progressive Web Application progressive. Before diving into what a Service Worker does, it is helpful to first understand the principles that make a web application progressive.</p><p>10 Principles that define a PWA:</p><p>i. Works regardless of browser choice</p><p>ii. Responsive: fits any form (desktop, mobile, tablet) and any screen-size</p><p>iii. Works offline (Service Worker!)</p><p>iv. App-like: when used on a phone it looks and feels like a native app</p><p>v. Up-to-date (the Service Worker process)</p><p>vi. Safe (HTTPS)</p><p>vii. Discoverable: search engines can find it (Service Worker registration)</p><p>viii. Push Notifications</p><p>ix. Linkable (URL)</p><p>x. Installable: download/install on local machine (without app/play store)</p><p>The App Shell</p><p>The first step to developing an efficient Service Worker is to understand and define the app shell. The app shell is the minimum amount of HTML, CSS, and JavaScript required to power the UI (User Interface). This “minimum amount” threshold can be thought of as the skeleton of the application without the data or content that is rendered dynamically:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*izHBMw8rbcOVjMVrdJFngg.png" /></figure><p>The app shell is cached locally using a service worker. Hence, on subsequent visits the page renders the app shell instantly and the application only needs to retrieve the necessary data.</p><p>The Service Worker</p><p>A service worker offers a technical foundation to web apps (non-native apps) to include features such as offline functionality, periodic background syncs, and push notifications. A service worker is a script that runs in the browser separate from the web page. Through the process of background sync, features can be implemented that don’t need a web page or user interaction. That is, developers can use a service worker to cache assets and on subsequent visits use the cached assets first, providing a default (instantly loaded) experience even when offline. These are some core tenants of a service worker:</p><p>i. runs on separate thread to the main JavaScript that powers the application</p><p>ii. not represented within the window object wherein your app is running</p><p>iii. does not have direct access to the DOM</p><p>iv. only run over HTTPS</p><p>v. relies on promises</p><p>Service Worker life-cycle</p><p>i. Download: initial download occurs when the user first accesses a service worker-controlled web app; then, the service worker is re-downloaded every 24 hours.</p><p>ii. install: attempted when the downloaded file is found to be <em>new</em> (first service worker encountered or different from an existing service worker)</p><p>iii. activate: fires when either</p><p>a) first time installation is successful</p><p>b) after successful installation and when there are no pages loaded that are still using the previous service worker</p><p>c) after successful installation and the waiting period (see <em>b</em>) is skipped using ServiceWorkerGlobalScope.skipWaiting(); note: this activates the new service worker but to claim control of the existing pages that were still using the previous service worker you can use self.clients.claim()</p><p>Service Worker Registration</p><p>i. make sure service workers are supported by the browser</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*Crnl_LaUrKMAN0OyNbwbFw.png" /></figure><p>ii. use navigator.serviceWorker.register() to register the service worker; note: the path to the file that contains the service worker is relative to the root, not the JS file wherein the registration is occurring.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DLkZLmh6Jp_6Jk3WuiPE_w.png" /></figure><p>Install, Activate, Cache</p><p>When the service worker is registered the browser will attempt to install and activate the service worker. For this to be successful you will need an event listener in the service worker file. Include the files that build the app shell: for example, index.html, css, nav, headers, constant fixtures in the view, assets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GEvOFCAFmCq-0BOZMWjDYg.png" /></figure><p>Fetch (the service worker’s job)</p><p>Once the service worker is activated, fetch can be used to do the work the service worker is there to do. That is, intercept network requests and respond with the data that is cached if it matches the data being requested. This allows for instant rendering of the app shell on subsequent visits and cuts down on the over all time for the page to load. The code below returns the cached data if there is a match. Otherwise it makes the network call that was intercepted, adds the missing pieces to the cache (updates the cache for the next time the same request comes through), and returns the response. However, if there is not a match and the network is not available (offline) then the <em>catch</em> will render a default response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R6jNS5NL_CxXirX812Lq3A.png" /></figure><p>Activate (updating the Service Worker)</p><p>There are two key steps to updating a service worker: installing the new service worker and deleting old caches.</p><p>1. Installing the New Service Worker</p><p>Syntactically, this install is almost identical to the initial install. However, there is one crucial difference: the name. The name of the updated service worker needs to be different from the currently active service worker so that the active one is not disturbed. Hence, the initial service worker in the example above was tagged with the name ‘v1’, so the updated service worker is given the name ‘v2’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XRAfFNYletYJQxR_gifsvg.png" /></figure><p>The new version of the service worker is now available on refresh, or the next time the application is visited by the user. When this happens the browser will recognize the new service worker and install the new service worker in the background. However, the new service worker is not automatically activated upon a successful install. It is only activated when the old service worker is no longer being used by the application. Thus, during install and potentially for sometime after install the old service worker will still handle fetches. This ensures the functionality of the app during the service worker update. That is, a service worker is always active and any request intercepted during install of the updated service worker is handled and a response is sent.</p><p>Note: there are two alternative ways to stop a worker:</p><p>i. worker.terminate() from the main app</p><p>ii. self.close() inside of the worker</p><p>2. Deleting Old Caches</p><p>The ‘activate’ event listener can be used to delete old caches when the new service worker is activated. Trying to do this while the previous version is still running could break the application. Deleting old caches is very important because each browser has a hard limit on the amount of storage space that a service worker can use. Thus, you do not want to waste this limited resource by storing unused data. The code below is an example of how to use the activate event listener to delete old caches when a service worker is activated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5zfw8X7xU7gkn-dCN-p6UQ.png" /></figure><p>Note: promises passed into waitUntil() will block other events until completion. Thus, the clean-up operation will complete before the new service worker receives its first fetch event.</p><p>Conclusion</p><p>PWA’s are cutting edge and new school. They have the potential to extrapolate away much of the complexity in building an application for different platforms. That is, we can write one application that will perform on any platform with the look and feel like the app is developed specifically for the given platform. Learn now and you can get ahead of the game.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70414a6d96c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deployment with DigitalOcean]]></title>
            <link>https://medium.com/@jsmichot/deployment-with-digitalocean-1dc9617a68de?source=rss-201643f7075a------2</link>
            <guid isPermaLink="false">https://medium.com/p/1dc9617a68de</guid>
            <category><![CDATA[pm2]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[digitalocean]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Justin Michot]]></dc:creator>
            <pubDate>Wed, 28 Feb 2018 05:35:31 GMT</pubDate>
            <atom:updated>2018-02-28T05:36:57.103Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*OtVIEip9730X1aPA.png" /></figure><p>Deploying a web application can be challenging, especially if it’s your first time. For each issue that one may come across, there’s usually documentation online that can help solve the problem. However, if you are new to deploying, it would be helpful to have a simple and efficient process to successfully deploy your application online. Furthermore, it would be nice to have this process accessible in one place. Many times there are minor details and processes that are left out of the documentation. And for someone new to deployment, it is precisely these cracks wherein one may become stuck for hours at a time. I will provide an example that brings the full process together in one place. Note, this is an example that attempts to deploy an application so that anyone can view said application online: nothing more, nothing less. My goal is to provide a foundation that provides motivation through achieving goals, progressing, and being successful. And the opportunity for that motivation to fuel the continued learning process through experience. Also, I am solely focused on the process of deployment. Good-code that works and is ready for deployment will be assumed.</p><p>Deployment can take on many different paths. I will touch on deploying a node application, installing nvm, and running the server with pm2.</p><p><strong>Deployment</strong></p><p>Step 1: Create a Droplet</p><p>First, log in to DigitalOcean. Click “Create” and within the drop-down menu click “Droplets”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*ji4_h268tWyVrDIxnYP92g.png" /></figure><p>Step 2: Choose an image</p><p>Next you will need to choose an image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*Xa4ZlvJQhrP2NRvwXi5vsw.png" /></figure><p>Click on “One-click apps” to see the following options:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pSI0S4PV8szxuSqlRc6TSQ.png" /></figure><p>Most of these steps have several different options to choose from depending on your need and/or preference. I will select NodeJS.</p><p>Step 3: Choose a Size</p><p>This will depend on the amount of memory your application needs to run efficiently and your budget. I will choose the 2GB option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*KhkBPk02YIl_DrcrIFKr2w.png" /></figure><p>Step 4: Choose a datacenter region</p><p>Ideally, choose the closest available location. For me, it is New York:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*8zyZg2s4VrLHdRh2jW0LKg.png" /></figure><p>Step 5: Finalize and create</p><p>Prior to this step you can choose to add ssh keys to your droplet. However, for purposes of streamlining deployment and making it as simple as possible, I will not add any ssh keys this time. Now, choose a hostname, or use the one provided for you. I named this droplet “Example-Droplet”. Finally, click “Create” and the droplet will be created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qF1FkDPYS2H77VdE6QP5bA.png" /></figure><p>Step 6: SSH into your droplet</p><p>Now that I have a new droplet I can use a bash terminal to ssh into the droplet. First copy the IP address, then follow the syntax below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*JzUgA94SEZal7jyyoVQhgQ.png" /></figure><p>From the command line:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*_2ECOazwoci6cOr1L1aeAg.png" /></figure><p>Next you will have to answer a few prompts to gain access to the droplet. The first prompt lets you know that the authenticity of the IP address can’t be established. This is expected because I did not add any ssh keys. Type/enter “yes” to continue. Next you will need to enter the password. This password is sent to the account associated with the DigitalOcean account. Retrieve the password and enter. Next prompt will have you set a new password. Once complete you will enter into the droplet. The command line for my droplet appears like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*SEw3oVB3OiWbEyiGDpcQzQ.png" /></figure><p>Step 7 Git clone</p><p>Using git is an efficient way to get your code into the droplet. Again, there are different solutions here. I will use git clone deploy my application into the droplet. Also, git clone establishes the origin master to pull down from for any future updates. However, I am focused here on deployment, not on the application itself. I will clone from the master branch of the github repository that holds the code for the application I intend to deploy. The example below refers to the book-recommendations repository from my personal github account:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BEK6FrKo1of6Qopf_kveJQ.png" /></figure><p>Once the repository is cloned into the droplet, cd into the repository:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*CWxyCDlmhIAZZwMNRPz5tA.png" /></figure><p>Step 8 download package-managers</p><p>I will control the environment using NVM to access the newest versions of NodeJS. Execute the following codes to install Node and Bower:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*QCIfMIgZkqOXr_Hi-cyavA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*WRe_fZoQGDyxkib0-PHrzw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ATTF73E6uG-jTsOJoCdUuA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*nJ__NJdAVOciIsPrTaP7uQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*IZKVLjgjN-IO46HvzQ_ogA.png" /></figure><p>Find the latest LTS and install:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/237/1*j_RFxYlHM88t8elubg9HDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*5WR1dInuiFBG_ExRVrvF-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*9vlAwym6poiEINw84kB5OQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*UQmAtLDVCZ6N_NN7k_32yQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*6tc3gg-3PPOFOma7CxTIsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*zOG6zqMdNei6EMfq89qDxA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*NjdKwjVZdNrtIbQL_X2vrA.png" /></figure><p>Where necessary run npm install and/or bower install to install the dependencies the application relies on.</p><p>Step 9 Download PM2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*2Xt_d1WsnLUvENBK-frtoA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*hWh5iqvAyo9BFKPEecrRBQ.png" /></figure><p>PM2 is a General Purpose Process Manager for NodeJS apps. Starting and stopping the application in production is made simple and efficient. Notably, PM2 always keeps your application online with auto restarts and init system script generation.</p><p>Step 10 Run the server using PM2</p><p>This application runs from server/index.js. Furthermore, I have the port set to 3000. The final step to deployment is to launch the app using PM2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*yiFmlWTfodL2lSnsrrkMqA.png" /></figure><p>Congratulations! The internet is live online. Enter the IP address followed by a colon and the port number to see the deployed application. For example: {IPaddress}:{Port}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*HOyOp6uxxUmUq7T9_xAAjw.png" /></figure><p>Please note the IP address / application used above is an example: nothing more than a placeholder to demonstrate the process. I will delete the droplet created for this particular example.</p><p>Hopefully this process will help extract away the complexity. Once deployed you can explore different processes and technologies that add security and productivity to make your deployment better. Sometimes the first step is the hardest. Once you’ve made it this far the world is your oyster. Good luck and happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1dc9617a68de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OAuth2]]></title>
            <link>https://medium.com/@jsmichot/oauth2-35ff3f038acd?source=rss-201643f7075a------2</link>
            <guid isPermaLink="false">https://medium.com/p/35ff3f038acd</guid>
            <category><![CDATA[google-calendar]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[google-api]]></category>
            <category><![CDATA[oauth2]]></category>
            <dc:creator><![CDATA[Justin Michot]]></dc:creator>
            <pubDate>Wed, 21 Feb 2018 03:12:45 GMT</pubDate>
            <atom:updated>2018-02-21T03:12:45.994Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/494/0*rclyuhcDfWrBgUGJ.png" /></figure><p>Implementing “Auth” can be challenging, especially if it’s your first time. I will break down how to authenticate users with google sign-in and retrieve user-specific information from a google API. OAuth2 along with some helpful libraries will be featured.</p><p>There are four main steps that will be taken during this particular implementation of OAuth2:</p><ol><li>Obtain OAuth2 credentials</li><li>Obtain an Access Token</li><li>Send Access Token to an API</li><li>Refresh the Access Token when Applicable</li></ol><p>I. Obtain OAuth2 credentials</p><p>OAuth2 begins by obtaining credentials. Specifically, you need a “client ID” and a “client Secret”. You receive OAuth2 credentials from your account at console.developers.google.com. Once logged into your account go to the <em>credentials</em> section and click the drop-box labeled C<em>reate credentials</em> :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*5NUyyKZ3HvhSSKRKKhB36g.png" /></figure><p>From the drop-down menu select <em>OAuth client ID</em>. The next screen will allow you to create a client ID. All you need to do here is select the <em>Application type</em>, give your project a <em>Name</em>, and click <em>Create</em> :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*g_ZQpPcZDzDHaoHkPo9wKA.png" /></figure><p>Above I have selected <em>Web application</em> and named the project “Presentation-Example.” Google will alert you with the new client ID and Secret issued for your project :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*2abnYg7WT4l6nD79PavQrg.png" /></figure><p>After clicking <em>OK </em>you are redirected to the main Credentials page where the newly created project can be seen :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0IAIVGRSfzbY73QtYZzOw.png" /></figure><p>Click the name of the project and authorize the origin URI that you will be sending requests from. Also, redirect URI’s need to be set. During development you want to specify the local port you will be using. For a deployed application you will reference the corresponding URI using your applications domain name or IP address. You may use the example below as a guideline but the origin URI will need to be specific to your application.(note: reference the code examples below for clarification about the redirect URI and where it comes from)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*RZIYidTLYvTPbhbd8AI0gg.png" /></figure><p>That concludes step1. Time to dive into some code!</p><p>II &amp; III. Obtain an Access Token — Send Request to Google API</p><p>Server-side I am using NodeJS with these dependencies installed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*NXc-7nhu4Kh9HS8qI-lTzw.png" /></figure><p>Next, I use the middleware to extract away complexity. These packages contain good code that has been thoroughly debugged. No sense re-inventing the wheel here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*rDNkcD5Ua_umlVFYrlikcw.png" /></figure><p>Now it’s time to implement the <em>GoogleStrategy</em> from the <em>passport-google-oauth2</em> library above. This strategy takes care of the authentication process. Prompting the user to sign-in with Google and asking permission to access various aspects of their information from google. These permissions depend upon the <em>scope</em> as defined by the <em>GoogleStrategy</em>. The scope of your Strategy will depend on the purpose of your application. For this example I ask to obtain the user’s name, email, and access to their google calendars . Search Google online to find the proper scope for your <em>GoogleStrategy</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*jK8eO8V4TMl5fCd89PRUug.png" /></figure><p>If the User allows access to the above request, then an <em>accesstoken, refreshtoken, params</em> object, the user’s google <em>profile</em> object, and the <em>done </em>method are passed into a callback function. As indicated by the pseudocode above, it is recommended that you store information that your application needs to your database. Also the accesstoken received can be used to make request information from a google API within the Strategy’s scope. This is an example of an API call to receive events from a user’s google calendar :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wR2jKowI0lEd3t_XTSixUg.png" /></figure><p>Note that above is a helper function that makes a GET request to the Google Calendar API using the request library with Express. It is designed so that when calling this function a callback function is provided that will handle data received in the response appropriately. That is, format and store needed-data in the database, send data to client-side, etc.</p><p>Routing must be setup properly to implement this Strategy. The callback URI saved in step1 must authorize the appropriate routes in the code :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*2bX9-dJtoAZsAyeaaqY7zQ.png" /></figure><p>An access token has been received and used. But what if your application is designed to make subsequent API requests that require an access token. That is, when the user initially logs in the access token received works. But access tokens, by design, have a very short life span. Trying to use the same access token for subsequent requests during the user’s session will most likely not be successful unless you refresh the access token :</p><p>IV. Refresh the Access Token</p><p>From the route-handling above note that <em>accessType</em> is assigned the value <em>offline</em>. This is what prompts google to return an actual refresh token into the callback function from the Strategy implementation above (otherwise the <em>refreshtoken </em>parameter would have been <em>undefined</em>). Receiving and storing this user-specific refresh token in a database is required for step 4 of this demo to work. The refresh token can be used at the appropriate time (whenever subsequent API calls that require an access token are made) to receive a new access token. There are multiple ways to accomplish this. I will show one option by using the <em>googleapis</em> library :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*fqmQOHOQ0dk4lnHBnHi6Fg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uSnydlPHZqC2cq19sUoIpQ.png" /></figure><p>Above, the <em>refreshAccessToken</em> method (from the <em>googleapis</em> library) is used to refresh the access token; said method then passes the new access token into the callback function wherein I can access the <em>access_token</em> property from the <em>tokens</em> object and make a successful request to the Google Calendar API by using the new access token. Note that the I chose the name <em>“tokens”. </em>The same object will be passed in as the second argument to the callback regardless what you name it. However, the <em>access_token</em> property is not a choice. That is the property wherein the new accesstoken is stored.</p><p>I hope this demo helps you traverse what can be the large learning curve that is “Auth”. Good Luck and Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35ff3f038acd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ember.js]]></title>
            <link>https://medium.com/@jsmichot/ember-js-4a27add991cd?source=rss-201643f7075a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a27add991cd</guid>
            <category><![CDATA[emberjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Justin Michot]]></dc:creator>
            <pubDate>Wed, 07 Feb 2018 03:28:41 GMT</pubDate>
            <atom:updated>2018-02-07T03:28:41.023Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*jyQ0ulB8-2WqEqEFmsl1ww.png" /></figure><p><strong>Intro</strong></p><p>Ember.js is an open-source JavaScript web framework. Unlike many JavaScript frameworks, Ember.js follows the principle of Convention over Configuration by incorporating many “best practices” into the framework. Ember consists of five key concepts: Routes, Models, Templates, Components, Services.</p><p><strong>Routes</strong></p><p>Routing is the central part of an Ember application. The State of an application is represented by a URL. Each URL has a corresponding route object that controls what is visible to the user. The URL is set in several different ways. For example, when the user first visits the app or when the user clicks a link within the app. Once a URL is set, Ember maps the current URL to one or more route handlers. Handling routes plays a pivotal role within an application. Ember handlers can:</p><ul><li>render a template</li><li>load/change a model that is then available to the template</li><li>redirect to a different route</li></ul><p><strong>Models &amp; Components</strong></p><p>Models are objects that store the data used throughout the application. Most applications use a database to store data. And thus models are effectively loaded from and stored-in servers. Ember uses components to translate model data into a UI that the user can interact with.</p><p><strong>Templates</strong></p><p>Ember’s templates use the Handlebars templating library that allow for JavaScript code to be executed within the HTML document by using double curly braces: {{ }}. Ember templates also use “contexts” that require variables to be added to the Controller before being used in the HTML. This allows for dynamic binding. That is, if/when the value of a variable changes it is automatically updated in the DOM.</p><p><strong>Conclusion</strong></p><p>Overall, Ember is a powerful app that allows the programmer to be efficient with his/her time. The features of Ember help manage complexity. Time can be saved because Ember does many common and repetitive tasks for you. If you have a choice when it comes to choosing a front-end framework, consider looking into Ember.js.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a27add991cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streams]]></title>
            <link>https://medium.com/front-end-weekly/streams-ae04a543cc9e?source=rss-201643f7075a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae04a543cc9e</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Justin Michot]]></dc:creator>
            <pubDate>Wed, 31 Jan 2018 02:17:05 GMT</pubDate>
            <atom:updated>2018-01-31T02:17:05.544Z</atom:updated>
            <content:encoded><![CDATA[<p>NodeJS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aIAfqkDqkOQ9KNU2rVNT8w.png" /></figure><p>The internet is based on the concept of transferring data (or information) from point A to point B. Everything that you do online is, at some point, is reliant on data being sent from one computer to another computer. This data is transferred via streams.</p><p>Although from a programmer’s perspective the complexity of streams is mostly handled “under the hood.” However, it is worth knowing more about streams. In fact, in almost any situation in which data is being transferred from one place to another, the programmer has the ability to customize several aspects of the stream. Let’s take a look at what streams are and I’ll illustrate a couple of examples in which streams are specifically used in NodeJS.</p><p><strong>Without Streams</strong></p><p>Without streams large data transportation is very inefficient. That is, if you have a large file the entirety of that file must be read before it can be transported. And then upon arrival the entirety of that file must be written into memory before any of the data can be accessed. Consider the example below from NodeJS:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*_rG5ngmRWC3vYPhM5rIZDQ.png" /></figure><p>The code above does not use streams. And if dealing with small amounts of data the point will be moot. However, let’s dive deeper into what streams are, why are they so powerful and what can be accomplished by using them.</p><p><strong>Intro to Streams</strong></p><p>Streams transport data chunk by chunk. This data is typically <em>read</em> from file-A and/or is <em>written</em> to file-B. The concept of <em>reading</em> and <em>writing</em> data is central to the transport of data. Specifically, transporting data via streams through the process of <em>reading </em>and <em>writing </em>data, chunk by chunk, from one place to another is prevalent online.</p><p>Streams allow for the efficient use of memory space. For instance, if ultimately one large file is being sent from point A to point C, but needs to first be sent to point B for encoding, then streams will allow for point B to receive data from point-A chunk-by-chunk, handle the encoding of one chunk at a time, and send that chunk on to point C without ever having to store the entirety of the file in memory at point B. This concept encapsulates the power of streams. Point B may not have enough memory space to store the entire file at one time, but via streams the entire file can still be encoded at Point B and sent to Point C as long as Point B’s memory can hold one chunk. The size of this chunk can vary and be manually adjusted by the programmer.</p><p>There are four types of streams:</p><ol><li>Readable (“<em>source</em>”)</li><li>Writable (“<em>destination</em>”)</li><li>Duplex (“<em>readable</em> <em>&amp; writable</em>”)</li><li>Transform (<em>modifies the data midstream</em>)</li></ol><p><strong>The Concept of Source and Destination</strong></p><p>Readable and Writable streams are the foundation of understanding streams. Readable streams can be thought of as the source stream. That is, where the data being transported comes from. Furthermore, writable streams can be thought of as the destination stream. That is, where the data being transported is going. Consider the following example in NodeJS:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*vH2mwG4cqAZRguoEZjexCQ.png" /></figure><p>The <em>createReadStream</em> method from the <em>File System </em>module is used to stream data, chunk-by-chunk, from <em>filePathA</em>, and then the <em>pipe </em>method pieces together the data and uses <em>createWriteStream </em>to send the data chunk-by-chunk to <em>filePathB. </em>It is possible to stream data using only the <em>createWriteStream </em>(given that you are creating data on the fly). Also, it is possible to only use a <em>readable</em> stream (given that you are not transporting the data to any other destination). However, the code above would not work if you replaced <em>createReadStream</em> with <em>createWriteStream</em> and/or replaced <em>createWriteStream</em> with <em>createReadstream</em>. Hence, it may be helpful to think of streams in terms of <em>readable/source </em>streams and <em>writable/destination </em>streams.</p><p><strong>Duplex Streams</strong></p><p>A duplex stream is one stream with two channels. One Channel sends data and the other receives data. Each channel has its own buffer. That is, both channels can transport data simultaneously. Consider this pattern: a.pipe(b).pipe(a). This type of pattern is made possible via a duplex stream. That is, one connection between two computers wherein each computer can send and receive data from the other. The two channels allow each application to act as the source and/or the destination within the same stream. Duplex Streams are by far the most common type of stream online. Network Sockets use duplex streams to send and receive data. Think about online gaming and how multiple devices are sending and receiving data with each other simultaneously. Also, duplex streams are used to connect almost all network devices via TCP (Transmission Control Protocol) and IP (Internet Protocol).</p><p><strong>Transform Streams</strong></p><p>A transform stream is a stream that modifies the data being transported midstream. Two modules in NodeJS that can be used to illustrate this transformation are the zlib and crypto modules. Consider the example below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*V14nGZ9K3JQjJH0na19RIA.png" /></figure><p>This example is reading from point A and writing to point B. However, the data is compressed (<em>createGzip</em>) and encrypted (<em>createCipher</em>) along the way. Then the compressed/encrypted data is streamed from point B to point C. However, the data is deciphered and decompressed along the way. Hopefully, this clearly illustrates the concept of a transform stream. Please note that transform streams are conceptual. That is, convention describes the above example as a transform stream but no where in the code is it required to declare a transform stream. The same methods that can be used in isolation (<em>createReadStream/createWriteStream</em>) can be used to implement the source/destination for a transform stream. Overall, understanding the power of streams and role that streams play when transporting data is important from a programming perspective.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae04a543cc9e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/streams-ae04a543cc9e">Streams</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AngularJS binding…]]></title>
            <link>https://medium.com/front-end-weekly/angularjs-binding-d9d84b52bb1?source=rss-201643f7075a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9d84b52bb1</guid>
            <category><![CDATA[angularjs-binding]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[angular-binding]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Justin Michot]]></dc:creator>
            <pubDate>Wed, 24 Jan 2018 01:28:20 GMT</pubDate>
            <atom:updated>2018-01-24T01:34:50.060Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*FIoYZUJ5qk7NjGC6EZKBgA.png" /></figure><p>AngularJS is a powerful front-end JavaScript framework. However, it has a steep learning curve at first approach. Sometimes to begin the journey towards knowledge it’s best to focus on a core concept and understand one main concept in isolation. Then be able to extrapolate that concept in order to understand other concepts until eventually breaking down what was at first a vast new world of complexity into a functioning and productive understanding.</p><p>AngularJS provides the tools for a programmer to separate an application (aka <strong>model</strong>) into components. Each component has two main parts: an <em>HTML</em> template (aka <strong>view</strong>), and a controller (aka <strong>controller</strong>). AngularJS also gives the programmer the ability to embed custom tag attributes (<em>ng-</em> prefix) into HTML elements. AngularJS interpretes these <em>ng-</em> attributes as directives for how to render content to the page. The controller can be used to dynamically render content and is where the business logic (<em>JavaScript</em>) of the application is written.</p><p>At the core of AngularJS is the concept of data-binding. This binding establishes automatic synchronization between the model and view components. The view becomes a visual representation of the model at all times. When something in the model changes, the view reflects that change and vice versa. Let’s extrapolate away all the complexity of AngularJS and look at an example of how this concept of data-binding is executed in code.</p><p>It all starts with the creation of an angular module. This is the model: the single source of truth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*iTo88j058yOiGWZVVq6RQg.png" /></figure><p>Now we can inject AngularJS into the view. This allows for special AngularJS attributes and elements to be injected throughout the body of this HTML document.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*vtW9TaobwHkpJ8o3gg-MvQ.png" /></figure><p>Let’s assume that we have a working function that requests and receives videos from the YouTube API. These videos are stored in an array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*K8o46rJtcGBcGLPf8NwavA.png" /></figure><p>Next the data begins its journey throughout the application. Below is a component of the ‘video-player’ module. This component is named ‘app’. All other components will branch out from our ‘app’ component. The youTube constructor function is passed into the ‘app’ component. From ‘app’ youTube can be called and the data can be accessed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*9-yrw0_xpkhCJSNRDTe-Sg.png" /></figure><p>Now we can share this data with the View. The View below is rendered from an AngularJS component named ‘videoList’ that we will create. That is, in AngularJS, each view has a corresponding component. And each component can render a template (aka view). Previously the model received the data. Now we must bind the data between the component and it’s corresponding view. First the data is assigned to the variable. Below, an HTML attribute is used to create a variable in the video-list component. The variable is named <em>videos</em> and is assigned the value of $ctrl.videos. $ctrl can be thought of as a local object that contains all of the properties assigned to it within its component. The HTML below is part of the <em>app</em>’s template.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*TgkE01xDINh7YtksFaSe_g.png" /></figure><p>Now inside of the <em>videoList</em> component the binding comes to fruition inside of the bindings object. Note that AngularJS converts <em>video-list</em> into<em> videoList</em> automatically. This is a syntactic nuance that is outside the scope of our current focus.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*OWTNEJCd6LMVqKw6lxR5Wg.png" /></figure><p>The binding is complete. Now videos can be rendered inside of the <em>videoList</em> template using double curly braces (a special AngularJS markup feature to access data). Below is an example of how we would display the title of the first video in our videos array:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*YbKqO5Gx0rjcbOijfJDAYQ.png" /></figure><p>The AngularJS data-binding process establishes automatic synchronization between the model and view components. The view becomes a visual representation of the model at all times. When something in the model changes, the view reflects that change immediately without any other action on the programmer’s part to insure that the view is re-rendered upon said change.</p><p>Note that inside of the bindings object in which videos is bound with ‘&lt;’: the symbol directs AngularJS how to interpret the value assigned to the variable name. Most use cases can be accomplished using the ‘&lt;’ symbol. However, there are other options:</p><p>‘&lt;’ reads the attribute as <strong>CODE</strong></p><p>‘@’ reads the attribute as <strong>TEXT</strong></p><p>‘=’ <strong>TWO-WAY DATA BINDING</strong></p><p>‘&amp;’ wraps attribute in a <strong>FUNCTION</strong></p><p>Hopefully this illustration simplifies the greatness of AngularJS binding. This procedure can be followed throughout the entirety of an application. Variables and functions live at the top level of the application and are passed down and placed throughout separate components where needed. This allows for efficient transition from a testing environment to production and portability of components being added to or taken away from the application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9d84b52bb1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/front-end-weekly/angularjs-binding-d9d84b52bb1">AngularJS binding…</a> was originally published in <a href="https://medium.com/front-end-weekly">Frontend Weekly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ES8 What’s New in JavaScript?]]></title>
            <link>https://medium.com/@jsmichot/es8-whats-new-in-javascript-cecea4213f6f?source=rss-201643f7075a------2</link>
            <guid isPermaLink="false">https://medium.com/p/cecea4213f6f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[es8]]></category>
            <dc:creator><![CDATA[Justin Michot]]></dc:creator>
            <pubDate>Wed, 17 Jan 2018 06:49:00 GMT</pubDate>
            <atom:updated>2018-01-17T06:49:00.866Z</atom:updated>
            <content:encoded><![CDATA[<p>Currently, my day-to-day life is fully engrossed with coding. Specifically, I am going through an all-time consuming immersive program to become a software engineer. JavaScript, being my base language, recently received new specifications, or features, via the release of ES8 about six months ago in June 2017. I think it’s worth while to highlight what’s new!</p><p><strong>String Padding</strong></p><p>There are two new functions on the String Object: padStart and padEnd. Both functions take two arguments, a <em>number </em>and an (optional) <em>string</em>, and return a string with a minimum length of <em>number </em>(hereinafter referred to as <em>minLength</em>). The number represents the “minimum length” of the returned string. If a string’s length is less than <em>minLength</em> then padStart adds “padding” at the beginning of the string until the string’s length equals <em>minLength</em>. Calling padEnd under the same circumstance adds “padding” to the end of the string until the string’s length equals <em>minLength</em>. The “padding” by default is blank spaces. However, you can provide a <em>string</em> as the second argument and the characters of the <em>string</em> will be used to pad the string sequentially, potentially repeating characters if necessary or not including all characters depending on when the desired length of the returned string is reached. Here are some simple examples to illustrate syntax and return values of padStart and padEnd:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*MtD2QoxkWecqXiDHXOwpeQ.png" /></figure><p><strong>Object.values(obj) &amp; Object.entries(obj)</strong></p><p>Similar to Object.keys(obj), except Object.values(obj) returns an array of the given object’s (<em>obj</em>) values. And Object.entries(<em>obj</em>) returns an array of arrays with each sub-array containing a key/value pair: [ key, value]. [key, value] ].</p><p><strong>Trailing Commas</strong></p><p>An error will no longer be thrown when there is a trailing comma at the end of a function’s parameter or arguments list.</p><p><strong>Object Descriptors</strong></p><p>Object.getOwnPropertyDescriptors(<em>obj</em>, <em>prop</em>) takes an object and a property and returns all property descriptors of the given property. Object.getOwnPropertyDescriptors allows a programmer to pass down a property’s descriptor values through prototypal inheritance. Specifically when using Object.create. For instance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*DQRYMjI7gyGqF43F0d4n7g.png" /></figure><p>Prior to ES8, Object.create would reset all descriptors to their default values. Now, creating an object with the syntax from line 9 would not allow the new object to set a name property. The name property would also delegate up to person and return ‘Sally” unless the writable descriptor is reassigned to <strong>true</strong>.</p><p>The return value is an object with the following properties: “value”, “writable”, “get”, “set”, “configurable”, and “enumerable”.</p><p>“value” is the value of the associated property (<em>prop</em>).</p><p>“writable” is a boolean and is <strong>true </strong>if the value of <em>prop</em> can be changed.</p><p>“get” and “set” are functions that serve as the getter/setter functions of <em>prop</em> respectively, or <strong>undefined</strong> if prop does not have getter/setter functions.</p><p>“configurable” is a boolean and if <strong>true</strong> the descriptor properties can be changed and <em>prop</em> can be modified/deleted from the corresponding object (<em>obj</em>).</p><p>“enumerable” is true if the <em>prop</em> will be accounted for/looped-over when a <strong>for in</strong> loop is invoked on the corresponding object (<em>obj</em>).</p><p><strong>Shared Array Buffer Object</strong></p><p>Gives the programmer the ability to control memory allocation and deallocation. Using the keyword <strong>new</strong> you can assign an array of a set size (in bytes).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*Sq44npyGsl_ijgfzKt5SmA.png" /></figure><p><em>newArray</em> has a set size in memory of 10 bytes.</p><p>The use case is for narrow/specific situations when using memory space as efficiently as possible is absolutely vital. JavaScript, when allocating memory for complex datatypes often reserves/uses more memory space than is actually needed. Also, garbage collection can be inefficient at times when unimportant references are left pointing at unneeded variables. The SharedArrayBuffer offers more control over an applications use of memory space as an alternative.</p><p><strong>Async Functions</strong></p><p>The evolution of “asynchronous” JavaScript and Promises continue. Async functions seeks to add more syntactically pleasing options to Promises (which in turn did the same for “callback hell”). In front of a function marked <strong>async</strong> a programmer can place the <strong>await</strong> keyword in front of an expression that returns a promise. The execution of the <strong>async</strong> function is paused until the promise is resolved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*gIfQYRAdNHuG0a5bMmnNhA.png" /></figure><p>It is important to note that only one <strong>await</strong> happens at a time. That is, if there were more awaits on lines 4, 5, etc… then they would not execute until the first <strong>await</strong> on line 3 is resolved. If you want to <strong>await</strong> more than one promise at the same time then you must use <strong>await</strong> Promise.all();</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cecea4213f6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Concept of “Public” , “Private”, & “Privileged” in JavaScript]]></title>
            <link>https://medium.com/@jsmichot/the-concept-of-public-private-privileged-in-javascript-569a84c7e212?source=rss-201643f7075a------2</link>
            <guid isPermaLink="false">https://medium.com/p/569a84c7e212</guid>
            <category><![CDATA[privatevariable]]></category>
            <category><![CDATA[privileged-variables]]></category>
            <category><![CDATA[public-variables]]></category>
            <category><![CDATA[closure]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Justin Michot]]></dc:creator>
            <pubDate>Tue, 09 Jan 2018 20:04:57 GMT</pubDate>
            <atom:updated>2018-01-09T20:04:57.893Z</atom:updated>
            <content:encoded><![CDATA[<p>I am currently learning JavaScript as my first computer programming language. It is clear to me that JavaScript patterns can be quite different from other languages. Many conventions in JavaScript aim to bridge this difference. For instance, at Operation Spark we follow the Hack Reactor immersive curriculum. One convention within the Hack Reactor community is to begin all “private” variable names with an underscore. Cool, except what’s a “private” variable?</p><p>I do not have a coding perspective outside of JavaScript, but many programmers do. And as it turns out, “public” and “private” are common keywords used in other languages to accomplish what JavaScript does through closure.</p><p>JavaScript has first-class functions. This allows functions to be passed in as arguments to other functions and returned as the output value when a function is invoked. If the function returned references variable(s) from it’s parent scope, it forms a “closer”, that is, it retains access to those variables.</p><p>JavaScript lingo refers to the variable(s) that the returned function references as a “closure variable”. In other languages “closure variables” are “private.” For example, in Java, “private” variables are variables that are only available to the class in which they belong. However, JavaScript does not have classes, but offers different patterns that mimic the concept of classes. One of which is referred to as pseudo-classical instantiation. Through the use of “closure”, “private” variables (aka “closure variables”) are only available to the instances created by the Constructor function through a “privileged” method (aka “closure function”).</p><p>“Public” variables are visible to all classes. That is, they can be modified, deleted, and replaced. All JavaScript variables that are not considered to be “private”, are “public”. In fact, closure functions are themselves “public” but can be referred to as “privileged” to note their access to “private” variables.</p><p>Although JavaScript does not technically have “public”, “private”, and “privileged” variables, it is important to understand how traditional patterns in other languages translate into JavaScript. Communication foregoes progress. Many teachers of JavaScript come from other languages originally. Many students of JavaScript have a background in other languages. And it is vital for students like me who are learning JavaScript as a first language to communicate and understand common lingo that persists throughout the coding community as a whole.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=569a84c7e212" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>