<?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 Dmitry Yakimov on Medium]]></title>
        <description><![CDATA[Stories by Dmitry Yakimov on Medium]]></description>
        <link>https://medium.com/@welldan97?source=rss-a3396049e11c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fctemAsptcwH0S1hoHO29g.jpeg</url>
            <title>Stories by Dmitry Yakimov on Medium</title>
            <link>https://medium.com/@welldan97?source=rss-a3396049e11c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 07:12:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@welldan97/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[TypeScript Reference for JS developers]]></title>
            <link>https://medium.com/beadlist/typescript-reference-for-js-developers-8997f739f504?source=rss-a3396049e11c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8997f739f504</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Dmitry Yakimov]]></dc:creator>
            <pubDate>Sun, 28 Aug 2022 19:25:23 GMT</pubDate>
            <atom:updated>2022-08-28T19:29:12.510Z</atom:updated>
            <content:encoded><![CDATA[<h3>Glossary of keywords, operators, statements and directives</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/64/1*Q4wXJyxfDp9KbaNNPkvFvQ.png" /></figure><p>See up to date version on <strong>GitHub</strong>: <a href="https://github.com/welldan97/typescript-reference">https://github.com/welldan97/typescript-reference</a></p><h3>Statements</h3><p><a href="https://www.typescriptlang.org/docs/handbook/declaration-files/by-example.html">declare</a>, <a href="https://www.typescriptlang.org/docs/handbook/namespaces.html">namespace</a></p><h3>Built-in Type Primitives</h3><p><a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html">boolean</a>, <a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html">string</a>, <a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html">number</a>, <a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html">undefined</a>, <a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html">null</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html">bigint</a>, <a href="https://www.typescriptlang.org/docs/handbook/symbols.html">symbol</a>, <a href="https://www.typescriptlang.org/docs/handbook/symbols.html#unique-symbol">unique symbol</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html">any</a>, <a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html">unknown</a>, <a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html">never</a>, <a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html">void</a></p><h3>Complex Types</h3><p><a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types">|</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html#array">Array[]</a>, <a href="https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types">Tuple[]</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-aliases">type</a>, <a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#interfaces">interface</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/enums.html">enum</a></p><h3>Type and Interface Properties</h3><p>{</p><p><a href="https://www.typescriptlang.org/docs/handbook/2/objects.html#optional-properties">property?: Type</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/objects.html#readonly-properties">readonly property: Type</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/functions.html#call-signatures">(...args): Type</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/functions.html#construct-signatures">new(s: Type)</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/objects.html#index-signatures">[key: Type]: Type;</a></p><p>}</p><h3>Functions</h3><h3>Arguments</h3><p><a href="https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function">{ (this: Type): Type }</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/functions.html#rest-parameters-and-arguments">{ (...args: Type[]): Type }</a></p><h3>Type Guards and Assertion Functions</h3><p><a href="https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates">is</a>, <a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions">asserts condition</a>, <a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions">asserts value is Type</a></p><h3>Overloads</h3><p><a href="https://www.typescriptlang.org/docs/handbook/2/functions.html#function-overloads">overloads</a></p><h3>Type Manipulation</h3><h3>Basic</h3><p><a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#non-null-assertion-operator-postfix-">!</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions">as</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-inference">as const</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/indexed-access-types.html">Type[key]</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/typeof-types.html">typeof</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/keyof-types.html">keyof</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#inferring-within-conditional-types">extends Type ? IfTrue : IfFalse</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#type-inference-in-conditional-types">infer</a></p><h3>Extension</h3><p><a href="https://www.typescriptlang.org/docs/handbook/2/objects.html#intersection-types">&amp;</a>, <a href="https://www.typescriptlang.org/docs/handbook/2/objects.html#extending-types">extends</a>, <a href="https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces">merging</a></p><h3>Mapped Types</h3><p>{</p><p><a href="https://www.typescriptlang.org/docs/handbook/2/mapped-types.html">[Property in keyof Type]: Type;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#mapping-modifiers">-readonly [Property in keyof Type]: Type[Property];</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#mapping-modifiers">readonly [Property in keyof Type]: Type[Property];</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#mapping-modifiers">[Property in keyof Type]-?: Type[Property];</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#mapping-modifiers">[Property in keyof Type]?: Type[Property];</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#key-remapping-via-as">[Properties in keyof Type as NewKeyType]: Type[Properties]</a></p><p>}</p><h3>Generics</h3><p><a href="https://www.typescriptlang.org/docs/handbook/2/objects.html#generic-object-types">interface NewType&lt;Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/objects.html#generic-object-types">type NewType&lt;Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/generics.html#generic-types">{ &lt;Type&gt;(arg: Type): Type }</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/generics.html#generic-classes">class Class&lt;Type&gt;</a></p><h3>Constrains</h3><p><a href="https://www.typescriptlang.org/docs/handbook/2/generics.html#generic-constraints">&lt;Type extends OtherType&gt;</a></p><h3>Classes</h3><h3>Properties</h3><p>{</p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#this-based-type-guards">property?: Type</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#fields">property!: Type</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#readonly">readonly property: Type</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#index-signatures">[key: Type]: Type</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#private">private property: Type</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#protected">protected property: Type</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#type-only-field-declarations">declare property: Type</a></p><p>}</p><h3>Properties present in JS</h3><p>{</p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#caveats">#property: Type</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#getters--setters">get property(): Type</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#getters--setters">set property(...args): Type</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#static-members">static property: Type</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#static-blocks-in-classes">static {...}</a></p><p>}</p><h3>Constructor Parameter Properties</h3><p>{</p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#parameter-properties">constructor(parameter arg: Type)</a></p><p>}</p><h3>Extension</h3><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#class-heritage">implements</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#extends-clauses">extends</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/classes.html#abstract-classes-and-members">abstract</a></p><h3>Decorators</h3><p><a href="https://www.typescriptlang.org/docs/handbook/decorators.html#class-decorators">@decorator class Class</a> {</p><p><a href="https://www.typescriptlang.org/docs/handbook/decorators.html#property-decorators">@decorator() property</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/decorators.html#method-decorators">@decorator method(...args) {...}</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/decorators.html#parameter-decorators">method(@decorator arg: Type) {...}</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/decorators.html#accessor-decorators">@decorator get accessor() {...}</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/decorators.html#accessor-decorators">@decorator set accessor(value) {...}</a></p><p>}</p><h3>Utility Types</h3><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype">Partial&lt;Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#requiredtype">Required&lt;Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype">Readonly&lt;Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type">Record&lt;Keys, Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys">Pick&lt;Type, Keys&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys">Omit&lt;Type, Keys&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#excludeuniontype-excludedmembers">Exclude&lt;UnionType, ExcludedMembers&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#extracttype-union">Extract&lt;Type, Union&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#nonnullabletype">NonNullable&lt;Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#parameterstype">Parameters&lt;Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#constructorparameterstype">ConstructorParameters&lt;Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#returntypetype">ReturnType&lt;Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#instancetypetype">InstanceType&lt;Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#thisparametertypetype">ThisParameterType&lt;Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#omitthisparametertype">OmitThisParameter&lt;Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#thistypetype">ThisType&lt;Type&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#uppercasestringtype">Uppercase&lt;StringType&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#lowercasestringtype">Lowercase&lt;StringType&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#capitalizestringtype">Capitalize&lt;StringType&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#uncapitalizestringtype">Uncapitalize&lt;StringType&gt;</a></p><h3>Comment Directives</h3><h3>Enabling and Disabling Typescript</h3><p><a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-6.html#suppress-errors-in-ts-files-using--ts-ignore-comments">// @ts-ignore</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/intro-to-js-ts.html#ts-check.html#suppress-errors-in-ts-files-using--ts-ignore-comments">// @ts-check</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#-ts-nocheck-in-typescript-files">// @ts-nocheck</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#-ts-expect-error-comments">// @ts-expect-error</a></p><h3>References</h3><p><a href="https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-path-">/// &lt;reference path=&quot;...&quot; /&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types-">/// &lt;reference types=&quot;...&quot; /&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-lib-">/// &lt;reference lib=&quot;...&quot; /&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-no-default-libtrue">/// &lt;reference no-default-lib=&quot;true&quot;/&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-amd-module-">/// &lt;amd-module /&gt;</a></p><p><a href="https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-amd-dependency-">/// &lt;amd-dependency /&gt;</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8997f739f504" width="1" height="1" alt=""><hr><p><a href="https://medium.com/beadlist/typescript-reference-for-js-developers-8997f739f504">TypeScript Reference for JS developers</a> was originally published in <a href="https://medium.com/beadlist">BeadList</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tutorial: Using Loopback 4 Together With Next.js on one Heroku instance]]></title>
            <link>https://medium.com/beadlist/tutorial-using-loopback-4-together-with-next-js-on-one-heroku-instance-306dd76d02a6?source=rss-a3396049e11c------2</link>
            <guid isPermaLink="false">https://medium.com/p/306dd76d02a6</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[loopback]]></category>
            <dc:creator><![CDATA[Dmitry Yakimov]]></dc:creator>
            <pubDate>Fri, 07 Dec 2018 21:17:41 GMT</pubDate>
            <atom:updated>2018-12-07T21:17:41.058Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*woLweYamfOf-pEk0tpXSCA.png" /></figure><p>Loopback 4 makes a great backend for an application. And Next.js is amazing for client side. And they work together very well.</p><p>When you run them on the separate servers you might won’t have any problems with deploy at all. But if you want to save some resources, and run them together on one server instance, it could get a little tricky. Today I’m going to show you how to do it. And we’ll use Heroku for deployment.</p><p>All together, we would need to follow these steps:</p><ol><li>Setting up Loopback 4;</li><li>Setting up Next.js;</li><li>Setting up the common server;</li><li>Deploy on Heroku.</li></ol><p>Our Loopback 4 server is going to be under the ./server path, and Next.js application would go to./client . So the project tree would look like this:</p><pre>.<br>├── client<br>│   ├── index.js<br>│   ├── package.json<br>│   ├── pages<br>│   ├── server.js<br>│   └── ...<br>└── server<br>    ├── index.js<br>    ├── index.ts<br>    ├── package.json<br>    ├── src<br>    ├── tsconfig.json<br>    └── ...</pre><h3>1. Setting Up Loopback 4</h3><p>In order to install and Loopback 4, let’s just follow the official instructions from <a href="https://loopback.io/doc/en/lb4/Getting-started.html">here</a>.</p><p>We install @loopback/cli globally:</p><pre>$ npm i -g <a href="http://twitter.com/loopback/cli">@loopback/cli</a></pre><p>And we create a new project:</p><pre>$ lb4 app</pre><pre>? Project name: frogfish-server<br>? Project description: app<br>? Project root directory: server<br>? Application class name: FrogfishServerApplication<br>? Select features to enable in the project<br> ◉ Enable tslint<br> ◉ Enable prettier<br> ◉ Enable mocha<br> ◉ Enable loopbackBuild<br> ◉ Enable vscode<br> ◉ Enable repositories<br> ◉ Enable services</pre><p>Then we start the server and check that everything is good:</p><pre>$ cd server</pre><pre>$ npm start</pre><p>When we go to <a href="http://localhost:3000/ping">http://localhost:3000/ping</a> we can see our application is running properly, and we see the following response:</p><pre>{<br>  greeting: &quot;Hello from LoopBack&quot;,<br>  date: &quot;2018-12-06T18:42:31.950Z&quot;,<br>  url: &quot;/ping&quot;,<br>  headers: {...}<br>}</pre><p>Alright, looking good. Now let’s set up Next.js.</p><h3>2. Setting Up Next.js</h3><h4>Installation</h4><p>Same as Loopback 4, let’s just follow official instructions from <a href="https://github.com/zeit/next.js/#setup">here</a>.</p><p>Outside of server dir we run this to init the project under the ./client dir:</p><pre>$ mkdir client</pre><pre>$ cd client</pre><pre>$ npm init</pre><pre>package name: (client) frogfish-client<br>version: (1.0.0)<br>description:<br>entry point: (index.js)<br>test command:<br>git repository:<br>keywords:<br>author:<br>license: (ISC)</pre><p>Then we install the dependencies:</p><pre>$ npm install --save next react react-dom</pre><p>And add scripts to our package.json:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;dev&quot;: &quot;next&quot;,<br>    &quot;build&quot;: &quot;next build&quot;,<br>    &quot;start&quot;: &quot;next start&quot;<br>  }<br>}</pre><p>Ok. Then we create a sample page on./client/pages/index.js :</p><pre>export default () =&gt; &lt;div&gt;Welcome to next.js!&lt;/div&gt;</pre><p>Let’s check if everything is working:</p><pre>$ npm run dev</pre><p>And we go to <a href="http://localhost:3000/">http://localhost:3000/</a> and see the sample page. Looking good!</p><h4>Custom Client Server</h4><p>In order to make Next.js to run with Loopback 4, we would need a custom server for it. Let’s make one. And let’s make it wrap it into module, to make it reusable.</p><p>We create a file ./client/index.js with this contents:</p><pre>// ./client/index.js</pre><pre>const express = require(&#39;express&#39;);<br>const next = require(&#39;next&#39;);</pre><pre>module.exports = async function({<br>  beforeNext = () =&gt; {}, <br>  dir = &#39;.&#39; } = {}<br>) {<br>  const dev = process.env.NODE_ENV === &#39;development&#39;;<br>  const port = process.env.PORT || 3000;</pre><pre>  const app = next({ dev, dir });<br>  const handle = app.getRequestHandler();<br>  const server = express();</pre><pre>  await app.prepare();<br>  await beforeNext(server);</pre><pre>  server.use(express.static(`${dir}/static`));<br>  server.get(&#39;*&#39;, (req, res) =&gt; handle(req, res));</pre><pre>  server.listen(port, err =&gt; {<br>    if (err) throw err;<br>    console.log(`&gt; Ready on port: ${port}`);<br>  });<br>};</pre><p>As you can see we have created a server module, which can be executed from outside of the client. It has two arguments:</p><ul><li>beforeNext — the function, which would called before Next.js handles the request. That’s where we are going to initiate our Loopback 4 app;</li><li>dir — the dir under which the Next.js project runs, by default it’s going to be . , but when we run it from outside it’s going to become ./client .</li></ul><p>And then we create a runner under ./client/server.js :</p><pre>// ./client/server.js</pre><pre>const server = require(&#39;./&#39;);<br>server();</pre><p>We change our package.json dev script like this:</p><pre>{<br>    &quot;dev&quot;: &quot;NODE_ENV=development node server.js&quot;,<br>}</pre><p>And we check that we didn’t break anything:</p><pre>$ npm run dev</pre><p>Ok, so far so good. Let’s glue our server with client.</p><h3>3. Set Up the Common Server</h3><h4>Server script</h4><p>So now we have two directories in our project. One is ./client , which contains our Next.js project, and then we have ./server for Loopback 4 app. And in the root dir we are going to make our common server, which would serve both.</p><p>Let’s create a file with named./index.js with this contents:</p><pre>// ./index.js</pre><pre>const client = require(&#39;./client&#39;);<br>const serverApp = require(&#39;./server/dist/&#39;);</pre><pre>client({<br>  dir: &#39;client&#39;,<br>  beforeNext: async server =&gt; {<br>    const app = new serverApp.FrogfishServerApplication();<br>    await app.boot();<br>    server.use(&#39;/api&#39;, app.requestHandler);<br>  },<br>});</pre><p>That’s how we can use both apps together under one server!</p><h4>Configuring package.json</h4><p>Now we are going to create common package.json in a root dir, where we just merging dependencies of both apps:</p><pre>{<br>  &quot;name&quot;: &quot;frogfish&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;&quot;,<br>  &quot;main&quot;: &quot;index.js&quot;,<br>  &quot;author&quot;: &quot;&quot;,<br>  &quot;license&quot;: &quot;ISC&quot;,<br>  &quot;dependencies&quot;: {<br>    &quot;<a href="http://twitter.com/loopback/boot">@loopback/boot</a>&quot;: &quot;^1.0.6&quot;,<br>    &quot;<a href="http://twitter.com/loopback/context">@loopback/context</a>&quot;: &quot;^1.2.0&quot;,<br>    &quot;<a href="http://twitter.com/loopback/core">@loopback/core</a>&quot;: &quot;^1.1.1&quot;,<br>    &quot;<a href="http://twitter.com/loopback/openapi-v3">@loopback/openapi-v3</a>&quot;: &quot;^1.1.3&quot;,<br>    &quot;<a href="http://twitter.com/loopback/repository">@loopback/repository</a>&quot;: &quot;^1.0.6&quot;,<br>    &quot;<a href="http://twitter.com/loopback/rest">@loopback/rest</a>&quot;: &quot;^1.4.0&quot;,<br>    &quot;<a href="http://twitter.com/loopback/rest-explorer">@loopback/rest-explorer</a>&quot;: &quot;^1.1.2&quot;,<br>    &quot;<a href="http://twitter.com/loopback/service-proxy">@loopback/service-proxy</a>&quot;: &quot;^1.0.3&quot;,<br>    &quot;express&quot;: &quot;^4.16.4&quot;,<br>    &quot;next&quot;: &quot;^7.0.2&quot;,<br>    &quot;npm-run-all&quot;: &quot;^4.1.5&quot;,<br>    &quot;react&quot;: &quot;^16.6.3&quot;,<br>    &quot;react-dom&quot;: &quot;^16.6.3&quot;<br>  },<br>  &quot;devDependencies&quot;: {<br>    &quot;<a href="http://twitter.com/loopback/build">@loopback/build</a>&quot;: &quot;^1.0.1&quot;,<br>    &quot;<a href="http://twitter.com/loopback/testlab">@loopback/testlab</a>&quot;: &quot;^1.0.1&quot;,<br>    &quot;<a href="http://twitter.com/types/node">@types/node</a>&quot;: &quot;^10.11.2&quot;<br>  }<br>}</pre><p>Then we install the dependencies:</p><pre>$ npm install</pre><p>Now let’s add scripts there for managing our app, for that we would need npm-run-all for running our scripts in parallel, we install it via:</p><pre>$ npm install npm-run-all --save</pre><p>And we add the following scripts:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;dev&quot;: &quot;NODE_ENV=development node .&quot;,<br>    &quot;build&quot;: &quot;npm-run-all --parallel build:server build:client&quot;,<br>    &quot;build:client&quot;: &quot;next build client&quot;,<br>    &quot;build:server&quot;: &quot;lb-tsc es2017 --outDir server/dist -p server&quot;,<br>    &quot;start&quot;: &quot;node .&quot;,<br>    &quot;heroku-postbuild&quot;: &quot;npm run build&quot;<br>  }<br>}</pre><p>There is some magic going on with TypeScript compilation. Apart from that, everything else is easy. Also notice heroku-postbuild script. It’s going to run after our application got deployed on heroku.</p><h4>Fixing tsconfig.json</h4><p>Now le’ts do the last thing here, let’s adjust ./server/tsconfig.json . In order to make TypeScript compilation to work, we have to fix its extends key:</p><pre>{<br>  &quot;extends&quot;: &quot;../node_modules/@loopback/build/config/tsconfig.common.json&quot;<br>}</pre><p>We’ve just added an extra dot before /node_modules .</p><h3>4. Deploy on Heroku</h3><p>Deploy on heroku is straightforward. We create an app there with a name frogfish . Then we deploy:</p><pre>git remote add origin <a href="https://git.heroku.com/frogfish.git">https://git.heroku.com/frogfish.git</a><br>git push</pre><p>And we add HOST variable to our configuration:</p><pre>heroku config:set HOST=frogfish.herokuapp.com</pre><p>Now the app is up and running! Yahoo</p><p>As a last step, let’s change ./client/pages/index.js to make use of our new api:</p><pre>import React, { Component } from &#39;react&#39;;</pre><pre>export default class IndexPage extends Component {<br>  state = {<br>    response: {},<br>  };</pre><pre>  async componentDidMount() {<br>    const response = await (await fetch(&#39;/api/ping&#39;)).json();<br>    this.setState({ response });<br>  }</pre><pre>  render() {<br>    return (<br>      &lt;div&gt;<br>        &lt;p&gt;Welcome to next.js!&lt;/p&gt;<br>        &lt;p&gt;{this.state.response.greeting}&lt;/p&gt;<br>        &lt;p&gt;<br>          &lt;pre&gt;<br>            {JSON.stringify(this.state.response, undefined, 2)}<br>          &lt;/pre&gt;<br>        &lt;/p&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}</pre><p>Then we deploy, and go to <a href="https://frogfish.herokuapp.com/">https://frogfish.herokuapp.com/</a> and yay, our Loopback 4 + Next.js app is up and running. We can see greetings both from both sides. Thank you very much.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_r9jZMf3CX6nv0kau7IiqQ.png" /><figcaption>Loopback 4 working together with Next.js</figcaption></figure><p>You can checkout the resulting source code on Github <a href="https://github.com/welldan97/frogfish">here</a>.</p><p>I wish you some joyful coding sessions and easy integrations. See you next time!█</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=306dd76d02a6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/beadlist/tutorial-using-loopback-4-together-with-next-js-on-one-heroku-instance-306dd76d02a6">Tutorial: Using Loopback 4 Together With Next.js on one Heroku instance</a> was originally published in <a href="https://medium.com/beadlist">BeadList</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using curl for API testing]]></title>
            <link>https://medium.com/beadlist/using-curl-for-api-testing-463803304620?source=rss-a3396049e11c------2</link>
            <guid isPermaLink="false">https://medium.com/p/463803304620</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[curl]]></category>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Dmitry Yakimov]]></dc:creator>
            <pubDate>Fri, 30 Nov 2018 17:04:55 GMT</pubDate>
            <atom:updated>2018-11-30T17:04:55.636Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eRM2JwYJlmcOZkRDTJjQvQ.png" /></figure><p>I’ve found an alternative to rest clients for API testing, and I thought to share it with you. But first an intro.</p><p>Back in the days, although I’ve been using terminal extensively, I still was using Postman for making requests. I guess I just didn’t really understood how they work, and curl or wget seemed to me a little bit complicated. Especially since I was using them directly from terminal, and I had to adjust arguments all the time, and, you know, it’s not very comfortable.</p><p>Then I’ve discovered restclient for emacs. Which essentially allowed to do the same as Postman, but it was more comfortable, because I didn’t have to quit my favorite editor and I could resolve everything just by typing in the necessary commands.</p><p>But, then I thought, there has to be a better way. Why not just have a shell script file with several curl commands in it. You can edit it with your favorite editor and easily share it with anyone. Because shell&amp;curl are common among all programmers, and they are editor-independent they can be understood by anyone, and they don’t force to use you certain app. That’s a win.</p><h3><strong>Curl Crush course</strong></h3><p>If you’ve been using apps for requests before you might want to learn a little bit about curl . It’s actually very easy for the most of the daily jobs. Here comes a little crush course, to get you aboard.</p><p>For the most of the time you can use this command:</p><pre>curl -X &lt;method&gt; &lt;url&gt; --header &lt;header&gt; -d &lt;data&gt; --verbose</pre><p>Where:</p><ul><li>&lt;method&gt; — HTTP request method, can be GET , POST , PUT , DELETE , and others;</li><li>&lt;url&gt; — the url of an endpoint;</li><li>&lt;header&gt; — request headers, you can specify several of them;</li><li>&lt;data&gt; — request body, you can provide your json here</li><li>--verbose — an option to show request verbosely, can be used to show the headers;</li></ul><p>Example:</p><pre>curl -X POST \<br>  &quot;<a href="http://localhost:3001/internal">http://localhost:3001/a</a>pi/users/login&quot; \<br>  --header &#39;Content-Type: application/json&#39; \<br>  --header &#39;Accept: application/json&#39; \<br>  -d &#39;<br>  {<br>    &quot;email&quot;: &quot;frog@example.com&quot;,<br>    &quot;password&quot;: &quot;fishfish&quot;<br>  }&#39;</pre><p>And this example becomes a building block for our api testing suit. Although it has some boilerplate with headers and explicit json, since it will be copy pasted several times it doesn’ bring much worries.</p><p>It’s that easy.</p><h3>Organization</h3><p>When I come to the project I usually create a file called ./requests with this boilerplate:</p><pre>#!/usr/bin/env bash</pre><pre># Functions</pre><pre># Variables</pre><pre>URL=&quot;&quot;</pre><pre># Samples</pre><p>Now let’s create our first API call for user log in</p><pre>#!/usr/bin/env bash</pre><pre># Users</pre><pre>usersLogin() {<br>  email=$1<br>  password=$2</pre><pre>  curl -X POST \<br>    &quot;$URL/users/login&quot; \<br>    --header &#39;Content-Type: application/json&#39; \<br>    --header &#39;Accept: application/json&#39; \<br>    -d &#39;<br>    {<br>      &quot;email&quot;: &quot;&#39;&quot;$email&quot;&#39;&quot;,<br>      &quot;password&quot;: &quot;&#39;&quot;$password&quot;&#39;&quot;<br>    }&#39;<br>}</pre><pre># Variables</pre><pre>URL=&quot;<a href="http://localhost:3001/internal">http://localhost:3001/a</a>pi&quot;</pre><pre># Samples</pre><pre>usersLogin &#39;<a href="/service/mailto:welldan97@gmail.com">f</a>rog@example.com&#39; &#39;fishfish&#39; | jq</pre><p>As you can see with this structure you can define your variables. It is pretty readable, and yet universal.</p><p>Note the inserted variables here &quot;&#39;&quot;$email&quot;&#39;&quot; , it’s a little weird but works, and I use it here primarily to avoid extra slashes.</p><p>Also note, I use <a href="https://stedolan.github.io/jq/">jq</a> for json highlighting. But you can use <a href="https://github.com/antonmedv/fx">fx</a> or just leave it without it.</p><p>Now I just have to run the script ./requests . And I get this output:</p><pre>{<br>  &quot;token&quot;: &quot;eyJhbGci.eyJpZCI6.Ag2Q2hTV&quot;,<br>  &quot;userId&quot;: 1<br>}</pre><p>Nice. Now, let’s add one more method:</p><pre>#!/usr/bin/env bash</pre><pre># Users</pre><pre>usersLogin() {<br>  email=$1<br>  password=$2</pre><pre>  curl -X POST \<br>    &quot;$URL/users/login&quot; \<br>    --header &#39;Content-Type: application/json&#39; \<br>    --header &#39;Accept: application/json&#39; \<br>    -d &#39;<br>    {<br>      &quot;email&quot;: &quot;&#39;&quot;$email&quot;&#39;&quot;,<br>      &quot;password&quot;: &quot;&#39;&quot;$password&quot;&#39;&quot;<br>    }&#39;<br>}</pre><pre>usersFindById() {<br>  id=${1:-1}</pre><pre>  curl -X GET \<br>    &quot;$URL/users/$id&quot; \<br>    --header &quot;Authorization: Bearer $TOKEN&quot;<br>}</pre><pre># Variables</pre><pre>URL=&quot;<a href="http://localhost:3001/internal">http://localhost:3001/a</a>pi&quot;<br>TOKEN=&quot;$(usersLogin &#39;<a href="/service/mailto:welldan97@gmail.com">f</a>rog@example.com&#39; &#39;fishfish&#39; | jq -r .token)&quot;</pre><pre># Samples</pre><pre>#usersLogin &#39;<a href="/service/mailto:welldan97@gmail.com">f</a>rog@example.com&#39; &#39;fishfish&#39; | jq<br>usersFindById 1 | jq</pre><p>Now as you can see, I’ve created TOKEN variable, which uses previous request. And then I use this variable in the usersFindById request.</p><p>Also I provide default value for id variable via id={1:-1} , so if it is undefined it would be equal to 1 .</p><p>I get this output:</p><pre>{<br>  &quot;id&quot;: 1,<br>  &quot;username&quot;: &quot;frog&quot;,<br>  &quot;email&quot;: &quot;<a href="/service/mailto:welldan97@gmail.com">frog@example.com</a>&quot;<br>}</pre><p>And then adding more and more requests I get a neat file, which I can use anytime for debugging.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-eoc110ZgVT6irj6ZFqvSg.png" /><figcaption>./requests</figcaption></figure><h3>Conclusions</h3><p>There is a reliable and easy way to use command line to test your API requests. And there are several benefits in doing so:</p><ul><li>You can use your favorite editor;</li><li>You can use variables and settings;</li><li>It’s universal way, and can be sent to your coworkers, or shared on github;</li><li>You don’t have to rely on 3rd parties, which may shut down one day;</li><li>You can automate it the way you want it;</li></ul><p>I wish you some joyful coding session and robust APIs in your hands . See you next time!█</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=463803304620" width="1" height="1" alt=""><hr><p><a href="https://medium.com/beadlist/using-curl-for-api-testing-463803304620">Using curl for API testing</a> was originally published in <a href="https://medium.com/beadlist">BeadList</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Music from your Terminal]]></title>
            <link>https://medium.com/beadlist/music-from-your-terminal-132f96720e24?source=rss-a3396049e11c------2</link>
            <guid isPermaLink="false">https://medium.com/p/132f96720e24</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[music]]></category>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[apps]]></category>
            <dc:creator><![CDATA[Dmitry Yakimov]]></dc:creator>
            <pubDate>Thu, 15 Nov 2018 15:10:20 GMT</pubDate>
            <atom:updated>2018-11-15T15:10:20.890Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gHZBANspeCHA-DLVBUftDA.png" /></figure><p>What people use in 2018? No, seriously what is popular these days? What apps are you using for listening music? I am on old bear in a town, and I remember apps for listening music were changing fast back then, faster than the chat applications. There were always new players which were hotter, and back then I was using the following the trends.</p><p>But now, I don’t care. It’s not that I don’t care about music, I do and a lot. I still need to have my flacs around and I need good music in a good quality. It’s just that now I don’t care about the players anymore, because looks like I found the best one. There is nothing can beat command line, it was here, and it’s going to be here, hopefully till the end of my life.</p><p>I was never fan of categorizing music by artists and styles and so on. This trend among players became popular early on. And back then players were making a lot of mistakes in categorizing. I am the responsible one, so I just like to categorize the musics myself by the directories on my computer. And then play &amp; mix them the way I want. That’s also why I got disappointed by the modern apps.</p><p>So what is the app which makes my life beautiful every day. It is actually good old VLC! I’ve discovered that it has terminal interface few years ago and it just sticked. There is nothing wrong with it. It’s simple, it works, it can play any types of music. It’s just perfect. And in combination with <a href="https://en.wikipedia.org/wiki/Ranger_(file_manager)">ranger</a> it becomes even more handy. Just look:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*_OhWiFg6DVtxuDf5OvQ3Fg.gif" /><figcaption>VLC + ranger</figcaption></figure><p>In order to run it on your Mac you would need to install VLC. You can do it via brew:</p><pre>brew cask install vlc</pre><p>And to open the player in command line mode you would need to run:</p><pre>/Applications/VLC.app/Contents/MacOS/VLC -I ncurses --no-color file.mp3</pre><p>Flag --no-color makes interface less funky. There are many other useful flags. And you can also play whole directories these way.</p><p>Apart from that you can always create a shorthand for this command and define keybindings for your shell or ranger to run it.</p><p>To control the player most of the time you would want to know these keys:</p><ul><li>↑, ↓ — navigation between tracks</li><li>space — pause/play</li><li>enter — play track under cursor</li><li>q — quit</li><li>h — the list of hotkeys.</li></ul><p>Here is the whole list of hotkeys of VLC:</p><pre>[Display]<br>h,H         Show/Hide help box<br>i           Show/Hide info box<br>L           Show/Hide messages box<br>P           Show/Hide playlist box<br>B           Show/Hide filebrowser<br><br>[Global]<br>q, Q        Quit<br>s           Stop<br>&lt;space&gt;     Pause/Play<br>f           Toggle Fullscreen<br>n, p        Next/Previous playlist item<br>[, ]        Next/Previous title<br>&lt;, &gt;        Next/Previous chapter<br>&lt;right&gt;     Seek +1%<br>&lt;left&gt;      Seek -1%<br>a           Volume Up<br>z           Volume Down<br><br>[Playlist]<br>r           Random<br>l           Loop Playlist<br>R           Repeat item<br>o           Order Playlist by title<br>O           Reverse order Playlist by title<br>/           Look for an item<br>A           Add an entry<br>D, &lt;del&gt;    Delete an entry <br>&lt;backspace&gt; Delete an entry<br><br>[Filebrowser]<br>&lt;enter&gt;     Add the selected file to the playlist<br>&lt;space&gt;     Add the selected directory to the playlist<br>.           Show/Hide hidden files<br><br>[Boxes]<br>&lt;up&gt;,&lt;down&gt;     Navigate through the box line by line<br>&lt;pgup&gt;,&lt;pgdown&gt; Navigate through the box page by page<br><br>[Player]<br>&lt;up&gt;,&lt;down&gt;     Seek +/-5%<br><br>[Miscellaneous]<br>Ctrl-l          Refresh the screen</pre><p>I wish you some joyful coding session and some good tunes in your ears. See you next time!█</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=132f96720e24" width="1" height="1" alt=""><hr><p><a href="https://medium.com/beadlist/music-from-your-terminal-132f96720e24">Music from your Terminal</a> was originally published in <a href="https://medium.com/beadlist">BeadList</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Helicopter system]]></title>
            <link>https://medium.com/beadlist/introducing-helicopter-system-fc9aefc0ce99?source=rss-a3396049e11c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc9aefc0ce99</guid>
            <category><![CDATA[keyboard-shortcuts]]></category>
            <category><![CDATA[vim]]></category>
            <category><![CDATA[atom]]></category>
            <category><![CDATA[keyboard]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Dmitry Yakimov]]></dc:creator>
            <pubDate>Thu, 08 Nov 2018 15:23:03 GMT</pubDate>
            <atom:updated>2018-11-08T15:23:03.633Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*osqlw4EnHML2QRZzRS3yBg.png" /><figcaption>Helicopter keyboard</figcaption></figure><p>More than a year ago I switched my main editor from Emacs to Atom. It’s nice and fast enough this day. It is a magnificent piece of software. It is the new better Emacs.</p><p>And I was happy with this switch, I’ve even installed <a href="https://atom.io/packages/atomic-emacs">atomic-emacs</a> package to make transition smoother. But then I thought: hmm, since I’m switching an editor, I might try to switch my keymap as well. Because Emacs keybindings don’t make much sense. So I’ve tried the default ones.</p><p>But I wasn’t completely happy with it. Then I tried vim-mode, and I wasn’t satisfied either. Just because of the keys placement and the need to switch the modes. So I decided that’s it! It’s time to make a keymap which makes sense. And I made a quick draft how I thought it should be.</p><p>Then I have been using it for over a year, adding more and more keybindings over time, making it more sophisticated, changing the location of keys. I must admit I was pretty satisfied with it. But adding new keybindings to keymap file became a hassle. My system overgrew the supported technology. So I wrapped it into the package, tuned here and released it. You can check it on github <a href="https://github.com/welldan97/atom-helicopter">here</a>. I’ll just share the points from there here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-1aL7ZMAxBzVlh4poo8fSg.png" /><figcaption>Helicopter keymap</figcaption></figure><p>To make Helicopter system effective and powerful it is based on top of a few core principles.</p><h3>1. Composability</h3><p>One of the main goals of the project is to give a composable way to define keystrokes in a way that it would be mentally easy to learn them. Each keystroke consists of 2 main elements — <em>method</em> and <em>argument</em>. The left hand is responsible for <em>methods</em> and the right hand is responsible for its <em>arguments</em>.</p><p>You can see a few examples of resulting keybindings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y0SkhPpASo21EkAmwIvtoQ.png" /></figure><p>The defined keymap works via regular key events, there is no need for entering mode, like in vim. Although, mode as an addition might be added in a future.</p><p>You can see the whole keymap <a href="https://github.com/welldan97/atom-helicopter/blob/master/keymap.md">here</a>.</p><h3>2. Ergonomics &amp; Semantics</h3><p>All the keystrokes are defined with ergonomics in mind. The navigation keys lie literaly at your fingertips. And the more common the action you want make the easier it is to access.</p><p>Each key has a semantics behind it. So you don’t have to memorize all the weird keybindings, you just have to the remember base keys and next time you use it you will feel that it make sense. Many times you are going to guess the keybindings without ever using them.</p><p>The whole list of user experience principles you can see <a href="https://github.com/welldan97/atom-helicopter/blob/master/ux_principles.md">here</a></p><h3>3. Different keyboard layouts support</h3><p>From the day one we have a support for different keyboard layouts. No matter which keyboard layout you use, the keys stay at the same place. Me myself using programmer dvorak, I see how it can be important to have support for different keyboards.</p><h3>4. Customizability</h3><p>All the keybindings should be customizable. If the defaults don’t make sense for you, you would be able to change it. If you want to have the search button on another key — you should be able to do it. And of course nothing stops you to define your own keybindings in a usual way.</p><p>You can see how the keybindings structured <a href="https://github.com/welldan97/atom-helicopter/blob/master/lib/keys.js">here</a>. And <a href="https://github.com/welldan97/atom-helicopter/blob/master/lib/statements.js">here</a> is a resolving file for actions.</p><h3>5. Scalability</h3><p>Helicopter is not just a keymap, it is actually a system to define one. It gives you an ability to add new <em>methods</em> and <em>arguments</em> easily. There are still a lot of unbound keys left. So you can add support for your favorite packages without a problem.</p><p>Right now it can be used only on Atom. But it’s in the plans to support other platform too.</p><p>Helicopter system is still work in progress and it’s lacking many things, indeed. But it proved to be useful already. Anyways, developing a keymap system is a journey, and it’s an interesting one. And If you are the one who would want to make this journey together, join the <a href="https://github.com/welldan97/atom-helicopter">project</a>, and let’s rock the boat!█</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc9aefc0ce99" width="1" height="1" alt=""><hr><p><a href="https://medium.com/beadlist/introducing-helicopter-system-fc9aefc0ce99">Introducing Helicopter system</a> was originally published in <a href="https://medium.com/beadlist">BeadList</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Function Zoo: Part 3— Command, Overloading, Currying]]></title>
            <link>https://medium.com/beadlist/function-zoo-part-3-command-overloading-currying-9668d86376d?source=rss-a3396049e11c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9668d86376d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[patterns]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[function]]></category>
            <dc:creator><![CDATA[Dmitry Yakimov]]></dc:creator>
            <pubDate>Thu, 01 Nov 2018 16:23:39 GMT</pubDate>
            <atom:updated>2018-11-08T15:08:56.634Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aTHqkN8cR6WsbkYi2fxT_Q.png" /><figcaption>Function Zoo</figcaption></figure><h3>Function Zoo: Part 3 — Command, Overloading, Currying</h3><p><a href="https://medium.com/@welldan97/function-zoo-part-1-common-types-439f7650663e">Part </a>1 — <a href="https://medium.com/@welldan97/function-zoo-part-2-function-as-a-sent-message-6144de47d2a2">Part 2</a> — Part 3</p><p>This is the next article on function extensions. And today we are going to talk about command pattern and 2 arguments extensions: overloading and currying.</p><h3>7. Command</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*C9wLnG8GrXXOjvL5v5HTWQ.png" /></figure><p>Last time we compared function execution to a sending of a message. And we discussed that the objects name and the methods name are recipient address, and then the arguments is the body of a message.</p><p>Now with that in mind, we can also pass the methods name as anargument. Well, actually it’s pretty simple, it would work like this: let’s say we have a generic method send which accepts methods name and the rest of arguments. Then the code would look like this:</p><pre>const Zoo = {<br>  // Regular methods<br>  getAnimal(type, color) {<br>    const animals = {<br>      Frog: {<br>        &#39;Infra Red&#39;: &#39;ir_frog.jpg&#39;,<br>        &#39;Caribbean Green&#39;: &#39;cr_frog.jpg&#39;,<br>      },<br>      Fish: {<br>        &#39;Infra Red&#39;: &#39;ir_fish.jpg&#39;,<br>        &#39;Caribbean Green&#39;: &#39;cr_fish.jpg&#39;,<br>      },<br>    };<br>    return animals[type][color];<br>  },</pre><pre>getColors() {<br>    return [&#39;Infra Red&#39;, &#39;Caribbean Green&#39;];<br>  },</pre><pre>getTypes() {<br>    return [&#39;Frog&#39;, &#39;Fish&#39;];<br>  },</pre><pre>send(methodName, ...arguments) {<br>    return this[methodName](...arguments);<br>  },<br>};</pre><pre>console.log(Zoo.send(&#39;getTypes&#39;));<br>// =&gt; [ &#39;Frog&#39;, &#39;Fish&#39; ]<br>console.log(Zoo.send(&#39;getAnimal&#39;, &#39;Fish&#39;, &#39;Infra Red&#39;)); <br>// =&gt; &#39;ir_fish.jpg&#39;</pre><p>This is called <a href="https://en.wikipedia.org/wiki/Command_pattern">Command Pattern</a>. This can be useful in many circumstances. When you are developing UI, it can be used for creating undo/redo buttons, when you want to log all the actions which has been called. Actually even Redux is based around command pattern as well.</p><p>Now with ES6 Proxy you can make command pattern look nicer:</p><pre>const nextZoo = new Proxy(Zoo, {<br>  get(target, propKey) {<br>    console.log(propKey);<br>    return target[propKey];<br>  },<br>});</pre><pre>console.log(nextZoo.getColors());<br>// =&gt; getColors<br>// =&gt; [ &#39;Infra Red&#39;, &#39;Caribbean Green&#39; ]</pre><h3>8. Overloaded Function</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*TxZ6y2ryPMxIWs2w_-5pTg.png" /></figure><p>Function overloading is a way to enhance functions by allowing them to accept different types of arguments. And then dependent on the type of the argument it acts differently.</p><p>For example, let’s say we have a function which calculates squares of numbers, like this:</p><pre>function numberSquare(number) {<br>  return number * number;<br>}<br>console.log(numberSquare(2)); // =&gt; 4</pre><p>Now if we would want to have a function which could also calculate squares each number of array, we could do it like this:</p><pre>function arraySquare(array) {<br>  return array.map(numberSquare);<br>}</pre><pre>function square(numberOrArray) {<br>  if (Array.isArray(numberOrArray)) <br>    return arraySquare(numberOrArray);<br>  else <br>    return numberSquare(numberOrArray);<br>}</pre><pre>console.log(square(2)); // =&gt; 4<br>console.log(square([1, 2, 3])); // =&gt; [ 1, 4, 9 ]</pre><p>In most cases I like to keep functions as simple as possible and I let them accept just one type of arguments. It is beneficial for minimizing maintenance costs and overall performance. So, generally function overloading is not recommended. Although in some cases it can be very useful, especially for recursive functions, when you destructure objects and arrays.</p><h3>9. Curried Function</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*GaPExEndO6FcxMidELErXQ.png" /></figure><p>Curried functions were already discussed by everyone a lot. For people who missed it, basically curried functions allow to accept arguments one at a time. In a simple case it works like this:</p><pre>function multiply(a, b) {<br>  if (b) return a * b;<br>  return function(b) {<br>    return a * b;<br>  };<br>}</pre><pre>const double = multiply(2);</pre><pre>console.log(multiply(2, 3)); // =&gt; 6<br>console.log(multiply(2)(3)); // =&gt; 6<br>console.log(double(3)); // =&gt; 6</pre><p>Curried functions are nice and could be useful in rare cases. But generally they are just too much hassle to create, so it’s not very recommended to use them. They would be worthy though if they would be supported on the language level.</p><p>On this I conclude my series of articles on functions enhancement patterns. If anyone reads it, let me know if you have some other function types ideas.</p><p>Good luck with your coding adventures, folks! █</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9668d86376d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/beadlist/function-zoo-part-3-command-overloading-currying-9668d86376d">Function Zoo: Part 3— Command, Overloading, Currying</a> was originally published in <a href="https://medium.com/beadlist">BeadList</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Function Zoo: Part 2 — Function as a sent message]]></title>
            <link>https://medium.com/beadlist/function-zoo-part-2-function-as-a-sent-message-6144de47d2a2?source=rss-a3396049e11c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6144de47d2a2</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[function]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[patterns]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Dmitry Yakimov]]></dc:creator>
            <pubDate>Thu, 25 Oct 2018 18:04:15 GMT</pubDate>
            <atom:updated>2018-11-01T16:42:18.216Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AeQ4ktIDvpDNpGWkFtRyvA.png" /><figcaption>Function Zoo</figcaption></figure><h3>Function Zoo: Part 2 — Function as a sent message</h3><p><a href="https://medium.com/@welldan97/function-zoo-part-1-common-types-439f7650663e">Part </a>1 — Part 2 — <a href="https://medium.com/@welldan97/function-zoo-part-3-command-overloading-currying-9668d86376d">Part 3</a></p><p>Today we are going to look at functions as a way of sending messages from one object to another. And in this article we are going to focus more on the expected outcomes of the function execution.</p><p>You can look at functions from the perspective of sending messages between the objects. It’s very similar to messages exchange via email, or messenger apps. Basically you have an address of a recipient, and you have some text you are sending. In case of function your object and its method name would be the recipient address, and its arguments would be the message text.</p><p>Then with this in mind, we can have 3 types of messages we can send to objects:</p><ol><li>Messages without answer expected;</li><li>Messages with immediate answer;</li><li>Messages with delayed answer.</li></ol><p>And based of these types of messages we can have according function types. On that we’ll continue our exploration of the function zoo. The numeration follows the previous article</p><h3>4. Procedure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*hV51pVMs6htnv9kpQ0YpvQ.png" /></figure><blockquote>”Fish,” said the frog, “could you make a cup of fine tea please?”<br>“On my way,” answered the fish.</blockquote><p>Procedure is a function which does not return a value. It’s called in order to execute something. It’s not a pure function, it is there to get useful side-effects: print a document, notify with a message, give an order to you robot, make a screenshot. In terms of messages it is the message without answer.</p><p>How useful the procedures are? Well they can be very useful indeed. Let’s say you have a smart home, then you can tell it to turn off the light. And normally you don’t want any answers from it, you would just want it to do it. And it might have some API going on, and then you could call it via JS like this: SmartHome.turnOffTheLight() .</p><p>That’s pretty good. But actually you can write the whole application using just procedures. If they just know where to send answers they can function like a fully functional functions(pun intended). The code would not be nice then, but it would work. Let’s see in example.</p><pre>const Zoo = {<br>  // Procedure definition<br>  getAnimal(type, color, destination) {<br>    const animals = {<br>      Frog: {<br>        &#39;Infra Red&#39;: &#39;ir_frog.jpg&#39;,<br>        &#39;Caribbean Green&#39;: &#39;cr_frog.jpg&#39;,<br>      },<br>      Fish: {<br>        &#39;Infra Red&#39;: &#39;ir_fish.jpg&#39;,<br>        &#39;Caribbean Green&#39;: &#39;cr_fish.jpg&#39;,<br>      },<br>    };</pre><pre>    destination.receiveAnimal(animals[type][color]);<br>  },<br>};</pre><pre>const Receiver = {<br>  animals: [],<br>  execute() {<br>    // Procedure execution<br>    Zoo.getAnimal(&#39;Frog&#39;, &#39;Caribbean Green&#39;, this);<br>    Zoo.getAnimal(&#39;Fish&#39;, &#39;Infra Red&#39;, this);<br>  },</pre><pre>receiveAnimal(animal) {<br>    this.animals.push(animal);<br>  },<br>};</pre><pre>Receiver.execute();<br>console.log(Receiver.animals);<br>// =&gt; [ &#39;cr_frog.jpg&#39;, &#39;ir_fish.jpg&#39; ]</pre><p>As you can see, you can still do pretty powerful things with procedures. Actually this code reminds <a href="https://en.wikipedia.org/wiki/Visitor_pattern">Visitor Pattern</a> a lot. Also in this code, you could be calling destination.receiveAnimal several times. These way it is very similar to real messengers conversation. And from this example you can have a feel of seeing functions as messages between the objects.</p><h3>Basic function</h3><blockquote>”Fish,” said the frog, “what is your favorite painting?”<br>“Composition VIII, by Kandinsky,” answered the fish.</blockquote><p>Here we come back to the basic function. Since it was already discussed in a previous article let’s say where it stands in terms of return value.</p><pre>function getAnimal(type, color) {<br>  const animals = {<br>    Frog: {<br>      &#39;Infra Red&#39;: &#39;ir_frog.jpg&#39;,<br>      &#39;Caribbean Green&#39;: &#39;cr_frog.jpg&#39;,<br>    },<br>    Fish: {<br>      &#39;Infra Red&#39;: &#39;ir_fish.jpg&#39;,<br>      &#39;Caribbean Green&#39;: &#39;cr_fish.jpg&#39;,<br>    },<br>  };<br>  return animals[type][color];<br>}</pre><pre>console.log(getAnimal(&#39;Frog&#39;, &#39;Caribbean Green&#39;));<br>// =&gt; &#39;cr_frog.jpg&#39;</pre><p>As you can see it could be a message with immediate answer, since it returns the value immediately. They are very handy and good for any fast computations.</p><h3>5. Async function</h3><blockquote>”Fish,” said the frog, “what is your favorite composer?”<br>“My favorite composer is Ludovico Einaudi,” said the fish, after a few minutes of thought.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*qYt_84Ggh9_6u4nj8HILEg.png" /></figure><p>As you’ve already guessed async function is the next in our list. It is the message with delayed answer. Once asked, you don’t wait for an answer. And an answer can come back any time. It’s like sending an email. May be the answer won’t even come. Although that is not really expected in the code.</p><pre>function later(value) {<br>  return new Promise((resolve, reject) =&gt;<br>    setTimeout(() =&gt; resolve(value), 1000),<br>  );<br>}</pre><pre>async function getAnimal(type, color) {<br>  const animals = {<br>    Frog: {<br>      &#39;Infra Red&#39;: &#39;ir_frog.jpg&#39;,<br>      &#39;Caribbean Green&#39;: &#39;cr_frog.jpg&#39;,<br>    },<br>    Fish: {<br>      &#39;Infra Red&#39;: &#39;ir_fish.jpg&#39;,<br>      &#39;Caribbean Green&#39;: &#39;cr_fish.jpg&#39;,<br>    },<br>  };<br>  return await later(animals[type][color]);<br>}</pre><pre>async function receiveAnimal() {<br>  console.log(await getAnimal(&#39;Frog&#39;, &#39;Caribbean Green&#39;));<br>  // =&gt; &#39;cr_frog.jpg&#39; (after 1s)<br>  console.log(await getAnimal(&#39;Fish&#39;, &#39;Infra Red&#39;));<br>  // =&gt; &#39;ir_fish.jpg&#39; (after 1s)<br>}<br>receiveAnimal();</pre><p>The interesting thing about async/await is that — no matter how it is called the return value always come back to the same place in the code. It’s like sending a mail with a correct return address, from the place where it was actually sent.</p><p>Although this property is limiting, it’s also very comfortable and leads to cleaner nicer looking code.</p><h3>6. Function with callback</h3><blockquote>”Fish,” said the frog, “what is your favorite film?”<br>“Oldboy.” said the fish, “No wait! It’s a Revolver. It’s definitely Revolver,” repeated the fish.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*XF_CI1TTLy9P3tR040nj4w.png" /></figure><p>So where the function with callback stands in our list. Well interestingly it’s a special beast. It is normally expected to return a value in a delayed manner, but also it can return a value immediately.</p><p>And compared to async function it doesn’t have to return a value back to the code where it was called it can send it to a totally new place, as long as it has an address for it. It’s like a mail sent with a different return address or an email which faked the sender.</p><p>Just have a look at this example to proof these two points:</p><pre>import { otherReceiver } from &#39;./otherZoo&#39;;</pre><pre>function later(value, cb) {<br>  setTimeout(() =&gt; cb(value), 1000);<br>}</pre><pre>function getAnimal(type, color, cb) {<br>  const animals = {<br>    Frog: {<br>      &#39;Infra Red&#39;: &#39;ir_frog.jpg&#39;,<br>      &#39;Caribbean Green&#39;: &#39;cr_frog.jpg&#39;,<br>    },<br>    Fish: {<br>      &#39;Infra Red&#39;: &#39;ir_fish.jpg&#39;,<br>      &#39;Caribbean Green&#39;: &#39;cr_fish.jpg&#39;,<br>    },<br>  };<br>  later(animals[type][color], cb);<br>  return &#39;immediate return value&#39;;<br>}</pre><pre>// Use return value in the same place<br>console.log(<br>  getAnimal(<br>    &#39;Frog&#39;, <br>    &#39;Caribbean Green&#39;, <br>    value =&gt; console.log(value)<br>  )<br>);<br>// =&gt; &#39;immediate return value&#39;<br>// =&gt; &#39;cr_frog.jpg&#39; (after 1s)</pre><pre>// send return value to another place<br>getAnimal(&#39;Frog&#39;, &#39;Caribbean Green&#39;, otherReceiver);</pre><p>Also functions with callbacks can call them several times, which can be useful in some cases. And it can bizarre in others.</p><p>As you can see functions with callbacks are very powerful indeed. But it’s also easy to get them wrong. That’s why it’s recommended to use them less often.</p><p>Here you go. Now we have discussed more function types over here. I hope you could see functions from a new angle. And I hope that it helped you to understand functions more deeply.</p><p>I wish you some beautiful coding sessions! █</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6144de47d2a2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/beadlist/function-zoo-part-2-function-as-a-sent-message-6144de47d2a2">Function Zoo: Part 2 — Function as a sent message</a> was originally published in <a href="https://medium.com/beadlist">BeadList</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Function Zoo: Part 1 — Common types]]></title>
            <link>https://medium.com/beadlist/function-zoo-part-1-common-types-439f7650663e?source=rss-a3396049e11c------2</link>
            <guid isPermaLink="false">https://medium.com/p/439f7650663e</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[patterns]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[function]]></category>
            <dc:creator><![CDATA[Dmitry Yakimov]]></dc:creator>
            <pubDate>Sun, 14 Oct 2018 21:50:22 GMT</pubDate>
            <atom:updated>2018-11-01T16:42:57.909Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*giGfifQkX0CC9nEadJy1yQ.png" /><figcaption>Function Zoo</figcaption></figure><h3>Function Zoo: Part 1 — Common types</h3><p>Part 1 —<a href="https://medium.com/@welldan97/function-zoo-part-2-function-as-a-sent-message-6144de47d2a2"> Part 2</a> — <a href="https://medium.com/@welldan97/function-zoo-part-3-command-overloading-currying-9668d86376d">Part 3</a></p><p>Let’s talk about functions in JavaScript. And let’s look at them differently this time. Let’s forget about functional programming and let’s see them from a different angle. I want to talk about function enhancing patterns, how you can make them even more potent, give them an edge, give them new abilities, empower or diminish them. And let’s see how this can be useful.</p><h3>1. Hash table (not a function yet)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*gd4vxKjIqNQV3GiuGSDYwQ.png" /></figure><p>This happens all the time. When you need just to map values, you don’t really want to implement the function, you want a hash table .</p><pre>const animals = {<br>  Frog: &#39;frog.jpg&#39;,<br>  Fish: &#39;fish.jpg&#39;,<br>}</pre><pre>animals.Frog // =&gt; frog.jpg</pre><p>As you can see, you have to address the animal picture like this animals.Frog which is the same as animals[&#39;Frog&#39;] , and it’s very similar to getAnimal(&#39;Frog&#39;) . In a way it looks like a syntactic sugar over the function declaration. And it is nice: brackets give you more accurate representation of what you actually want to do — to get an item from the collection. There is a semantic accent in it, so animals[&#39;Frog&#39;] looks better than let’s say animals(&#39;Frog&#39;) . And in fact, in some programming languages the second syntax is used.</p><p>But then if you want to add second argument, you have to create deeper hashes:</p><pre>const animals = {<br>  Frog: {<br>    &#39;Infra Red&#39;: &#39;ir_frog.jpg&#39;,<br>    &#39;Caribbean Green&#39;: &#39;cr_frog.jpg&#39;,<br>  },<br>  Fish: {<br>    &#39;Infra Red&#39;: &#39;ir_fish.jpg&#39;,<br>    &#39;Caribbean Green&#39;: &#39;cr_fish.jpg&#39;,<br>  }<br>}</pre><pre>animals.Frog[&#39;Caribbean Green&#39;] // =&gt; cr_frog.jpg</pre><p>Then the second level takes a role of the second argument:</p><p>animals[&#39;Frog&#39;][&#39;Caribbean Green&#39;]</p><p>The good thing about hash tables is their simplicity, they are perfect for mapping keys to values — one layer of definitions to another.</p><p>But they are also very limiting indeed.</p><ol><li>Well, first of all, the arguments list is a fixed set of strings or numbers. Where the function can accept any unlimited variations of different types of arguments</li><li>The error handling is predefined. When you try to get the wrong keys, you’ll get either undefined or TypeError . You might want it customize it in some way.</li><li>Hash tables can bring code duplication if abused.</li></ol><p>So the first thing you do to get more powerful constructions than hash tables, you wrap it into a function.</p><h3>2. Basic function</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*-GECaN2imqIg57qOeIGuuA.png" /></figure><p>Let’s wrap our previous example into a basic function.</p><pre>function getAnimal(type, color) {<br>  return animals[type][color];<br>}</pre><p>This way it already becomes more powerful. You can add error handling here, and you can make some additional data manipulation. These types of function you create all the time.</p><h3>3. Function with the state(closure)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*t2xrtTHEhxQ7qqKRoiuTnw.png" /></figure><p>In JavaScript you can create functions which can hold the state. They are usually called closures or functors. It works like this:</p><pre>function createCounter() {<br>  let i = 0;<br>  return function() {<br>    i = i + 1;<br>    return i;<br>  };<br>}</pre><pre>const counter = createCounter();<br>counter(); // =&gt; 1<br>counter(); // =&gt; 2<br>counter(); // =&gt; 3</pre><p>I try to avoid these types of functions, because they are not pure, and they can bring troubles during testing and repetitive runs. If you use this kind of functions, it’s usually a good idea to have a way to reset their state.</p><pre>function createCounter() {<br>  let i = 0;<br>  return function(initialValue) {<br>    if (initialValue !== undefined) i = initialValue;<br>    i = i + 1;<br>    return i;<br>  };<br>}<br>const counter = createCounter();<br><br>counter();  // =&gt; 1<br>counter();  // =&gt; 2<br>counter(0); // =&gt; 1<br>counter();  // =&gt; 2</pre><p>These types of functions can be useful for generating cross-application unique ids, like lodash uniqueId .</p><p>Over here we talked about some very common function types. Next time we are going to look at something more interesting. Happy coding, amigos!█</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=439f7650663e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/beadlist/function-zoo-part-1-common-types-439f7650663e">Function Zoo: Part 1 — Common types</a> was originally published in <a href="https://medium.com/beadlist">BeadList</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I read “Anarconomy”]]></title>
            <link>https://medium.com/@welldan97/i-read-anarchonomy-33b972980998?source=rss-a3396049e11c------2</link>
            <guid isPermaLink="false">https://medium.com/p/33b972980998</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[3d-printing]]></category>
            <category><![CDATA[books]]></category>
            <category><![CDATA[anarchism]]></category>
            <dc:creator><![CDATA[Dmitry Yakimov]]></dc:creator>
            <pubDate>Wed, 03 Oct 2018 23:04:15 GMT</pubDate>
            <atom:updated>2018-10-03T23:14:54.381Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l4kH9qbKhd0s2faWLy0mHg.png" /></figure><p>“Anarconomy” is a report by Copenhagen Institute for Futures Studies released in 2009. Pretty interesting that such organization exists — Institute for Futures Studies! And looks like they are doing some good stuff.</p><p>The report itself was also released by Russian publishing company “Ultra.Kultura” as a book. And by now I own the full collection of the books published by the company, so it is there I saw this book with juicy cover, and I read it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*HBFabsJDH9LjYakcyJXhfA.png" /></figure><p>Although the report itself dates 2009, the information in it is actual as never before. In the modern world when Big Co keep screwing up, and Big Bro is watching us, the need for distributed fair world has became the only sane way of human development. And the report talks about it, about digital anarchy and the possible economy in it. And where else such report could come from if not from the Denmark the homeland of Freetown Christiania.</p><p>In preface it states:</p><blockquote>We are witnessing a pronounced flourishing of free content and services on the internet. this content is created and distributed by the users themselves in voluntary networks according to rather anarchic principles: Wikipedia, open source software, books, music, films and design, which the creators make freely available, are all examples of this phenomenon. all of this challenges and supplements traditional commercial companies by offering non-commercial alternatives. this is the anarconomy. in the future, anarconomy will move from the internet and radically change economy in the physical world</blockquote><p>The report talks about open source, 3d printing, licences, and economy for the companies in the times. Also it shows 2 possible scenarios of the world development, one is anti-utopian corporate dictatorship, and another one is very optimistic all mighty free world. Of course they say that the real future would be somewhere in between.</p><p>The report is short, easy to read and it is inspiring indeed.</p><p>Apart from that, there is a note in it about electronics in plastic, which makes it possible to 3d print computers in the future. And I didn’t even know that plastic can conduct electricity. So if you are in the same boat as me, living under the rock: Alan Heeger received Nobel Prize in 2000 for the discovery of conducting polymers, which made plastic electronics possible.</p><p>Just imagine, may be soon enough you’ll be able to download a computer on your computer and print it on your 3d printer. And of course in this bright future, this computer model just has to be open source.</p><p>Good luck, fellows.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33b972980998" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[One Simple Delivery]]></title>
            <link>https://medium.com/beadlist/one-simple-delivery-c5238bc44214?source=rss-a3396049e11c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5238bc44214</guid>
            <category><![CDATA[process-improvement]]></category>
            <category><![CDATA[kanban]]></category>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[kaizen]]></category>
            <dc:creator><![CDATA[Dmitry Yakimov]]></dc:creator>
            <pubDate>Mon, 30 Jul 2018 21:33:32 GMT</pubDate>
            <atom:updated>2018-07-30T21:33:32.488Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s say you are working on some project, which has got it’s own process. And you keep wondering how much time is actually getting lost during on it. How efficient it is. How much of the time get wasted on bureaucracy and how much is actually spent on the valuable things.</p><p>Ok, what you can do is try to measure things, and that’s how you can do it. Make just one simple change and see how it goes. You can start with a real task, or you can just make it up in a sake of making it. For example if you are working with react you can add one simple component in the code.</p><p>So what can be the story of one simple delivery:</p><h4>Before development:</h4><p>The task has to be communicated somehow. How long does it take to create a card for it. Do you spend extra time on adding labels to it, marking certain checkboxes, moving it from column to column.</p><p>Then it is gets idle there for some time. How long does it take to get it acted upon, how long it waits in a backlog.</p><h4>Development:</h4><p>Let’s say developer has taken the card. How long does it takes to understand it. How long does it takes to make all the rituals before writing code: marking card as taken, moving it from column to column, updating repo, creating branch for it. How long does it takes to start the project. How long did it take to actually implement the feature. How long did it take to fix tests and linting errors, adjust project specific code style before pushing, you do that right? And then again all the rituals with the cards.</p><h4>After development:</h4><p>The code has been written, pushed what else is missing before it gets accepted? CI, Code review, manual testing. And then finally it reaches the main branch.</p><p>So try and measure all these numbers, and see which work is useful and which might be not. May be there is a room for optimization for your team. May be some of the practices are just bothersome.</p><p>Lately I see many small companies using the processes of the big ones. And you know, that they are different. Once your company grow, and I hope it is happening, you have to adjust the process to you team size. The process effective for 1 person might be terrible for 10 people, and useless for 100 people, right? But it seem to work the other way around. If you are working with the team of size of 3, and use process for 30 people or even for 10 people, you might be spending a lot of time on bureaucracy.</p><p>May be you don’t need several branches, may be you don’t need corporative code style, may be you don’t need code documentation, may be you don’t even need the kanban board, the chat might be enough. It all depends on your particular case.</p><p>Choose wisely.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5238bc44214" width="1" height="1" alt=""><hr><p><a href="https://medium.com/beadlist/one-simple-delivery-c5238bc44214">One Simple Delivery</a> was originally published in <a href="https://medium.com/beadlist">BeadList</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>