<?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 David Sanwald on Medium]]></title>
        <description><![CDATA[Stories by David Sanwald on Medium]]></description>
        <link>https://medium.com/@davidsanwald?source=rss-53448f96d094------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rcHV2du6L-NN4TbVL1RPPQ.jpeg</url>
            <title>Stories by David Sanwald on Medium</title>
            <link>https://medium.com/@davidsanwald?source=rss-53448f96d094------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 15:25:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@davidsanwald/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[Touch Typing- The Most Important Skill For Developers Nobody Talks About]]></title>
            <link>https://medium.com/@davidsanwald/touch-typing-the-most-important-skill-for-developers-nobody-talks-about-95b6c93f914a?source=rss-53448f96d094------2</link>
            <guid isPermaLink="false">https://medium.com/p/95b6c93f914a</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[career-advice]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[developer-tools]]></category>
            <dc:creator><![CDATA[David Sanwald]]></dc:creator>
            <pubDate>Fri, 03 Jul 2020 13:21:12 GMT</pubDate>
            <atom:updated>2020-07-03T13:21:12.859Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YLOgyHxRHisHlGI656ogKg.jpeg" /></figure><p>As a developer, the code I commit during a typical workday varies greatly, but about 8000 characters of code might be an okay estimate. Before I learned how to touch-type, my typing speed was about 30 WPM. That means I could type all of that in about 50 minutes. My current typing-speed is about 70 WPM, so I would only save 30 minutes per day.</p><p>As a developer, I’m not limited by the typing speed and thinking about code, reading code, looking for the right place to change that single line of code to fix a bug matter way more than my raw output of code.</p><p>All in all, it seems like touch-typing is only a minor optimization, so why was touch-typing the single most important skill I picked up as a developer?</p><h3>Why Touch-Typing Matters</h3><p>Many of the things that matter most to me might also be personal and subjective. But I still believe the following things are true not only for myself.</p><p>The flow of thoughts is not consistent. Often we think in bursts. Further, our mind does not emit ideas in a linear self-consistent manner. Often we only can associate and combine ideas that did not directly succeed each other. Touch-typing, to me, means less buff between thinking about code and writing code. I’m able to quickly type ideas I had to keep in my head before. Not being able to follow my thought process in the editor forced me to do more steps in my head. Typing made the way I code more iterative. It’s no problem at all writing code that will not be in the final commit. I often worried about writing clean code, which limited me and slowed me down. Now I’m able to write code without worrying about how it looks because immediately refactoring a line of code after typing it is so easy.</p><p>Before knowing how to type, I failed to get into using VIM (or its keybindings) countless times. I tried but never managed to build up muscle memory navigating and editing code the vim-way. Nobody told me that typing skills are almost a hard requirement for benefitting from VIM. After I was able to touch-type (even though I was still very slow), it only took me a week to pick up enough VIM to feel productive. Only a fraction of “writing code” is actually about writing code. It’s easy to overlook how much working with code is about editing and navigating it.</p><p>Often we are focussed on writing actual code, that there are many more things that depend on being typed so that we can contribute them to a product/team/discussion: code reviews slack messages documentation user stories stack overflow postings …</p><p>Here I can only speak for myself: I could type without having to look at the keyboard. It’s hard to explain but always using the same finger for the same keys when touch-typing still feels very different from before. The actual typing requires not nearly as much attention as before, and I can focus almost entirely on the code instead.</p><h3>Why Nobody Talks About Touch-Typing</h3><p>Among developers, there are two main groups. Many developers learned how to touch-type at an early age at school. Therefore they take touch-typing as given and are not aware of how much it impacts their work. The group of developers that did not pick up touch-typing during childhood would need to invest a lot of time and energy, learning how to type before actually experiencing the benefits. Learning how to type takes time. After typing without a system for years, most people are still able to type quite fast. As developers, we depend on our efficiency. Learning how to type means becoming much slower at first, and this can be quite scary. Therefore there are not too many people that learn how to type as adults. For myself picking up touch-typing was more than worth it. Because I benefit so much from this decision every day, I want to share my experience, maybe even encouraging somebody picking it up, it’s never too late.</p><h3>My Touch-Typing Journey</h3><p>Because I built up some muscle-memory by typing without a system for all my life, I struggled to relearn my finger movements. For that reason, I chose the most radical way possible:</p><p>I took all the vacation days I had accumulated and switched my keyboard layout from one day to the other from QWERTY to tCOLEMAK. To be honest, this was hell. Suddenly I couldn’t type at all. Looking at the keyboard was not helpful anymore at all, because the letters on the keycaps did not match their actual letters. I struggled to type even short URLs into the address bar of the browser.</p><h3>COLEMAK for the win</h3><p>To slowly relearn everything, I used the site <a href="https://www.keybr.com/">https://www.keybr.com/</a> by starting with the smallest keyset possible. To keep me from looking at my hands, I printed out a COLEMAK schema and put it on the wall behind my monitor. As I finally progressed to the full keyset on keybr, I switched to <a href="https://www.keyhero.com/">https://www.keyhero.com/</a> for my daily training. After two weeks, I was still slower than before but at least fast enough to start working again without being afraid of not being able to keep up. From there on, I went from 6 hours typing practice a day to only 2 hours after work. After another month, I stopped practicing everyday and only practiced occasionally. It took me about four months until typing felt like something natural to me. Today I’m still not too fast (about 70 WPM), but I think speed is only a minor factor for the positive impact that touch-typing had on my work.</p><h3>Let me hear your thoughts</h3><p>What are your thoughts on this? Do you agree or disagree? Why? I’m interested in all kinds of thoughts, opinions, and experiences. But I’d love to hear from people that picked up touch-typing at a later stage of their life and whether you had similar experiences.</p><p><em>Originally published at </em><a href="https://www.davidsanwald.net/touch-typing-the-most-important-developer-skill/"><em>https://www.davidsanwald.net</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95b6c93f914a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Combine React and D3 the Wrong Way]]></title>
            <link>https://medium.com/@davidsanwald/how-to-combine-react-and-d3-the-wrong-way-e212e0967f77?source=rss-53448f96d094------2</link>
            <guid isPermaLink="false">https://medium.com/p/e212e0967f77</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[d3js]]></category>
            <dc:creator><![CDATA[David Sanwald]]></dc:creator>
            <pubDate>Wed, 26 Sep 2018 16:00:46 GMT</pubDate>
            <atom:updated>2018-09-27T07:18:03.227Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KHtLk68FgF7ui6eruL9Rqg.png" /></figure><h3>How to Prototype D3 Charts Within React the Wrong Way</h3><p>Evolution did a lousy job to prepare the human mind to process today’s data in its raw form.<br>Thanks to our inability to extract information from data in it’s raw form, our understanding depends on mappings into different domains: <br>Charts became an indispensable tool to represent data in a way we can represent data and base our decisions on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mQeZpEvKECc-TnxCoxozTw.gif" /><figcaption>the cake is a lie</figcaption></figure><p>To this day D3 is still the unmatched gold in it’s area of expertise and provides a collection of low-level tools and helpers that allow mapping the properties of data to visual representations. D3 is not just used directly but also the core component of most web-focused charting libraries.</p><h4>D3 and React Fighting Over the DOM</h4><p>Introducing D3 to React to integrate data-driven elements into a UI always starts with the same fundamental question:<br><em>Who controls the DOM?</em><br>React does not detect changes to the DOM. New props or calling setState trigger the computation of an internal representation of the DOM and updates are based on comparing the new DOM representation to the previous tree.<br>Therefore updates to the DOM can only happen by updates flowing downwards via setState and new props.</p><h4>Divide and Rule</h4><p>Consequently, D3’s approach to updating models and keep them in sync with the view cannot coexist with React’s DOM control.</p><p>There are two solutions to this dilemma that allow harnessing D3’s powers inside a React app:</p><p>1. Leaving the DOM to React, using D3 only for calculations of things like scales or paths.<br>2. Blocking React from updating all children downwards D3’s root node.</p><p>To get straight from the point:<br>For more complex projects the first approach is superior and widely considered to be <em>the right way.</em> <br>It is important to know that D3 is not a charting library but a low-level tool belt developed by Mike Bostock while he was working on creating custom visualizations for the New York Times.<br>Even conventions like the “reusable chart convention” are of limited reusability and flexibility because they do not expose the individual elements of the data-join.<br>A React centric approach allows to write more reusable charts that integrate seamlessly into the React way of things.</p><p>There are only a few downsides to this approach:</p><ul><li>Some elements of a chart, for example, D3’s axes are hard to build yourself as inline SVG paths let alone animating them</li><li>Transitions, especially with data-aware interpolations exponentially increase the complexity of a visualization</li></ul><p>Ambitious data-driven animations inside React are entirely possible but realizing those in a performant way dramatically increases the complexity and slows down iterating on a chart.</p><p>For this reason, the ease of use and speed of D3&#39;s data-joins is still unmatched for quickly build a functional prototype.</p><p>Prototypes built that way have to meet two main requirements:</p><ul><li>allowing to change to a different approach at a later point without having to rewrite everything from scratch</li><li>being flexible enough to implement and test multiple prototypes and iterate on them in a short amount of time</li></ul><h3>How to Prototype Inside React With D3’s Data-Joins</h3><p>There are patterns that make it very convenient to come up with a working prototype of a chart while still being able to hand over the DOM to React at a later point without having to start from scratch.</p><h4>Embracing Pragmatism</h4><p>It is essential to understand that the kind of generality that a library requires to be useful for a wide variety of use cases while maintaining a stable API is often orthogonal to the flexibility that allows to quickly change and test different properties and variants of a prototype.</p><ul><li>acceptance of the limited reusability of many parts of the D3 code, a little copy and paste goes a long way</li><li>giving up costly patterns like the reusable chart conventions, which still do not provide access to the individual parts of the data-join</li><li>knowing when to switch over to a React centric approach</li><li>avoiding code smells like speculative generality and never forget: “You ain’t gonna need it”</li></ul><h4>Idempotent data-joins and Single Element Containers</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MG2kYdEuenqNh5gY16Meyw.gif" /><figcaption>update on resize simplified by idempotent updates</figcaption></figure><p>Using D3’s single element pattern eliminates the need for separate logic for initializing the chart or updating.</p><p>Instead of two separate functions with outcomes that vary depending on the current state of the DOM</p><pre>function initChart(){...}</pre><pre>function updateChart(){...}</pre><p>you can use the same logic for initializing and updating the chart:</p><pre>function chart (){...}</pre><p>Creating containers using the single element pattern is very straightforward:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c6b72f88b5585ad446ce4fc893ee82d/href">https://medium.com/media/8c6b72f88b5585ad446ce4fc893ee82d/href</a></iframe><p>Despite the side effects introduced by the D3’s mutations to the DOM, rendering with the same input always results in the same output. This dramatically reduces mental overhead and complexity.</p><h4>Reducing Coupling between Data and View</h4><p>The use of accessor functions instead of directly referring to individual properties of data points reduces coupling between the shape of data and its visual representation.<br>It is still important to be pragmatic, every unneeded level of indirection also comes with its costs. Starting by defining x and y accessors for the creation of SVG paths and introducing more layers when needed is usually a reasonable approach.</p><pre>const x = datum =&gt; datum.date <br>const line = d3.line().x(d =&gt; xScale(x(d)))  .y(d =&gt; yScale(y(d)))</pre><h4>Never Directly Scale Data</h4><p>Never scale the bound data directly. It is often necessary to have access to the actual unscaled values of the bound data and scaled values for path generators should never be mixed:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d4a23ecf2aaf59807a79204580ca694/href">https://medium.com/media/3d4a23ecf2aaf59807a79204580ca694/href</a></iframe><h4>Only Pure Functions to Transform Data</h4><p>Sticking to only pure functions to transform the data reduces mental overhead and improves reusability and robustness.<br>By keeping functions small and restricting them to only one level of abstraction.</p><pre>const getEvent = datum =&gt; datum.event<br>const is = x =&gt; y =&gt; x===y<br>const over = value =&gt; x =&gt; x &gt; value</pre><pre>const getScore = datum =&gt; datum.score</pre><pre>const isBigScore = compose(over(10),getScore)<br>const isGame = compose(is(&#39;game&#39;),getEvent)</pre><pre>const onlyBigGames data.filter(datum=&gt;isBigScore(datum)&amp;&amp;isGame(datum))</pre><h4>Separate Logic and Impure Data-Joins</h4><p>Even idempotent D3 data-joins still depend on the state of the DOM and are impure. Keeping as much logic to pure data transformations and keeping the impure D3 data-join layer as thin as possible makes the code much more comfortable to test and improves predictability.<br>The data layer is reusable when switching to a React controlled approach or introducing a charting library.</p><h4>React State as Single Source of Truth</h4><p>There should be only one single source of truth, to ensure that React’s UI stays in sync with the chart. Derived values should not be kept inside the React state, and they should be computed further downwards as needed.</p><pre>this.state = {activeEvent:&#39;birthday&#39;, events: [{score: 15, type:&#39;birthday&#39;}, ...]}</pre><pre>instead of directly storing derived state like</pre><pre>this.state = {activeEvent:&#39;birthday&#39;, events: [{score: 15, type:&#39;birthday&#39;, isActiveEvent: true }, ...]}</pre><p>If the nextState depends on the previous state, this.setState requires to pass it a function due to its async nature.</p><pre>const inc = x =&gt; x+1<br>const incSelectionCount = previousState =&gt; ({...previousState, selectionCount: inc(previousState.selectionCount)})</pre><pre>...</pre><pre>this.setState(inSelectionCount)</pre><p>This comes also with improved testability.</p><h4>What to test?</h4><p>Prototyping should not be slowed down by testing output to the DOM or having to write tests above unit test level. It is a good idea to start testing the data transformation functions. Those are pure and small and easy to test. Complicated, difficult to test parts like D3’s data-joins will change later anyway, their side effects have been separated from the logic pushed outwards as much as possible.<br>The next area to introduce tests are the functions passed to React’s setState.</p><h4>A few More Helpful Things</h4><p>It is a good idea to save the individual parts of the data-join and name them accordingly:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/63a8e98e3a223abd787561d18fc48677/href">https://medium.com/media/63a8e98e3a223abd787561d18fc48677/href</a></iframe><p>The parts that only create containers like the margin conventions benefit the most from creating small reusable helper functions similar to the following example:</p><pre>const calcInnerSize = props =&gt; {</pre><pre>const { margin, outerSize } = props</pre><pre>const width = outerSize.width - margin.left - margin.right</pre><pre>const height = outerSize.height - margin.top - margin.bottom</pre><pre>return ({ width, height })</pre><p>Almost every chart requires some padding in the y-dimension, which is easy to realize as follows:</p><h4>A Tiny Dirty Debugging Secret</h4><p>Everybody is guilty of using console.log statements for debugging purposes from time to time.<br>Logging out things becomes difficult in combination with function composition or D3’s dot chaining.<br>I sometimes use a little helper function in those cases:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7394a8268865dafed882dcc60223d8b3/href">https://medium.com/media/7394a8268865dafed882dcc60223d8b3/href</a></iframe><h3>Conclusion</h3><p>There are good reasons to sacrifice some of D3’s capabilities and hand over the complete DOM React. Unfortunately, animated transitions drastically increase complexity compared to the unanimated examples often show.<br>Therefore scratching out a prototype using D3’s data-join is still unmatched in speed and convenience.<br>The main principles that allow quick iterations and avoid lock-in are</p><ul><li>thin impure data-join layer not containing any data logic</li><li>pure, testable data transformation layer composed of small functions</li><li>pragmatism and the right amount of abstraction without introducing too much speculative generality</li></ul><h4>Where to look next?</h4><ul><li>I recommend having a look at the awesome <a href="https://github.com/drcmda/react-spring">react-spring</a> for an exciting approach to combine performant animations within React with a declarative API.</li><li><a href="https://d3fc.io/">d3fc</a>’s <a href="https://d3fc.io/introduction/decorate-pattern.html">decorate pattern</a> is an exciting extension of the reusable charts convention that exposes the different parts of the data-join to the user.</li><li><a href="http://sh/">vx</a> is a growing collection of low-level visualization components that provide an excellent foundation to build custom React centric, reusable visualizations.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e212e0967f77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making my React Project More Progressive]]></title>
            <link>https://medium.com/@davidsanwald/making-my-react-project-more-progressive-281a2e124720?source=rss-53448f96d094------2</link>
            <guid isPermaLink="false">https://medium.com/p/281a2e124720</guid>
            <category><![CDATA[pwa]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[service-worker]]></category>
            <category><![CDATA[progressive-web-app]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[David Sanwald]]></dc:creator>
            <pubDate>Thu, 04 May 2017 19:48:57 GMT</pubDate>
            <atom:updated>2017-05-05T07:53:22.945Z</atom:updated>
            <content:encoded><![CDATA[<h4>Optimizing my React Playground Project towards more Progressiveness</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*b7w0JUOG23v5SC8zS161zg.jpeg" /></figure><p>Lately I’ve been using my small step sequencer toy <a href="https://davidsanwald.github.io/klangblocks/">project</a>, I originally built at night because I couldn’t sleep (being madly in love isn’t always easy) for all kind of experiments and more or less educational JavaScript shenanigans.</p><p><a href="https://developers.google.com/web/progressive-web-apps/">Progressive Web Apps</a> are like pizza. There’s just no way you can dislike their features. So why not trying to become a little more progressive with my playground project.</p><h3>The First Audit</h3><p>Before every optimization, we always have to measure what we want to optimize. <br>So let’s add <a href="https://developers.google.com/web/tools/lighthouse/">Lighthouse</a> and get ready for some humiliation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*JE4cyTas9E0hLGQ_RTcqnA.png" /><figcaption><a href="https://googlechrome.github.io/lighthouse/viewer/?gist=058059d116e2b241d7e04c8470f07a19">https://googlechrome.github.io/lighthouse/viewer/?gist=058059d116e2b241d7e04c8470f07a19</a></figcaption></figure><p>Ouch! 29/100.</p><p>So what can we do about it?</p><p>Let’s start on the top.</p><h3>Hey ho let’s go!</h3><h4>Adding a Service Workers for basic offline support (+14 points)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*sv5Ac3ik74JJXtbdMGXUJg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*K4aJ8Y8C4Fi4pbefNHxjhw.png" /></figure><p>A <a href="https://developers.google.com/web/fundamentals/getting-started/primers/service-workers">service worker</a> script is executed in the background in it’s separate thread. Once it’s registered and installed, it is able to listen to events generated by network requests.<br>It doesn’t have access to the DOM but can intercept those network requests and also execute it’s own requests to fetch and precache data.</p><p>For security reasons a service worker can only be registered and installed when the pages utilizes https. The only exception is, of course, if the pages is served on localhost in development.</p><p>I quickly realized service worker can get quite complicated. Some things which make using service workers more complex are</p><ul><li>cross origin requests</li><li>redirects, things like logins</li><li>being mindful with the user’s resources</li><li>discriminating between frequently updated data and consistent data</li></ul><p>For knowledgeable in depth information about necessary considerations for real world service worker use, I recommend this <a href="https://www.youtube.com/watch?v=9L8YhkA0co4">great talk</a> by Antoni Huguet Vives.</p><p>There are some things which can go wrong, if you mess up you have to update the service worker on the client, you also have to be aware which data is served by the worker from cache, so the users might not see the eventual updates.</p><p>I found this <a href="https://medium.com/@boopathi/service-workers-gotchas-44bec65eab3f">article</a> about service workers (especially the part about killing workers before their 24h update cycle) very helpful.</p><p>Luckily my small sandbox app is quite simple, if I mess up something, it doesn’t cost lots of cash or thousands of users, I don’t update frequently and right now all of the data is needed by the user.<br>So it might be possible to go without complicated, customized caching strategies and trying an easy solution.</p><p>This is why I decided to give the <a href="https://github.com/NekR/offline-plugin">offline-plugin</a> for webpack a try. It works relatively easy out of the box, there were just a few points I had to keep in mind:</p><ul><li>Obviously I had to explicitly include those assets which aren’t handled by webpack. In my case I decided that I didn’t want my audio files to be handled by webpack’s file-loaders and just put them in the public folder.<br>So I had to inlucde them in the plugins config, as well as my index.html file, which isn’t handled by webpack either.</li><li>offline-plugin uses our old douchebag friend <a href="https://alistapart.com/article/application-cache-is-a-douchebag">Application Cache</a> as a fallback if there’s no service worker support on the client. So providing it an appropriate asset-manifest.json file wouldn’t be a bad idea.</li></ul><p>Okay yarn add -D offline-plugin and adding it and its configuration in the webpack.config.js file.</p><pre>//webpack.config.js</pre><pre>module.exports = { </pre><pre>// ...</pre><pre>plugins[<br>new OfflinePlugin({<br>      publicPath: &#39;/&#39;,<br>      externals: externalsUrls,<br>      ServiceWorker: {<br>    navigateFallbackURL: &#39;/&#39;<br>  }}), </pre><pre>//...</pre><pre>],</pre><pre>}</pre><p>And adding it to the entry file</p><pre>// index.js<br>import * as OfflinePluginRuntime from &#39;offline-plugin/runtime&#39;;<br>OfflinePluginRuntime.install();</pre><p>Okay, here we go again :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*CnZhdxzSjH4uITFjxHiyqg.png" /><figcaption><a href="https://googlechrome.github.io/lighthouse/viewer/?gist=ff12e83c8fff96a42be3bf21796fd33a">https://googlechrome.github.io/lighthouse/viewer/?gist=ff12e83c8fff96a42be3bf21796fd33a</a></figcaption></figure><p>That’s better but still way to go!</p><h4>Adding a Web App Manifest (+31 points)</h4><p>A <a href="https://developers.google.com/web/tools/lighthouse/audits/manifest-exists">Web App Manifest</a> will enable users to add it to their homescreen and allows to specify the apps appearance when it’s used outside the browser.</p><p>Linking the manifest.json is pretty straight forward and a basic manifest is also very simple to create. This is the manifest.json for my playground project:</p><p>//manifest.json <br>{<br> “name”: “KlangBlocks”,<br> “short_name”: “KlangBlocks”,<br> “start_url”: “.”,<br> “display”: “standalone”,<br> “theme_color”: “#002635”,<br> “background_color”: “#002635”,<br> “description”: “Here to make you think about death and get sad and stuff.”,<br> “icons”: [{<br> “src”: “icons/64.png”,<br> “sizes”: “64x64”,<br> “type”: “image/png”<br> }, {<br> “src”: “icons/128.png”,<br> “sizes”: “128x128”,<br> “type”: “image/png”<br> }, {<br> “src”: “icons/192.png”,<br> “sizes”: “192x192”,<br> “type”: “image/png”<br> },<br> {<br> “src”: “icons/384.png”,<br> “sizes”: “384x384”,<br> “type”: “image/png”<br> },<br> {<br> “src”: “icons/512.png”,<br> “sizes”: “512x512”,<br> “type”: “image/png”<br> }]<br>}</p><p>and linked in my index.html<br> &lt;link rel=”manifest” href=”%PUBLIC_URL%/manifest.json”&gt;</p><p>Google recommends to include at least a 192x192 icon to ensure providing the appropriate pixel density for larger displays. But to be safe it&#39;s recommended to provide icons up to a size of 512x512 pixels.</p><p>The specified background color allows to display a splash screen in this color, during the start-up time of the app.</p><p>This can dramatically improve the perceptual speed of the app, especially for slower start up times.</p><p>No we can view the App Manifest in the Application tab of devtools. Let’s click on “Add to homescreen” and see, if everything looks alright.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*QW6l_L62j4xxslYR2dOr0w.png" /></figure><p>Et voilà. Beautiful isn’t it? (;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dfr75yH1wkLmHj9BE7G8wg.png" /><figcaption>the added app</figcaption></figure><p>Where are we now?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*wiuNpX56xpZgNg23ORorKg.png" /><figcaption><a href="https://googlechrome.github.io/lighthouse/viewer/?gist=fea741b52a42c1741450d3f41df18855">https://googlechrome.github.io/lighthouse/viewer/?gist=fea741b52a42c1741450d3f41df18855</a></figcaption></figure><p>Better but if there are scores with green color we want that (:</p><h4>Using require.ensure() for lazy module loading/code splitting to improve performance</h4><p>Till now we haven’t really touched any actual code of the app. <br>That’s pretty sad, I think. <br>I’d guess that a major part of our bundle.js has to be attributed to the <a href="https://tonejs.github.io/">Tone.js</a> lib, that does all kinds of amazing stuff with the Web Audio API (for example providing a really clever solution for scheduling in combination with changing/ramping the general tempo, something which requires a lot of creativity because of the inner workings of the Web Audio Clock).</p><p>The overall loading time isn’t the main factor that determines how users perceive the speed of the application.</p><p>How long it takes till the user sees the first paint of the DOM in the browser as well as the amount of time till the application responds to user input are way more relevant parameters.</p><p>Because we can structure the app in such a way that the complete initial rendering doesn’t depend on the Tone.js library and those parts of the app, that are responsible for the sound output, we can optimize important parameters you see below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*BMn_t9OZJBNrXTTcl4v1XQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*C2hF9oMF0SieLgDZxuO00w.png" /><figcaption>Lighthouse audit before and after isolating the sound related part from the UI code</figcaption></figure><p>Analyzing webpack’s stats.json file confirmes our assumption.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lzgrpK9JAwq_FMECLGCzTA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lO-P90w8EvymSeh3zH7jDg.png" /><figcaption>before and after stats.json file visualized by <a href="https://github.com/th0r/webpack-bundle-analyzer">webpack-bundle-analyzer</a></figcaption></figure><p>I won’t go into detail about require.ensure() because it soon will be completely replaced by import().</p><p>Important is, that the part we want to bundle separably has to be isolated in such way, that having to wait for it being loaded doesn’t block the rest of the application.</p><p>This is the console output of our build script:</p><pre>Creating an optimized production build…<br>Compiled successfully.</pre><pre>File sizes after gzip:</pre><pre>101.51 KB (<strong>-42.55 KB</strong>) build/static/js/main.cae42e7d.js<br> 43.23 KB build/static/js/loop.591c7667.chunk.js<br> 2.74 KB build/sw.js</pre><p>Unfortunately this didn’t improve the overall score but we’re improving for the user and not for some automated audit.</p><h4>Sharing something even with those that don’t share the language (+12 points)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*KY6GV9YAkjlnVxbmDjDltA.jpeg" /></figure><p>Okay it’s a React app, so we will have a hard time without JavaScript.</p><p>But hey, I’m giving my best ❤</p><p>This is what you see, if you can’t execute JavaScript:</p><p><a href="http://noscript-but-love.surge.sh/">https://noscript-but-love.surge.sh/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FiGDUU2mwG6zxW34swpqpw.png" /><figcaption>No Script (:</figcaption></figure><p>What does Lighthouse have to <a href="https://googlechrome.github.io/lighthouse/viewer/?gist=8cdfacc64df839801ec816b16a1b7072">say</a> about all that?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*Us7wLUkj1s3zVHvS6BhJ5A.png" /></figure><p>Let’s not be to greedy for today. Hey it’s green ❤</p><h3>Conclusion</h3><p>It was pretty easy to improve the Lighthouse score but we should keep a few things in mind:</p><ul><li>PWAs aren’t about some scores but about improving the experience for real human beings. So the Lighthouse audit should be taken with a grain of salt</li><li>There weren’t any COR, no existing codebase, no 3xx requests, no user auth, we needed pretty much all data right from the start, while it wasn’t too much to just prefetch it indiscriminately</li><li>The score isn’t that bad but in many aspects the app still isn’t very progressive, for example we could significantly improve the perceptual speed by introducing an app shell and/or rendering some dummy skeleton before initializing our actual data</li></ul><h4>Lessons learned</h4><p>Providing some content, even to users without JavaScript support seems maybe almost unreasonably at first but shouldn’t we try to communicate with anyone, who tries to reach out to us, even if we don’t speak the same language?<br>Maybe progressive enhancement shouldn’t be just about the web?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=281a2e124720" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Defeating the Deadly Triad]]></title>
            <link>https://medium.com/@davidsanwald/defeating-the-deadly-triad-f5a8e39a82e1?source=rss-53448f96d094------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5a8e39a82e1</guid>
            <category><![CDATA[keras]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[openai]]></category>
            <dc:creator><![CDATA[David Sanwald]]></dc:creator>
            <pubDate>Mon, 24 Apr 2017 16:25:38 GMT</pubDate>
            <atom:updated>2019-01-22T11:42:40.331Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*yQUGvIBqOdFomc5VWx1zJA.jpeg" /><figcaption>one of the most canonical RL benchmarks</figcaption></figure><h4>Understanding Deep Reinforcement Learning using Double DQN</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FI7oPYEeSVfc%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DI7oPYEeSVfc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FI7oPYEeSVfc%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b442cb24579eb127497b2246f538901/href">https://medium.com/media/3b442cb24579eb127497b2246f538901/href</a></iframe><p>I thought this might by interesting but as long as medium doesn’t provide proper support for typesetting formulas, I have to point to the original version on github:</p><p><a href="https://davidsanwald.github.io/2016/12/11/Double-DQN-interfacing-OpenAi-Gym.html">Defeating the Deadly Triad:</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5a8e39a82e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interactive Intro to Reinforcement Learning]]></title>
            <link>https://medium.com/@davidsanwald/interactive-intro-to-reinforcement-learning-865e5a916289?source=rss-53448f96d094------2</link>
            <guid isPermaLink="false">https://medium.com/p/865e5a916289</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deepmind]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <dc:creator><![CDATA[David Sanwald]]></dc:creator>
            <pubDate>Mon, 24 Apr 2017 16:16:31 GMT</pubDate>
            <atom:updated>2017-04-24T16:16:31.380Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*HZpzcko_3Sgn7yXgq45D6A.png" /></figure><p>Most of the introductory materials to RL start with formal definitions. Before the first basic learning algorithms, one has to understand at least Markov Chains, their extension to Markov Decision (and Reward) Processes and Bellman Equations. After that the reader is on her own to figure out how to actually implement all this.</p><p>While formal math is obviously the best way to precisely formulate and communicate RL and its concepts it may not be the best tool to introduce the fascinating field to someone just starting out.</p><p>The more RL gains attention from outside, the more people without a formal math background are looking for a way to get started.</p><p>I love the possibilities of Jupyter notebooks to share and communicate ideas and concepts and I obviously love RL, that’s why I made a small notebook putting code in the center instead of hiding it in the appendix after 290802 formulas.</p><ul><li><a href="https://nbviewer.jupyter.org/github/DavidSanwald/ai-notebook/blob/master/index.ipynb">Preview</a> on nbviewer</li><li><a href="https://github.com/DavidSanwald/ai-notebook">Download</a> on github: <a href="https://github.com/DavidSanwald/ai-notebook">https://github.com/DavidSanwald/ai-notebook</a></li><li><a href="http://mybinder.org/repo/davidsanwald/ai-notebook">Interactive</a> version in the browser.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=865e5a916289" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>