<?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 Ning Xia on Medium]]></title>
        <description><![CDATA[Stories by Ning Xia on Medium]]></description>
        <link>https://medium.com/@ningxia?source=rss-fcd81a9d6e81------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oUldBBovnARPdUwy.jpg</url>
            <title>Stories by Ning Xia on Medium</title>
            <link>https://medium.com/@ningxia?source=rss-fcd81a9d6e81------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 00:43:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ningxia/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[Capturing click with CSS]]></title>
            <link>https://medium.com/@ningxia/capturing-click-with-css-dbaeb04d23f9?source=rss-fcd81a9d6e81------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbaeb04d23f9</guid>
            <category><![CDATA[onclick]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[click]]></category>
            <dc:creator><![CDATA[Ning Xia]]></dc:creator>
            <pubDate>Sat, 09 Apr 2016 17:10:53 GMT</pubDate>
            <atom:updated>2017-11-09T00:06:27.568Z</atom:updated>
            <content:encoded><![CDATA[<p>CSS does not currently provide a click pseudo-class like it does for :hover or :focus.</p><p>Restyling an element on click is a very common use case, however, and we would like to cleanly do so without resorting to javascript when it’s not needed.</p><p>The simplest way to capture a click event with pure CSS is with a hidden checkbox for which we expose the label.</p><pre>&lt;input type=”checkbox” id=”click-control”/&gt;<br>&lt;label for=”click-control” /&gt;</pre><pre>&lt;div class=”picture”/&gt;</pre><p>The above code takes advantage of how a click on the label registers as a click on its associated checkbox.</p><pre>#click-control {<br> display: none;<br>}</pre><pre>#click-control:checked ~ .picture {</pre><pre> /* change styles, animate, etc */</pre><pre>}</pre><p>The rest is taken care of by the :checked pseudo-class and some basic combinator selection.</p><p>See this in action in a very short and straightforward fiddle here: <a href="https://jsfiddle.net/1hdr73u8/4/">https://jsfiddle.net/1hdr73u8/4/</a></p><p>Stay tuned for more on CSS combinators and how much you can do with them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbaeb04d23f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript Promises, under the hood]]></title>
            <link>https://medium.com/@ningxia/javascript-promises-under-the-hood-4ce853fcb2c9?source=rss-fcd81a9d6e81------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ce853fcb2c9</guid>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[promises]]></category>
            <dc:creator><![CDATA[Ning Xia]]></dc:creator>
            <pubDate>Fri, 01 Apr 2016 02:53:06 GMT</pubDate>
            <atom:updated>2021-09-10T14:09:24.766Z</atom:updated>
            <content:encoded><![CDATA[<p>When discussing Promises, one of the first things you are likely to hear is that they are an alternative to cascading fallback functions aka callback hell aka the triangle of doom when handling asynchronous computation. Popular Javascript Promise libraries include <a href="http://bluebirdjs.com/docs/getting-started.html">bluebird</a> and <a href="https://github.com/kriskowal/q">Q</a>, and it is pretty fair to say that we have all used or are still using Promises in our Node applications, which is how I became increasingly curious with just how a Promise worked underneath, leading me to write my own Promise library.</p><h4>How does a Promise actually work?</h4><p>The anatomy of a Promise is elegantly simple. It represents the guaranteed future of an eventual value. Unlike Observables, you cannot cancel a Promise before it has given you some sort of value back, be that by resolution or rejection.</p><p>At minimum, a Promise is an object with a then method, which accepts a callback function to operate on the returned eventual value. The Promise is instantiated with the passage of a function that it invokes during its construction, through which it encloses internal resolve and reject functions. The resolve and reject functions are two sides of the same coin, each signaling that the eventual value of the asynchronous behavior has completed. Generally, we resolve expected outputs, and reject errors, both of the handled and unexpected variety. Note that a Promise can handle synchronous computation as well, though it’s just less exciting.</p><pre>function Promise(func) {<br>  var state = ‘pending’; <br>  var deferred = null; <br>  var value;</pre><pre>  function resolve(){...}</pre><pre>  function reject(){...}</pre><pre>  function handle(){...}<br>  <br>  this.then = function(){...}</pre><pre>  func(resolve, reject);<br>} </pre><p>The Promise works by something of a race between resolve/reject and then. It tracks its own state of progress in closure, knowing whether it is pending, resolved, or rejected. Depending on whether resolve/reject or then is called first, the Promise behaves accordingly.</p><pre>function resolve(newValue) {<br>  try { <br>  state = ‘resolved’; value = newValue;<br>  if (deferred) { <br>    handle(deferred); <br>  }<br>}</pre><pre>function reject(reason) { <br>  state = ‘rejected’; <br>  value = reason;<br>  if (deferred) { <br>    handle(deferred); <br>  } <br>}</pre><p>If resolve/reject is called first, then great — this means that asynchronous computation has completed and handed a value back. The Promise stores that value in closure so that when then is called later, it can go right ahead and invoke the callback function passed to then on the value.</p><p>If then is called before resolve/reject, then the value handler passed to then is deferred. Once resolve/reject is eventually called, meaning we have the value we were waiting for, that deferred handler from earlier is used.</p><p>The management of these relationships is performed by a handle function, while try and catch blocks help with rejecting unexpected errors. The setTimeout here gives the Promise itself asynchronous flow, as expected in the Promises/A+ spec.</p><pre>function handle(handler) {     <br>  if (state === &#39;pending&#39;) {<br>    deferred = handler;<br>    return;        <br>  }</pre><pre>  setTimeout(function(){            <br>    var handlerCb;</pre><pre>    if (state === &#39;resolved&#39;) {<br>      handlerCb = handler.onResolved;<br>    } else if (state === &#39;rejected&#39;) {                <br>      handlerCb = handler.onRejected;<br>    } <br>            <br>    if (handlerCb) {                <br>      var returnValueOrReason;                <br>      try {                       <br>        returnValueOrReason = handlerCb(value);                <br>      } catch (err) {                    <br>        handler.reject(err);                    <br>        return;                <br>      }                 </pre><pre>    if (state === &#39;resolved&#39;) {<br>        handler.resolve(returnValueOrReason);                <br>      } else if (state === &#39;rejected&#39;) {<br>        handler.reject(returnValueOrReason);<br>      }            <br>    } <br>  <br>  }, 1);    <br>}</pre><p>Note how handle, which will be called when .then() is called, checks the state of the Promise to decide what to do next. The handlerCb variable simply stores the value handling callback functions given to passed to .then() so it can know how to behave when our eventual value is available. Promise chaining works by having each Promise’s then method return another Promise instance.</p><pre>this.then = function(onResolved, onRejected) {<br>  return new Promise(function(resolve, reject){<br>    handle({<br>      onResolved: onResolved,<br>      onRejected: onRejected,<br>      reject: reject,<br>      resolve: resolve<br>    });<br>  });<br>}</pre><p>Feel free to view the library I built to explore these concepts on my <a href="https://github.com/ning-github/squab">GitHub</a> or you can install and play around with a good ol’ npm install:</p><pre> npm install squab</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ce853fcb2c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Move]]></title>
            <link>https://medium.com/@ningxia/the-move-9f77db4f3cde?source=rss-fcd81a9d6e81------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f77db4f3cde</guid>
            <dc:creator><![CDATA[Ning Xia]]></dc:creator>
            <pubDate>Wed, 23 Mar 2016 07:47:47 GMT</pubDate>
            <atom:updated>2018-02-13T19:07:11.295Z</atom:updated>
            <content:encoded><![CDATA[<p>This post officially marks the transition of my technical blog from ghost, with which I set up hosting on DO, to here on Medium.</p><p>While I am sure I will miss the almost limitless customization I had previously, I am very excited to post my content on a platform that caters so strongly to sharing, a smooth writing experience, and readership.</p><p>Those are all great, but there is a larger decider in my choice to move where I record my thoughts, reflections, and insights on software and web development to Medium. It is the ability to read and produce content in the same place. Medium is where I consume a lot of my tech content on a daily basis, whether it is someone’s writeup of their experience using a new architecture, or a company sharing their proof of concept for a certain design decision. That blogs and their readers can write in response and reference to each other provides the sense that ideas on Medium are part of a conversation, and I am looking forward to joining in.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f77db4f3cde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From the Archives: React: Tracing through Flux]]></title>
            <link>https://medium.com/@ningxia/from-the-archives-react-tracing-through-flux-966e20ee8940?source=rss-fcd81a9d6e81------2</link>
            <guid isPermaLink="false">https://medium.com/p/966e20ee8940</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[flux]]></category>
            <dc:creator><![CDATA[Ning Xia]]></dc:creator>
            <pubDate>Wed, 23 Mar 2016 07:45:51 GMT</pubDate>
            <atom:updated>2016-03-23T07:45:51.917Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>React: Tracing through Flux</strong></blockquote><blockquote>Archived from my previous blog. Originally published: August 11, 2015.</blockquote><p>Recall that previously we examined the Flux unidirectional data-flow. We’ll now walk through each piece of the architecture as it can occur in an application. The example used here is based on <a href="http://www.picarus.co/main#/">Picarus</a>, a photo-sharing application.</p><p><strong>ACTION</strong>: <br>- User interaction with the View or API call/response.</p><p>From the Photo view component, in which each photo has comments, clicking on a photo is supposed to load its comments:</p><pre>onSubmit : function(){<br>  AppActions.loadComments(photoId)<br>}</pre><p><strong>Think of it as:</strong> Action can occur from View</p><p><strong>DISPATCHER</strong>:<br>- Broadcasts a kicked-off action to all stores. <br>- All stores include the dispatcher (more on that later).<br>- Think of the dispatcher as casting out hooks.</p><p>From the Actions module:</p><pre>loadComments: function(photoId){<br>  axios.get(‘/api/requests/’+id) // axios is an HTTP client<br>   .then(function(response) { <br>     // server query of database returns comments<br>     AppDispatcher.dispatch({<br>       type: AppConstants.RECEIVE_COMMENTS, <br>       // AppConstants are just the specific names for each type of action the app passes around<br>       data: data // payload (two things)<br>     });<br>   });<br>}</pre><p>*the above code can be refactored to use a utility function to retrieve the photo’s comments from the database. I have consolidated everything for the sake of showing how action methods use the dispatcher to transmit data</p><p><strong>Think of it as:</strong> Dispatch happens within an Action method</p><p><strong>STORE: </strong><br>- Holds the model (source of truth) that your view’s states use to render. This model can look something like:</p><pre>var _comments = {};</pre><p>Recall that the Dispatcher throws out hooks. Stores can choose to latch onto certain hooks by catching them, such as with switch statements. In this way, when the RECEIVE_COMMENTS hook vibrates, the Stores latching on, like CommentStore below, will feel it, update, and trigger an event.</p><p>From the CommentStore module:</p><pre>CommentStore.dispatchToken = AppDispatcher.register(function(action) {<br>  switch(action.type) {<br>    case AppConstants.RECEIVE_COMMENTS:<br>      _receiveComments(action.data);<br>      RequestStore.emitChange(); <br>      break;<br>  default:<br>  }<br>}</pre><p>I will be going into further detail on stores and views in a future blog post so don’t worry too much about the methods above. Just know that upon RECEIVE_COMMENTS action type dispatch, CommentStore will update its source of truth with the Action’s payload and emit an event signaling this.</p><p><strong>Think of it as:</strong> Actions update Stores by Dispatching with certain action types to which Stores can register themselves.</p><p><strong>VIEWS: </strong><br>- The React component itself. The component’s state is what controls its re-rendering as it diffs the virtual DOM with new information.</p><p>The component’s state is updated whenever the store emits the event tied to it. How does it do this? By attaching eventListeners from the Store.</p><p>From the Photo view component:</p><pre>// attach listener<br>componentDidMount: function(){<br>  RequestStore.addChangeListener(this._onChange);<br>}</pre><pre>// update state with Store method that gets Store’s model<br>_onChange: function () {<br>  this.setState({photoComments: CommentStore.getComment(photoId)});<br>}</pre><p>The component passes the state setter as a callback to be executed whenever CommentStore emits its corresponding event. So when data in the source of truth changes, this change is reflected in the View’s state, and from there the component re-renders itself.</p><p><strong>In summary, follow this flow:</strong><br>View/API can kick off Action. <br>Action is dispatched with payload. <br>Stores register to Action types, and update and emit. <br>On Store change, View states also update and can re-render.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=966e20ee8940" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From the Archives: Using PostgreSQL Triggers in JavaScript with Bookshelf.js]]></title>
            <link>https://medium.com/@ningxia/from-the-archives-using-postgresql-triggers-in-javascript-with-bookshelf-js-3dae75fdc8c8?source=rss-fcd81a9d6e81------2</link>
            <guid isPermaLink="false">https://medium.com/p/3dae75fdc8c8</guid>
            <category><![CDATA[bookshelf]]></category>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Ning Xia]]></dc:creator>
            <pubDate>Wed, 23 Mar 2016 07:31:22 GMT</pubDate>
            <atom:updated>2018-07-18T23:31:17.435Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Using PostgreSQL Triggers in JavaScript with Bookshelf.js</strong></blockquote><blockquote>Archived from my previous blog. Originally published: August 18, 2015.</blockquote><p>A PostgreSQL trigger can be used to perform automatic cross-table queries.</p><p>For example, given a photo-sharing application, say we have a photos table that has a user_id column indicating which user uploaded which photo and a likes column storing how many users have liked that single photo.</p><p>We also have a users table, which has a karma column that stores the total number of likes across all of photos uploaded by that user.</p><p>If we want a particular user’s karma to increment or decrement whenever one of his or her photos has been liked or unliked, we can create a trigger to do so. This trigger has two main components:</p><p>1. A trigger function. This is the “something” that happens when the triggering query occurs. It can be another query. The trigger itself to do something when a particular event query happens on a table</p><p>2. The trigger itself that is attached to a particular query on a table</p><p>To implement triggers in JavaScript, which the Bookshelf ORM does not support, we need to write them raw and integrate using Knex.</p><pre>var trigFunc = “CREATE FUNCTION incOrDec() RETURNS trigger AS $$ \nBEGIN \n UPDATE users SET karma = karma+NEW.likes-OLD.likes WHERE id = NEW.user_id; \nRETURN NULL; \n END; \n $$ LANGUAGE plpgsql;”;</pre><pre>db.knex.raw(trigFunc).then(function(response){<br>  console.log(‘defined incOrDec function’);</pre><pre>  // the trigger itself will be created here<br>}</pre><p>Above, the trigger function incOrDec is defined by the proper raw PostgreSQL syntax, then passed as a string to Knex’s .raw.</p><p>Once we have successfully defined the trigger function, we then define the trigger that will use it.</p><pre>// create trigger itself after creating its trigger function<br>var trigger = “CREATE TRIGGER bumpOrDropKarma AFTER UPDATE OF likes ON photos FOR EACH ROW EXECUTE PROCEDURE incOrDec();”;</pre><pre>db.knex.raw(trigger)<br>  .then(function(response){<br>    console.log(‘defined bumpOrDropKarma trigger’);<br>  });</pre><p>You can see the full trigger code, which is used in production for <a href="http://www.picarus.co/main#/">Picarus</a>, at <a href="https://github.com/SucculentWall/Picarus">https://github.com/SucculentWall/Picarus</a></p><p>For more cool information about PostgreSQL triggers, you can start here in the <a href="http://www.postgresql.org/docs/8.4/static/plpgsql-trigger.html">documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3dae75fdc8c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From the Archives: Flux: A Bird’s Eye View]]></title>
            <link>https://medium.com/@ningxia/from-the-archives-flux-a-bird-s-eye-view-18d5bd12d505?source=rss-fcd81a9d6e81------2</link>
            <guid isPermaLink="false">https://medium.com/p/18d5bd12d505</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[flux]]></category>
            <dc:creator><![CDATA[Ning Xia]]></dc:creator>
            <pubDate>Wed, 23 Mar 2016 07:22:43 GMT</pubDate>
            <atom:updated>2016-03-23T07:24:01.260Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Flux: A Bird’s Eye View</strong></blockquote><blockquote>Archived from my previous blog. Originally published: July 20, 2015.</blockquote><p>React, Facebook’s javascript view library, is one of the most popular new technologies on the internet right now. Since React is only the V in MVC, Flux fills out the actual handling and passing of data.</p><p>Flux is not a framework but rather an architecture, or structural guideline, that allows you to organize your React code to achieve separation of concerns between different stages of logic. It operates on a <strong>unidirectional data flow</strong> through 4 parts: Actions, Dispatcher, Stores, and Views.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IhdY0wsFj8mxsxGX.png" /><figcaption>image from facebook.github.io</figcaption></figure><p><strong>Actions</strong></p><ul><li>Creators may retrieve or update API data that is packaged into an object to be dispatched.</li></ul><p><strong>Dispatcher</strong></p><ul><li>sends knowledge of an action being fired to the store(s)</li></ul><p><strong>Stores</strong></p><ul><li>the source of truth that views draw from when displaying to a user</li></ul><p><strong>Views</strong></p><ul><li>the actual React components</li></ul><p>As stated, this post is meant to offer a very high level look at how Flux works. Stay tuned for more to come on using React with the Flux architecture.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18d5bd12d505" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From the Archives: Remapping your Caps Lock Key]]></title>
            <link>https://medium.com/@ningxia/from-the-archives-remapping-your-caps-lock-key-3d789c7b6d01?source=rss-fcd81a9d6e81------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d789c7b6d01</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[keyboard]]></category>
            <category><![CDATA[caps-lock]]></category>
            <dc:creator><![CDATA[Ning Xia]]></dc:creator>
            <pubDate>Wed, 23 Mar 2016 07:19:15 GMT</pubDate>
            <atom:updated>2016-03-23T07:19:15.725Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Remapping your Caps Lock Key</strong></blockquote><blockquote>Archived from my previous blog. Originally published: May 18, 2015.</blockquote><p><strong>The productivity tip of the century:</strong><br>The caps lock key is one of the largest keys on the modern keyboard, in addition to being positioned on the home row. This makes it highly accessible.</p><p>Its default function is also the most useless of any key.</p><p>This is a vestigial feature from the typewriter, which used the caps lock key to mechanically lock the device into an all uppercase state, which could only be unlocked by pressing shift.</p><p>Today, practically the only time you press caps lock is by accident. The irony is that with a typewriter, the typist was made physically aware that caps lock was on, minimizing error. Nowadays, caps lock is turned on by error so frequently that there is boilerplate password rejection text addressing it.</p><p><strong>Bottom Line:</strong> <em>Remap</em> your caps lock key to something useful.</p><p>I personally recommend mapping it to control (^) which is popularly used in applications but also a bit difficult to reach on the standard MacBook.</p><p>Remap by going to System Preferences &gt; Keyboard &gt; Modifier Keys</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EuDO-YHy87fSfnv_u1_z0A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d789c7b6d01" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From the Archives: Customize Window Management Keyboard Shortcuts with Slate]]></title>
            <link>https://medium.com/@ningxia/from-the-archives-customize-window-management-keyboard-shortcuts-with-slate-be5b14b57b7a?source=rss-fcd81a9d6e81------2</link>
            <guid isPermaLink="false">https://medium.com/p/be5b14b57b7a</guid>
            <dc:creator><![CDATA[Ning Xia]]></dc:creator>
            <pubDate>Wed, 23 Mar 2016 07:10:09 GMT</pubDate>
            <atom:updated>2016-03-23T07:10:35.964Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Customize Window Management Keyboard Shortcuts with Slate</strong></blockquote><blockquote>Archived from my previous blog. Originally published: July 19, 2015</blockquote><p>Slate is a free window management application available here: <a href="https://github.com/jigish/slate">https://github.com/jigish/slate</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ccn3lG6OdCT40ryX-3I4cA.png" /></figure><p>Think of that time at Starbuck’s when you saw a Windows user evenly snap his Google Chrome window to fit half of the screen and his text editor to fit the other half of the screen. Then you sat down on your Mac and had to click and drag with careful attention to achieve what someone else did with one keys and zero effort.</p><p>Though the project itself has not seen any further features or developments in a while, it is still one of the top productivity tools available for OS X.</p><p>So how does Slate work? Easy.</p><p>1. Get started right away with :</p><pre>cd /Applications &amp;&amp; curl <a href="http://www.ninjamonkeysoftware.com/slate/versions/slate-latest.tar.gz">http://www.ninjamonkeysoftware.com/slate/versions/slate-latest.tar.gz</a> | tar -xz</pre><p>You may need to allow slate access in System Preferences &gt; Security and Privacy &gt; Accessibility</p><p>2. Create a .slate file in your computer’s home directory</p><p>3. In your slate configuration file, simply register a particular on-screen action to a corresponding key press combination on your keyboard. This is called binding.</p><p>For example, to push a window to the exact right half of your screen with ctrl + right arrow:</p><pre>bind right:ctrl push right bar-resize:screenSizeX/2</pre><p>And that’s pretty much all it takes to get started! Fill your .slate file with your own custom configurations for a more comfortable and effective workflow.</p><p>Here is an example of my own slate configuration: <a href="https://github.com/ning-github/dev-env/blob/master/.slate">https://github.com/ning-github/dev-env/blob/master/.slate</a></p><p>You can also check out further customization possibilities using slate’s javascript config here: <a href="https://github.com/jigish/slate/wiki/JavaScript-Configs">https://github.com/jigish/slate/wiki/JavaScript-Configs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be5b14b57b7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From the Archives: Closure]]></title>
            <link>https://medium.com/@ningxia/from-the-archives-closure-b88217eb2b1?source=rss-fcd81a9d6e81------2</link>
            <guid isPermaLink="false">https://medium.com/p/b88217eb2b1</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[closure]]></category>
            <dc:creator><![CDATA[Ning Xia]]></dc:creator>
            <pubDate>Wed, 23 Mar 2016 06:57:14 GMT</pubDate>
            <atom:updated>2016-03-23T06:57:14.599Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Closure</strong></blockquote><blockquote>Archived from my previous blog. Originally published: June 10, 2014.</blockquote><p>To best understand the definition and purpose of a closure, consider the following example.</p><pre>var pet = function(){<br>  var name = ‘spot’;<br>  return true;<br>}</pre><p>Recall that when a function completes its execution, its inner work is garbage-collected from memory so that the interpreter can proceed to the next line of execution with a clean slate. So if:</p><pre>var dog = pet();</pre><p>then following this invocation, the name variable and its value are discarded.<br> <br><em>But what if we still want to use </em>name<em>?</em></p><p>A closure is when a function <strong>retains access</strong> to its enclosing function’s scope even after that enclosing function has finished running.</p><pre>var pet = function(){<br>  var name = ‘spot’;</pre><pre>  var sayPetName = function(){<br>    console.log(name);<br>  }</pre><pre>  return sayPetName;<br>}</pre><pre>var myPetsName = pet();</pre><p>Although pet, the wrapper, has already finished running, if we call myPetsName</p><pre>myPetsName();  // logs “spot”</pre><p>we see that the enclosed function sayPetName that was returned by the wrapper still holds access to name, despite the wrapper function completing execution long ago.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b88217eb2b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From the Archives: Linked Lists and Non-contiguous Memory]]></title>
            <link>https://medium.com/@ningxia/linked-list-insertion-and-removal-operations-are-both-achieved-in-o-1-time-392d856d2c3e?source=rss-fcd81a9d6e81------2</link>
            <guid isPermaLink="false">https://medium.com/p/392d856d2c3e</guid>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[linked-lists]]></category>
            <category><![CDATA[contiguous-memory]]></category>
            <dc:creator><![CDATA[Ning Xia]]></dc:creator>
            <pubDate>Wed, 23 Mar 2016 06:44:13 GMT</pubDate>
            <atom:updated>2016-03-23T06:46:57.163Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Linked Lists and Non-contiguous Memory</strong></blockquote><blockquote>Archived from my previous blog. Originally published: June 7, 2014</blockquote><p>Linked list insertion and removal operations are both achieved in O(1) time.</p><p>Each node in a linked list holds a value and a pointer to the next node’s location in memory. It is a piece of data that tells you where to find the next piece of data in the list.</p><p>This is an important difference from arrays, which manages data held contiguously in memory.</p><p>How an array organizes data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X-wMQUhImaw34m-hhXC-tg.png" /></figure><p>How a linked list organizes data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6orgkGdnhmhNg5edVWS14g.png" /></figure><p>Tying back to our mention of time complexity, linked lists are therefore much more fluid and flexible than arrays because when you add or remove a node from the list, you just need to add or remove a pointer.</p><p>On the other hand, with an array, after insertion or removal, you have to resize that block in the memory itself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=392d856d2c3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>