<?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 Hassan Ali on Medium]]></title>
        <description><![CDATA[Stories by Hassan Ali on Medium]]></description>
        <link>https://medium.com/@hassanhelfi?source=rss-aa091aee2b10------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*g4f6qxwfQDOj_cjtewDhQA.jpeg</url>
            <title>Stories by Hassan Ali on Medium</title>
            <link>https://medium.com/@hassanhelfi?source=rss-aa091aee2b10------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 09:38:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hassanhelfi/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[How to Never Miss a GitHub Mention]]></title>
            <link>https://medium.com/hackernoon/how-to-never-miss-a-github-mention-fdd5a0f9ab6d?source=rss-aa091aee2b10------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdd5a0f9ab6d</guid>
            <category><![CDATA[programmer]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[version-control]]></category>
            <dc:creator><![CDATA[Hassan Ali]]></dc:creator>
            <pubDate>Sat, 26 Jan 2019 14:15:38 GMT</pubDate>
            <atom:updated>2019-05-02T05:30:33.253Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v1huB5UCNg8mETB6" /><figcaption>Photo by <a href="https://unsplash.com/@jetlag?utm_source=medium&amp;utm_medium=referral">David Troeger</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Does your team use <a href="https://hackernoon.com/tagged/github">GitHub</a> as their main source version control? Mine does and because of that my <a href="https://hackernoon.com/tagged/email">email</a> client is constantly populated with GitHub messages. A part of me dies every time I resume work after taking PTO knowing that I’ll be coming back to pages and pages of GitHub notifications. Also, if you happen to work in a distributed team or your team’s work is open source, then there is a high chance you wake up to a page or two of notifications…everyday. In this post I want to share with you two tips that helped me manage GitHub notifications.</p><h3><strong>Reduce the Noise</strong></h3><p>Make yourself a favor and head over to GitHub’s <a href="https://github.com/watching">watching page</a> to unsubscribe from any repository you don’t want to be alerted for each new pull requests and issues that are created. If you only care about when releases are published, then navigate to the main page of the repository and click “Releases only” from the drop-down menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pTOpBHWwaIbKvkjbZZ_5sg.png" /></figure><h3>Create Filters</h3><p>One of the best ways I found that helps me manage GitHub notifications is to create filter rules that attach labels (tags) to emails. Labels are similar to folders except you can apply multiple labels to a single message. I would assume most email services would have support for tags but if yours doesn’t, then you’re probably overdue for a switch.</p><h4>Identifying the notification reason</h4><p>GitHub has done a really good job with their messages; they use email headers and the Cc email address to provide the notification reason. The From header will always be <a href="/service/mailto:notifications@github.com">notifications@github.com</a> and the second Cc email address will have the notification reason. The suffix for the notification reason will always be <a href="http://twitter.com/noreply">@noreply</a>.github.com; the prefix, however, will contain the notification reason. The list of reasons are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xvbw5sKF4Ochy36qvxkCyw.png" /><figcaption><a href="https://help.github.com/articles/about-email-notifications/#filtering-email-notifications">https://help.github.com/articles/about-email-notifications/#filtering-email-notifications</a></figcaption></figure><p><em>Note: </em><em>review_request seems to be missing from the list</em></p><h4>Assigning labels to GitHub emails</h4><p>For the sake of this post, I will use the Gmail service. If you’ve never created filters before, head over to <a href="https://support.google.com/mail/answer/6579?hl=en">https://support.google.com/mail/answer/6579?hl=en</a> for easy steps on how to create a filter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p6ubCuZ_aVPHK2yQdqnS4Q.png" /><figcaption>An empty filter form</figcaption></figure><p>The From and Has the words input fields are usually more than enough to filter GitHub emails accordingly. For the former, it will always be notifications@github.com. The following is what I consider the must-haves when labeling GitHub notifications (the below values correspond to the Has the words field).</p><p><strong>Your review is requested</strong></p><p>cc:review_requested@noreply.github.com AND “requested your review”</p><p><strong>A team review is requested</strong></p><p>cc:review_requested@noreply.github.com AND “requested review from”</p><p><strong>You were mentioned on an issue/pull request</strong></p><p>cc:mention@noreply.github.com</p><p><strong>You were assigned to an issue/pull request</strong></p><p>cc:assign@noreply.github.com</p><p><em>Note: </em><em>AND , </em><em>cc: and </em><em>“ ”are search operators that can be used to generate improved filtered results. Feel free to check out the complete list of </em><a href="https://support.google.com/mail/answer/7190?hl=en"><em>search operators</em></a><em>.</em></p><p>Here’s the full of list of my GitHub filters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KNlsnTcgN63PQgzdZ35-dQ.png" /><figcaption>My current list of GitHub filters</figcaption></figure><p>…and here’s how it shows up in the UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x-KNla2XVH27VhiyTF0Bqw.png" /></figure><p>As a closing remark, reducing the noise and creating filters have helped me a lot. I actually only started using labels after realizing that I kept missing GitHub mentions, especially on pull requests I didn’t create nor was the reviewer. I hope you enjoyed this post. Feel free to share any other tips you may have.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdd5a0f9ab6d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/how-to-never-miss-a-github-mention-fdd5a0f9ab6d">How to Never Miss a GitHub Mention</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn How to Manage Dotfiles]]></title>
            <link>https://medium.com/hackernoon/learn-how-to-manage-dotfiles-b8b62c6c5491?source=rss-aa091aee2b10------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8b62c6c5491</guid>
            <category><![CDATA[unix]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[dotfiles]]></category>
            <dc:creator><![CDATA[Hassan Ali]]></dc:creator>
            <pubDate>Fri, 18 Aug 2017 16:17:14 GMT</pubDate>
            <atom:updated>2019-05-02T05:30:33.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Li4H27cRUD8A4JWD8PtRUw.png" /></figure><p>I recently got a new laptop and a coworker of mine suggested I start automating my setup configurations. The goal is to allow me bootstrap and replicate my configuration preferences on different machines almost instantly. One item leading the todo’s list is the <a href="https://hackernoon.com/tagged/management">management</a> of dotfiles. Today I will share with you how you can harness the power of the Unix shell to create a script that you can use to manage your dotfiles between different machines.</p><p><a href="https://hackernoon.com/tagged/dotfiles">Dotfiles</a> are used to customize Unix-like systems. The neat thing about them is that they could be modified to suit your own preferences. Examples include .gitconfig, .bash_profile and .vimrc to name a few. As a convention, dotfiles are usually stored in the home directory. You can find yours by typing echo $HOME on your shell. On my machine, it shows /Users/haali.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*WNyt85WW_eCQdqC1MkOQxw.png" /></figure><p>Getting started is straight forward. We need to organize our dotfiles in a directory. This is something you need to do only once since later the directory containing all of our dotfiles will be stored on Git. To organize our files, we will need to move/copy our dotfiles from the $HOME directory to a new directory. We will refer to that new directory as $dir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*BZN5b1YQLX8estNupAUKAA.png" /><figcaption>Original copies are to be stored in $dir</figcaption></figure><p>For this post, let’s assume we want to track .vimrc, .gitconfig and .zshrcbut feel free to add as many dotfiles as you want. On your terminal, run the following two statements:</p><pre>❯ mkdir $HOME/Documents/dotfiles<br>❯ cp $HOME/{.vimrc, .gitconfig, .zshrc} $HOME/Documents/dotfiles</pre><p>If you’ve never written bash previously, the first statement creates a directory dotfiles in the given path and the second statement copies the selected files to the dotfiles folder. FYI, this is the only time you will type those statements for this particular automation. In the future, you will simply retrieve your dotfiles from git and run a script.</p><h3>Creating the script</h3><p>Open your editor of choice and create a new file dotfiles_setup.sh with the following line at the very top:</p><pre>#!/bin/bash</pre><p>This tells the process that this script should always be run with bash, rather than another shell.</p><p>Next, let’s store the dotfiles we care about in a variable. We will also need a variable to store the path of the created directory that has the original dotfiles.</p><pre>dotfiles=(&quot;.vimrc&quot; &quot;.zshrc&quot; &quot;.gitconfig&quot;)<br>dir=&quot;${HOME}/Documents/dotfiles&quot;</pre><p>Moving on, as a convention, most dotfiles are read from the $HOME directory. Having moved our dotfiles away from the $HOMEdirectory, we will need a way to create a link connecting each moved file from $HOME to $dir. Fortunately, this is easily accomplished by using the ln command. The link command basically creates a copy that points to the original file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*s3mN9aEjAF1nTnvf8_z0cA.png" /><figcaption>Original copies are stored in $dir. $HOME contains pointer dotfiles</figcaption></figure><p>Continuing along with the script, add the following lines:</p><pre>for dotfile in &quot;${dotfiles[@]}&quot;;do<br> ln -sf &quot;${HOME}/${dotfile}&quot; &quot;${dir}&quot;<br>done</pre><p>This code segment has a for loop at the beginning which loops over every element of $dotfiles defined earlier and uses the ln command to create a soft link that points to the original dotfile which was moved to $dir. A <a href="https://en.wikipedia.org/wiki/Symbolic_link">soft link</a> is a special kind of file that points to another file in the file system and doesn’t contain the data in the target file.</p><p>That’s it! Head over to your terminal and let the magic happen with:</p><pre>❯ ./dotfiles_setup.sh</pre><p>If you head over to $HOME and run ls -la $HOME, you will be able to visually see all the created references to $dir. In the $HOME directory, the dotfile references will be shown with an arrow pointing to the original copy. On my machine for instance .gitconfig is seen as:</p><pre>.gitconfig -&gt; /Users/haali/Documents/dotfiles/.gitconfig</pre><h3>Making changes</h3><p>Any changes made to $dir will be seen momentarily by the reference files so you don’t have to do anything special. I strongly recommend you keep your dotfile synced with git so that you could replicate your most up-to-date machine configurations on any machine.</p><h3>The whole script</h3><pre>#!/bin/bash</pre><pre>dotfiles=(&quot;.vimrc&quot; &quot;.zshrc&quot; &quot;.gitconfig&quot;)</pre><pre>dir=&quot;${HOME}/Documents/dotfiles&quot;</pre><pre>for dotfile in &quot;${dotfiles[@]}&quot;;do<br> ln -sf &quot;${HOME}/${dotfile}&quot; &quot;${dir}&quot;<br>done</pre><p>I hope this post will get you to start automating all the things. Credit where credit’s due, I want to thank my coworker <a href="https://twitter.com/_eoger">Edouard</a> for inspiring me to get started with automating all the things.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8b62c6c5491" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/learn-how-to-manage-dotfiles-b8b62c6c5491">Learn How to Manage Dotfiles</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Code Splitting for React Router with Webpack and HMR]]></title>
            <link>https://medium.com/hackernoon/code-splitting-for-react-router-with-webpack-and-hmr-bb509968e86f?source=rss-aa091aee2b10------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb509968e86f</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[neutrinos]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[webpack-2]]></category>
            <dc:creator><![CDATA[Hassan Ali]]></dc:creator>
            <pubDate>Tue, 04 Apr 2017 18:20:56 GMT</pubDate>
            <atom:updated>2019-05-02T05:30:34.121Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*74w0uj8zZAkz2h8NJPw1pw.jpeg" /></figure><p><em>In this guide we’ll create a </em><a href="https://github.com/mozilla-neutrino/react-router-starter"><em>starter application</em></a><em> that uses routes with code splitting.</em></p><p>For big web apps, it’s not efficient to put all of your code into a single file. Large apps should only download the <a href="https://hackernoon.com/tagged/javascript">JavaScript</a> required to boot the app. We want to be able to break a single file into many fragments. Splitting your code into multiple chunks is what we refer to as “code splitting”. Chunks will be loaded as the user navigates around.</p><p><a href="https://neutrino.js.org/">Neutrino</a>, will be used to see how we can achieve code splitting with React, Webpack, and React Router. Neutrino is an awesome tool that harnesses the power of Webpack to let you create and build modern JavaScript applications with zero initial configuration. It works by allowing us to inject shared presets or configurations. We will be using the React preset. The latter requires you to be on Node.js v6.9+. According to the <a href="https://neutrino.js.org/presets/neutrino-preset-react/">Neutrino documentation</a>, the React preset features:</p><ul><li>Modern Babel compilation supporting ES modules, last 2 major browser versions, async functions, and dynamic imports</li><li>Support for import CSS, HTML, images, fonts, and icons</li><li>Tree-shaking to create smaller bundles</li><li>Hot Module Replacement, no HTML templating, and much more</li></ul><p>The entire source code of this post is <a href="https://github.com/mozilla-neutrino/react-router-starter">available on GitHub</a>. Without further ado, let’s get started.</p><p>First, we need a directory to start working from. From your terminal, create a new directory and change into it. Then we are going to install neutrino, neutrino-preset-react and react-hot-loader as development dependencies. We will also need react, react-dom and react-router-domfor actual React development. react-hot-loader@3.0.0-beta-6 is the latest version at the time of this write-up.</p><pre>❯ mkdir react-code-splitting<br>❯ cd react-code-splitting/<br>❯ yarn add --dev neutrino neutrino-preset-react<br>❯ yarn add --dev react-hot-loader<a href="http://twitter.com/3">@3</a>.0.0-beta.6<br>❯ yarn add react react-dom react-router-dom</pre><p>By default, the React preset looks for source code in a src directory with the main entry point being index.js.</p><pre>❯ mkdir src &amp;&amp; touch src/index.js</pre><p>Let’s edit index.js with a simple hello world example. We’ll be changing that file later but for now, we will keep it simple for the sake of testing the bare minimum.</p><pre>import React from &#39;react&#39;;<br>import { render } from &#39;react-dom&#39;;<br><br>render(&lt;h1&gt;Hello world!&lt;/h1&gt;, document.getElementById(&#39;root&#39;));</pre><p>Now edit your project’s package.json to add commands for starting and building the application:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;neutrino start --use neutrino-preset-react&quot;,<br>    &quot;build&quot;: &quot;neutrino build --use neutrino-preset-react&quot;<br>  },<br>  &quot;devDependencies&quot;: {<br>    &quot;neutrino&quot;: &quot;^5.2.0&quot;,<br>    &quot;neutrino-preset-react&quot;: &quot;^5.2.0&quot;<br>  },<br>  &quot;dependencies&quot;: {<br>    &quot;react&quot;: &quot;^15.4.2&quot;,<br>    &quot;react-dom&quot;: &quot;^15.4.2&quot;,<br>    &quot;react-hot-loader&quot;: &quot;3.0.0-beta.6&quot;,<br>    &quot;react-router-dom&quot;: &quot;^4.0.0&quot;<br>  }<br>}</pre><p>Start the app then open a browser to the address in the console.</p><pre>❯ yarn start<br>✔ Development server running on: http://localhost:5000<br>✔ Build completed</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CgA9AEhNtEm6cjKxAK-cDw.png" /></figure><p>Great, we’re now ready to split code like real ninjas :-)</p><p>To support Hot Module Replacement (HMR), change index.js, the previously created file to the following:</p><pre>// index.js</pre><pre>import React from &#39;react&#39;;<br>import { render } from &#39;react-dom&#39;;<br>import { AppContainer } from &#39;react-hot-loader&#39;;<br><br>import <em>App </em>from &#39;./App&#39;;<br><br>const <em>renderApp </em>= () =&gt; {<br>  render(<br>    &lt;AppContainer&gt;<br>      &lt;App /&gt;<br>    &lt;/AppContainer&gt;,<br>    document.getElementById(&#39;root&#39;),<br>  );<br>};<br><br>// This is needed for Hot Module Replacement<br>if (module.hot) {<br>  module.hot.accept(&#39;./App&#39;, () =&gt; <em>renderApp</em>());<br>}<br><br><em>renderApp</em>();</pre><p>We added AppContainer to specify which part of the app we want HMR, and an if statement to activate it in development mode. We also imported App.js which we will create next.</p><pre>// App.js</pre><pre>import React from &#39;react&#39;;<br>import { BrowserRouter as Router, Route, Link } from &#39;react-router-dom&#39;;<br>import asyncComponent from &#39;./components/asyncComponent&#39;;<br><br>const Page1 = asyncComponent(() =&gt; import(&#39;./components/Page1&#39;)<br>  .then(module =&gt; module.default), { name: &#39;Page 1&#39; });<br>const Page2 = asyncComponent(() =&gt; import(&#39;./components/Page2&#39;)<br>  .then(module =&gt; module.default), { name: &#39;Page 2&#39; });<br>const Home = asyncComponent(() =&gt; import(&#39;./components/Home&#39;)<br>  .then(module =&gt; module.default), { name: &#39;Home&#39; });<br><br>const App = () =&gt; (<br>  &lt;Router&gt;<br>    &lt;div className=&quot;App&quot;&gt;<br>      &lt;ul&gt;<br>        &lt;li&gt;&lt;Link to=&quot;/&quot;&gt;Home&lt;/Link&gt;&lt;/li&gt;<br>        &lt;li&gt;&lt;Link to=&quot;/page1&quot;&gt;Page 1&lt;/Link&gt;&lt;/li&gt;<br>        &lt;li&gt;&lt;Link to=&quot;/page2&quot;&gt;Page 2&lt;/Link&gt;&lt;/li&gt;<br>      &lt;/ul&gt;<br><br>      &lt;Route exact path=&quot;/&quot; component={Home} /&gt;<br>      &lt;Route path=&quot;/page1&quot; component={Page1} /&gt;<br>      &lt;Route path=&quot;/page2&quot; component={Page2} /&gt;<br>    &lt;/div&gt;<br>  &lt;/Router&gt;<br>);<br><br>export default App;</pre><p>App.js imports react-router-dom and returns the Router component with the routes injected.</p><h3>Dynamic Routes</h3><p>From your terminal, create routes to use. We will also need asyncComponent.js to lazily load components.</p><pre>❯ mkdir src/components<br>❯ touch src/components/Page1.js<br>❯ touch src/components/Page2.js<br>❯ touch src/components/Home.js<br>❯ touch src/components/asyncComponent.js</pre><p>We’ll fill in the bare minimum for the routes.</p><pre>// Page1.js</pre><pre>import React from &#39;react&#39;;<br><br>const <em>Page1 </em>= (props) =&gt; &lt;h1&gt;{props.name}&lt;/h1&gt;;<br><br>export default <em>Page1</em>;</pre><pre>// Page2.js</pre><pre>import React from &#39;react&#39;;<br><br>const <em>Page2 </em>= (props) =&gt; &lt;h1&gt;{props.name}&lt;/h1&gt;;<br><br>export default <em>Page2</em>;</pre><pre>// Home.js</pre><pre>import React from &#39;react&#39;;<br><br>const <em>Home </em>= (props) =&gt; &lt;h1&gt;{props.name}&lt;/h1&gt;;<br><br>export default <em>Home</em>;</pre><p>We’re almost done. Our last task is to write logic to lazily load components. We will do that through asyncComponent.js.</p><pre>// asyncComponent.js</pre><pre>import React from &#39;react&#39;;<br><br>export default (loader, collection) =&gt; (<br>  class AsyncComponent extends React.Component {<br>    constructor(props) {<br>      super(props);<br><br>      this.Component = null;<br>      this.state = { Component: AsyncComponent.Component };<br>    }<br><br>    componentWillMount() {<br>      if (!this.state.Component) {<br>        loader().then((Component) =&gt; {<br>          AsyncComponent.Component = Component;<br><br>          this.setState({ Component });<br>        });<br>      }<br>    }<br><br>    render() {<br>      if (this.state.Component) {<br>        return (<br>          &lt;this.state.Component { ...this.props } { ...collection } /&gt;<br>        )<br>      }<br><br>      return null;<br>    }<br>  }<br>);</pre><p>And we’re done!</p><h3><strong>Quick Start</strong></h3><p>Start the app with yarn start, then open a browser to <a href="http://localhost:3000.">http://localhost:5000</a>.</p><pre>❯ yarn start<br>✔ Development server running on: <a href="http://localhost:5000/">http://localhost:5000</a><br>✔ Build completed</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*19BmQqKad8xzQYlPMhE0Ug.png" /></figure><p>Open the <a href="https://hackernoon.com/tagged/network">network</a> tab to see the individual chunks being loaded lazily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uBN_6SBbOWKspX1TlunGKA.png" /></figure><h3>Building</h3><p>The React preset builds static assets to the build directory by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ObUdys87n9QuS0YosaLXsg.png" /></figure><p>To conclude, we used <a href="https://github.com/mozilla-neutrino/neutrino-dev">Neutrino</a> to roll up a React application and split our code into multiple chunks. We also incorporated HMR to inject updated modules without reloading the page. See <a href="https://github.com/mozilla-neutrino/react-router-starter">react-router-starter</a> for the complete code.</p><figure><a href="http://bit.ly/HackernoonFB"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hqOaABQ7XGPT-OYNgiUBg.png" /></a></figure><figure><a href="https://goo.gl/k7XYbx"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vgw1jkA6hgnvwzTsfMlnpg.png" /></a></figure><figure><a href="https://goo.gl/4ofytp"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKBpq1ruUi0FVK2UM_I4tQ.png" /></a></figure><blockquote><a href="http://bit.ly/Hackernoon">Hacker Noon</a> is how hackers start their afternoons. We’re a part of the <a href="http://bit.ly/atAMIatAMI">@AMI</a> family. We are now <a href="http://bit.ly/hackernoonsubmission">accepting submissions</a> and happy to <a href="/service/mailto:partners@amipublications.com">discuss advertising &amp; sponsorship</a> opportunities.</blockquote><blockquote>If you enjoyed this story, we recommend reading our <a href="http://bit.ly/hackernoonlatestt">latest tech stories</a> and <a href="https://hackernoon.com/trending">trending tech stories</a>. Until next time, don’t take the realities of the world for granted!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35tCjoPcvq6LbB3I6Wegqw.jpeg" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb509968e86f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/code-splitting-for-react-router-with-webpack-and-hmr-bb509968e86f">Code Splitting for React Router with Webpack and HMR</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Three JavaScript Array Hacks]]></title>
            <link>https://medium.com/dailyjs/3-javascript-array-hacks-b360a5d01ab1?source=rss-aa091aee2b10------2</link>
            <guid isPermaLink="false">https://medium.com/p/b360a5d01ab1</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tips]]></category>
            <category><![CDATA[hacks]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Hassan Ali]]></dc:creator>
            <pubDate>Tue, 14 Mar 2017 17:45:08 GMT</pubDate>
            <atom:updated>2017-03-29T12:54:41.666Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FqK6ofpEMS_EoYqNA77g4g.jpeg" /></figure><p>Arrays are everywhere in JavaScript and with the new <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Spread_operator">spread operators</a> introduced in ECMAScript 6, you can do awesome things with them.</p><p><em>In this post I will show you three useful tricks you can use when programming:</em></p><h3>1. Iterating through an empty array</h3><p>JavaScript arrays are sparse in nature in that there are a lot of holes in them. Try creating an array using the Array’s constructor and you will see what I mean.</p><pre>&gt; const arr = new Array(4);<br>[undefined, undefined, undefined, undefined]</pre><p>You may find that iterating over a sparse array to apply a certain transformation is hard.</p><pre>&gt; const arr = new Array(4);<br>&gt; arr.map((elem, index) =&gt; index);<br>[undefined, undefined, undefined, undefined]</pre><p>To solve this, you can use Array.apply when creating the array.</p><pre>&gt; const arr = Array.apply(null, new Array(4));<br>&gt; arr.map((elem, index) =&gt; index);<br>[0, 1, 2, 3]</pre><p>A nicer way to iterate through an empty array is to use spread operators. Shout-out to <a href="https://medium.com/u/1bee792e9fb4">Hugo Caillard</a> for pointing that out.</p><pre>&gt; const arr = [...new Array(4)];<br>&gt; arr.map((elem, index) =&gt; index);<br>[0, 1, 2, 3]</pre><h3>2. Passing an empty parameter to a method</h3><p>If you want to call a method and ignore one of its parameters, then JavaScript will complain if you keep it empty.</p><pre>&gt; method(&#39;parameter1&#39;, , &#39;parameter3&#39;);<br>Uncaught SyntaxError: Unexpected token ,</pre><p>A workaround that people usually resort to is passing either null or undefined.</p><pre>&gt; method(&#39;parameter1&#39;, null, &#39;parameter3&#39;) // or<br>&gt; method(&#39;parameter1&#39;, undefined, &#39;parameter3&#39;);</pre><p>I personally don’t like using null since JavaScript treats it as an object and that’s just weird. With the introduction of spread operators in ES6, there is a neater way of passing empty parameters to a method. As previously mentioned, arrays are sparse in nature and so passing empty values to it is totally okay.</p><pre>&gt; method(...[&#39;parameter1&#39;, /* parameter2 */, &#39;parameter3&#39;]);</pre><h3>3. Unique array values</h3><p>I always wonder why the Array constructor doesn’t have a designated method to facilitate the use of unique array values. Spread operators are here for the rescue. Use spread operators with the Set constructor to generate unique array values.</p><pre>&gt; const arr = [...new Set([1, 2, 3, 3])]<br>[1, 2, 3]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZrJKJqBsksWd-8uKM9OvgA.png" /></figure><p>There you have it: <em>Three JavaScript hacks that every developer should keep in their toolbox.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b360a5d01ab1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dailyjs/3-javascript-array-hacks-b360a5d01ab1">Three JavaScript Array Hacks</a> was originally published in <a href="https://medium.com/dailyjs">DailyJS</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[4 Quick Tips to Efficient CSS]]></title>
            <link>https://medium.com/@hassanhelfi/4-quick-tips-to-efficient-css-a319c609825?source=rss-aa091aee2b10------2</link>
            <guid isPermaLink="false">https://medium.com/p/a319c609825</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Hassan Ali]]></dc:creator>
            <pubDate>Mon, 02 Jan 2017 03:24:23 GMT</pubDate>
            <atom:updated>2017-03-15T04:04:55.825Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NDAAM31wD-s1c2Ct-VxB8Q.png" /></figure><p>CSS is a messy “language” and its goal is to style the intended elements without introducing side effects to the rest of the code base. If you don’t pay attention to your rules, you will quickly find yourself in a state of clutter, where confusion reigns over and your CSS accidentally matches unwanted elements. This post serves to introduce you to standard guidelines to keep in mind when writing CSS. For the rest of this post, I will refer to the last selector in a rule as the <strong>key selector</strong>. li, for instance, would be the key selector for the rule div ul li.</p><h3><strong>1. Minimize the number of selectors</strong></h3><p>Avoid having rules with many selectors. This is the most expensive operation in CSS, especially if the rule contains a universal rule (explained later). Use a class name or an ID to minimize descendant selectors. The more selectors a rule has, the longer it would take to resolve it.</p><p>&lt;div&gt;&lt;h1 class=”greetings”&gt; … &lt;/h1&gt;&lt;/div&gt;</p><p>Bad: div h1 { … }</p><p>Good: .greetings { … } or h1.greetings { … }</p><h3><strong>2. Avoid Universal Rules</strong></h3><p>Universal rules are when key selectors have the form * or [attribute=“value”]. We definitely do not want to use universal rules, pretty much ever. CSS is evaluated right-to-left, so this will select every element in the page before proceeding to the next selector in the rule.</p><h3><strong>3. If a rule has an ID selector as its key selector, don’t add the tag name to the rule</strong></h3><p>The mechanism matches rules starting with the key selector, then moves left up until the first selector or a mismatch. Taking into consideration that an ID is unique, then there is no reason to let the system do more work than grabbing the element with that ID.</p><p>Bad: div#contact { … }</p><p>Good: #contact { … }</p><p>As a side note, you should strive to minimize the use of ID’s as much as possible and depend on classes to style your elements. Putting ID’s on important anchors like header, content and contact for example is okay. However, keep rules with ID’s to a single selector or else you’ll have to pay more attention to specificity since they have a higher priority.</p><h3><strong>4. Depend on inheritance</strong></h3><p>Inheritance is when HTML elements inherit properties from their containing elements (parents). Not all CSS properties are inherited. The inherited ones can be found <a href="https://www.w3.org/TR/CSS21/propidx.html">here</a>. You may have been using inheritance without knowing it. For example, the CSS property padding is inherited. If you put some padding on a parent element, then its descendants (children) will receive this property. Know your inheritance list and you will end up with fewer rules.</p><p>If you have more tips to share, comment below :) Otherwise, feel free to reach out to me on Twitter <a href="https://twitter.com/hassanhelfi">@hassanhelfi</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a319c609825" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How a One Liner Doubled My JavaScript Performance]]></title>
            <link>https://medium.com/@hassanhelfi/how-a-one-liner-doubled-my-javascript-performance-eb2599a2b89c?source=rss-aa091aee2b10------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb2599a2b89c</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Hassan Ali]]></dc:creator>
            <pubDate>Sun, 30 Oct 2016 18:31:55 GMT</pubDate>
            <atom:updated>2017-04-14T14:46:01.533Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*00F5aOPtoNfGZGL-HXatnw.jpeg" /></figure><p>While I was working on the <a href="https://github.com/taskcluster/unified-logviewer">Unified Log Viewer</a>, a project initiated by <a href="http://eliperelman.com/">Eli Perelman</a>, I came to realize how a single threaded environment can easily be impacted. For the sake of understanding, an example that explains the meat of the problem without necessarily diving into the specifics of the code will be used.</p><pre>const update = (response) =&gt; {<br>  if (!response) {<br>   return;<br>  }<br>  ...<br>};</pre><pre>xhr.responseType = &#39;arraybuffer&#39;;<br>xhr.overrideMimeType(&#39;text/plain; charset=utf-8&#39;);<br>xhr.addEventListener(&#39;progress&#39;, () =&gt; update(xhr.response));<br>xhr.addEventListener(&#39;load&#39;, () =&gt; update(xhr.response));</pre><p>To explain what’s happening in the code above, we have a buffer that fires the progress event whenever new data comes and later triggers the `load` event when all data have been transmitted. For both events handlers, there is a call to an anonymous function stored in update. The update function makes a quick check on response before proceeding with the execution. If response is empty, it returns.</p><p>Note that progress gives a value of `undefined` as a parameter to update, since xhr.response is null when dealing with array buffers [1]. onload gives a response with a value i.e., not undefined. This code was generating performance issues. This problem can happen when many events are being triggered and a bunch of function calls are being made as a result of those events.</p><p>JavaScript has a concurrency model based on “event loop”. This can be represented by the following:</p><ul><li>Stack (Functions)</li><li>Queue (Events)</li><li>Heap (Objects are allocated in a heap)</li></ul><p>Let me grab your attention on the Stack and Queue. You can ignore the heap for now. A queue adds a message any time an event occurs and there is an event listener attached to it. To continue, whenever there is a function call, a layer gets added to the stack.</p><blockquote><strong>A message from the queue cannot be processed unless the stack is empty</strong></blockquote><p>This means if you have a script that takes a while to execute for example, any events that happen won’t run until the script is done. Since progress was being called many times, it was initiating a call to update, adding many layers to the stack, thus causing performance issues.</p><h4>Solution</h4><p>The solution is quite simple. When you want your events to be processed fast, make sure your function stack stays as clean as possible otherwise they will have to wait until all functions on the stack are fully executed.</p><pre>const update = (response) =&gt; {<br>  ... // No need to check if the response is empty anymore<br>};</pre><pre>xhr.responseType = &#39;arraybuffer&#39;;<br>xhr.overrideMimeType(&#39;text/plain; charset=utf-8&#39;);<br>xhr.addEventListener(&#39;progress&#39;, () =&gt; {<br>  if (xhr.response) {<br>   update(xhr.response);<br>  } <br>}<br>xhr.addEventListener(&#39;load&#39;, () =&gt; update(xhr.response));</pre><h4>Conclusion</h4><p>When performance depends heavily on how quick your events are being processed, it is important not to cluster the stack model. Remember that event messages are not processed unless the stack model is empty. As a result, I saw huge performance improvements (~ 2 times).</p><h4>Resources</h4><p>[1]<a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/response](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/response"> https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/response</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb2599a2b89c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interning at Mozilla]]></title>
            <link>https://medium.com/@hassanhelfi/interning-at-mozilla-a95abb627bdc?source=rss-aa091aee2b10------2</link>
            <guid isPermaLink="false">https://medium.com/p/a95abb627bdc</guid>
            <category><![CDATA[mozilla]]></category>
            <category><![CDATA[internships]]></category>
            <category><![CDATA[silicon-valley]]></category>
            <dc:creator><![CDATA[Hassan Ali]]></dc:creator>
            <pubDate>Thu, 04 Aug 2016 00:00:25 GMT</pubDate>
            <atom:updated>2016-08-04T00:03:27.761Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M1yqPl0mP6vZh1V03mIY-A.png" /></figure><p>I am on my last week of internship at Mozilla. I started on May 23 and ending on August 12. This summer has been by far my favorite of all time. Interning at Mozilla exposes you to some of the brightest people in the world.</p><p>I applied to Mozilla through their website. I was sent an online coding challenge invitation; completed it then did 3 Skype interviews, 2 of which were live coding before getting an official offer. The whole process took around a month.</p><p>I arrived in San Francisco on May 21st, 2 days before my first day at work. Upon arrival, I was warmly welcomed by a driver with my name on the car’s dashboard. I still haven’t started work and Mozilla was already making me feel special.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uMffG0apAfRpcsH9a64f-g.jpeg" /><figcaption>They know how to take care of you</figcaption></figure><p>My first day was in Mountain View, where all interns were introduced on AirMozilla (Check it out <a href="https://air.mozilla.org/mozilla-weekly-project-meeting-20160523/">here</a>! I am introduced at 19:05). In case you’re wondering, I was introduced remotely because my mentor lives in Iowa and my manager works from Portland.</p><p>I have a separate blog where I talk about the things I develop. If you’re curious to know what kind of work I did for Mozilla, check out this <a href="https://helfi92.github.io/push-inspector/">post</a>.</p><p>Approximately 2 weeks later, we were flown to London for the Mozilla All Hands. An All Hands is a meeting where all Mozilla Employees get together under one roof, and work on their projects and plan for the future. Since 2015, Mozilla has been having 2 gatherings per year. The All Hands were really great because this was the only time I had a chance to meet my mentor and manager face to face. I took the opportunity to set up meetings with them to discuss my work thoroughly. The University team organized a couple of activities with all the interns and it was really nice getting to know them. Snapchat even had a custom Mozilla filter during that week.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*2NvNx1NEjkLosXSM_LgPQA.jpeg" /><figcaption>Fellow interns of Summer 2016</figcaption></figure><p>By working for Mozilla, you get to meet insanely smart people with big achievements and I am really grateful for that. I always wanted to surround myself with people that have big goals because they indirectly make me aim higher in life.</p><p>Mozilla is very generous when it comes to perks. Interns are housed, fed and flown with no personal cost. Working for Mozilla means you can come to work and leave whenever you want as long as the work is being done. They provide lunch everyday at work and unlimited snacks. Lunch is different everyday so you never get tired of it.</p><p>Mozilla has 12 offices located worldwide, 2 of which are in California. I was located in the San Francisco office. It’s really pretty and has one of the best roof views in the world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SUi6PYs2Q6RUeOBFugnkoA.jpeg" /><figcaption>Mozilla roof in San Francisco</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RithvgWNtVErII1X5EBBoQ.png" /><figcaption>Shot taken at roughly 7 AM from the Mozilla office roof</figcaption></figure><p>Just last week I gave a presentation to talk about the internship and I would invite you to watch to it.</p><p><a href="https://air.mozilla.org/breaking-builds/">Breaking Builds</a></p><p>If you have any questions about Mozilla or about the internship, feel free to contact me. I’d love to answer any questions you may have.</p><p>Until next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a95abb627bdc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>