<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Maciek Chmura</title>
    <description>The latest articles on Forem by Maciek Chmura (@maciekchmura).</description>
    <link>https://forem.com/maciekchmura</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F61611%2F00aa469e-2ff1-4021-9dc7-b4507300185d.jpg</url>
      <title>Forem: Maciek Chmura</title>
      <link>https://forem.com/maciekchmura</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/maciekchmura"/>
    <language>en</language>
    <item>
      <title>Check events fired while interacting with a DOM element</title>
      <dc:creator>Maciek Chmura</dc:creator>
      <pubDate>Tue, 14 Jul 2020 11:08:35 +0000</pubDate>
      <link>https://forem.com/maciekchmura/check-events-fired-while-interacting-with-a-dom-element-d16</link>
      <guid>https://forem.com/maciekchmura/check-events-fired-while-interacting-with-a-dom-element-d16</guid>
      <description>&lt;p&gt;There is an easy way of monitoring all events fired while interacting with a DOM element.&lt;/p&gt;

&lt;p&gt;Open dev tools and select element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wfRuRjdu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wqfr6h7izia9t2bz9rcx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wfRuRjdu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wqfr6h7izia9t2bz9rcx.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While the element is selected, switch to console and type: &lt;code&gt;monitorEvents($0)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HYwain5z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i7i9yhyhdhajwktoadm0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HYwain5z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i7i9yhyhdhajwktoadm0.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Interact with the element: hover, click, etc.&lt;br&gt;
The console should print all the events fired.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lURLGOes--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qia15k82ykfbdxtylcqi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lURLGOes--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qia15k82ykfbdxtylcqi.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>dom</category>
      <category>event</category>
      <category>log</category>
    </item>
    <item>
      <title>Sequelize decimal type error</title>
      <dc:creator>Maciek Chmura</dc:creator>
      <pubDate>Wed, 26 Feb 2020 21:29:43 +0000</pubDate>
      <link>https://forem.com/maciekchmura/sequelize-decimal-type-error-7c3</link>
      <guid>https://forem.com/maciekchmura/sequelize-decimal-type-error-7c3</guid>
      <description>&lt;p&gt;Sequelize is probably the most popular ORM for Express. It helped me to quickly start with a NodeJS server and a Postgres database in my current side project.&lt;br&gt;
Unfortunately I encountered a strange issue when I wanted to introduce decimal numbers to one of my models.&lt;/p&gt;

&lt;p&gt;Sequelize in version 5.21.3 has an error with decimal type.&lt;/p&gt;

&lt;p&gt;My model looked like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sequelize&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;DataTypes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;incomeExpense&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;incomeExpense&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DataTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;primaryKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;autoIncrement&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DataTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DECIMAL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DataTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STRING&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DataTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DATEONLY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DataTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STRING&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;freezeTableName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;incomeExpense&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;associate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;incomeExpense&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;belongsTo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stage&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;incomeExpense&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Data in Postgres:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;id&lt;/th&gt;
&lt;th&gt;value&lt;/th&gt;
&lt;th&gt;description&lt;/th&gt;
&lt;th&gt;date&lt;/th&gt;
&lt;th&gt;type&lt;/th&gt;
&lt;th&gt;stageId&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;120.00&lt;/td&gt;
&lt;td&gt;invoice 1&lt;/td&gt;
&lt;td&gt;2019-11-11&lt;/td&gt;
&lt;td&gt;income&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;120.33&lt;/td&gt;
&lt;td&gt;invoice 2&lt;/td&gt;
&lt;td&gt;2019-11-11&lt;/td&gt;
&lt;td&gt;income&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;JSON response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"120.00"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"invoice 1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2019-11-11"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"income"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2019-11-10T23:00:00.000Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"updatedAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2019-11-10T23:00:00.000Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"stageId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"120.33"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"invoice 2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2019-11-11"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"income"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2020-02-06T16:41:36.868Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"updatedAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2020-02-06T16:41:36.868Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"stageId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The returned &lt;code&gt;value&lt;/code&gt; is a string type.&lt;/p&gt;

&lt;p&gt;I thought that the conversion from a number to a string heppens somewhere in Node or React. As it turns out, it is the model itself. &lt;/p&gt;

&lt;p&gt;Model after changing the &lt;code&gt;value&lt;/code&gt; to &lt;code&gt;DataTypes.FLOAT&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sequelize&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;DataTypes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;incomeExpense&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sequelize&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;incomeExpense&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DataTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;INTEGER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;primaryKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;autoIncrement&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="c1"&gt;// value: DataTypes.DECIMAL(10, 2),&lt;/span&gt;
      &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DataTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;FLOAT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DataTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STRING&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DataTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DATEONLY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;DataTypes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STRING&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;freezeTableName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;incomeExpense&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;associate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// associations can be defined here&lt;/span&gt;
    &lt;span class="nx"&gt;incomeExpense&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;belongsTo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;stage&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;incomeExpense&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Postgres dropped the trailing zeros:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;id&lt;/th&gt;
&lt;th&gt;value&lt;/th&gt;
&lt;th&gt;description&lt;/th&gt;
&lt;th&gt;date&lt;/th&gt;
&lt;th&gt;type&lt;/th&gt;
&lt;th&gt;stageId&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;120&lt;/td&gt;
&lt;td&gt;invoice 1&lt;/td&gt;
&lt;td&gt;2019-11-11&lt;/td&gt;
&lt;td&gt;income&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;120.33&lt;/td&gt;
&lt;td&gt;invoice 2&lt;/td&gt;
&lt;td&gt;2019-11-11&lt;/td&gt;
&lt;td&gt;income&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;And now the &lt;code&gt;value&lt;/code&gt; in response is a number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"invoice 1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2019-11-11"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"income"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2019-11-10T23:00:00.000Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"updatedAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2019-11-10T23:00:00.000Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"stageId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;120.33&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"invoice 2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2019-11-11"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"income"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"createdAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2020-02-06T16:41:36.868Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"updatedAt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2020-02-06T16:41:36.868Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"stageId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This issue is opened, and there is an ongoing discussion:&lt;br&gt;
&lt;a href="https://github.com/sequelize/sequelize/issues/8019"&gt;link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For now, I can't think of a better fix than Changing a &lt;code&gt;DECIMAL&lt;/code&gt; to a &lt;code&gt;FLOAT&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>express</category>
      <category>node</category>
    </item>
    <item>
      <title>How to learn JavaScript</title>
      <dc:creator>Maciek Chmura</dc:creator>
      <pubDate>Mon, 23 Sep 2019 11:25:23 +0000</pubDate>
      <link>https://forem.com/maciekchmura/how-to-learn-javascript-k7o</link>
      <guid>https://forem.com/maciekchmura/how-to-learn-javascript-k7o</guid>
      <description>&lt;p&gt;This is the second post of a series about my path of learning JavaScript.&lt;br&gt;
The last post described my opinion about what not to do while learning JS.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How to learn it then?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I think learning JavaScript has nothing to do with JavaScript.&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fq3twzse0mb9q4nucwpk1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fq3twzse0mb9q4nucwpk1.png" alt="wat"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me explain.&lt;/p&gt;

&lt;p&gt;Just like my Unnamed Friend advised, I needed to learn how to program. &lt;br&gt;
In general.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What are variables, functions, objects, arrays, strings, ints?&lt;/li&gt;
&lt;li&gt;How do computers even work?&lt;/li&gt;
&lt;li&gt;What happens when you type an address to a browser?&lt;/li&gt;
&lt;li&gt;What is a server?&lt;/li&gt;
&lt;li&gt;What is a database?&lt;/li&gt;
&lt;li&gt;Why functions return something?&lt;/li&gt;
&lt;li&gt;What is an algorithm?&lt;/li&gt;
&lt;li&gt;What is a browser API?&lt;/li&gt;
&lt;li&gt;What is AJAX?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A lot of unknowns and no clear starting point, when you just want to make a Todo app in React... 🤦‍♂️&lt;/p&gt;

&lt;p&gt;Luckily there is a starting point. And it is an awesome one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 1: Fundamentals
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ftmp8hxkwixqyxjrk92dy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ftmp8hxkwixqyxjrk92dy.png" alt="CS50"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.edx.org/course/cs50s-introduction-to-computer-science" rel="noopener noreferrer"&gt;CS50&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;An introduction to the intellectual enterprises of computer science and the art of programming.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Taught by David J. Malan &lt;a href="https://twitter.com/davidjmalan" rel="noopener noreferrer"&gt;@davidjmalan&lt;/a&gt; and his team.&lt;/p&gt;

&lt;p&gt;I love this course. I would like to do it again and discover everything one more time 😅&lt;/p&gt;

&lt;p&gt;For each week you will have a lecture by David&lt;br&gt;
(while watching it, your 💡⚡ 'AHAAAAA' light bulb will shine every few minutes).&lt;br&gt;
Followed up by shorter lecture with coding examples.&lt;br&gt;
You finish each week with a coding project and run it through an automatic test.&lt;/p&gt;

&lt;p&gt;You will be exposed to very interesting problems with many technologies.&lt;/p&gt;

&lt;p&gt;Here are the topics that were covered in the scope of this course during my take on it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Week 1: Introduction to programming in C language. Create 2 CLI programs in C.&lt;/li&gt;
&lt;li&gt;Week 2: Big O, Sorting Algorithms, Binary Search, Recursion. Create 2 cyphering CLI programs with C.&lt;/li&gt;
&lt;li&gt;Week 3: Call Stack, Pointers, Dynamic Memory Allocation. Create a program to manipulate images in C&lt;/li&gt;
&lt;li&gt;Week 4: Structures, Custom Types, Singly-Linked Lists, Hash Tables, Tries, Stack, Queues. Create a spell checker in C.&lt;/li&gt;
&lt;li&gt;Week 5: IP, TCP, HTTP, HTML, CSS&lt;/li&gt;
&lt;li&gt;Week 6: Dynamic Programming, Introduction to Python.&lt;/li&gt;
&lt;li&gt;Week 7: Servers, Python and Flask. Create 2 CLI programs in Python.&lt;/li&gt;
&lt;li&gt;Week 8: Flask, MVC, SQL. Implement a stock-trading website.&lt;/li&gt;
&lt;li&gt;Week 9: JavaScript, DOM, Ajax. Implement a news map app.&lt;/li&gt;
&lt;li&gt;Week 10 and 11: Final Project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After completing it you will have a pretty good understanding of what is needed to build an app.&lt;/p&gt;

&lt;p&gt;Suddenly you will not ask: "UGHHHH, why it is coded like that??!!"&lt;br&gt;
And will say: "💡Ahhhh, it is coded like that because..."&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 2: Building
&lt;/h2&gt;

&lt;p&gt;Now you are ready to dig into JavaScript.&lt;br&gt;
And the best way to learn is by building.&lt;br&gt;
Some ideas about what to build:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tic-tac-toe game with vanilla JS&lt;/li&gt;
&lt;li&gt;tic-tac-toe with &lt;a href="https://reactjs.org/tutorial/tutorial.html" rel="noopener noreferrer"&gt;React&lt;/a&gt;
&lt;em&gt;now you know what problems React solve!&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Node backend with a database on &lt;a href="https://www.heroku.com/free" rel="noopener noreferrer"&gt;Heroku&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;React app with data from &lt;a href="https://firebase.google.com/" rel="noopener noreferrer"&gt;Firebase&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Depending on how much time you have for learning, this can take from 6 months to a year.&lt;/p&gt;

&lt;p&gt;Now you have a solid understanding of what programming is about.&lt;br&gt;
You have a handful of completed projects on GitHub.&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 3: Expand your knowledge
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://javascript.info/" rel="noopener noreferrer"&gt;You can dig deeper into JavaScript&lt;/a&gt;. &lt;br&gt;
You can follow this awesome &lt;a href="https://roadmap.sh/" rel="noopener noreferrer"&gt;roadmap&lt;/a&gt; made by &lt;a href="https://twitter.com/kamranahmedse" rel="noopener noreferrer"&gt;@kamranahmedse&lt;/a&gt;.&lt;br&gt;
Build more complex apps.&lt;/p&gt;

&lt;p&gt;Go and learn what interest you. &lt;br&gt;
That's it 😀.&lt;br&gt;&lt;br&gt;
Have fun!  &lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>How NOT to learn JavaScript</title>
      <dc:creator>Maciek Chmura</dc:creator>
      <pubDate>Tue, 17 Sep 2019 11:16:33 +0000</pubDate>
      <link>https://forem.com/maciekchmura/how-not-to-learn-javascript-i79</link>
      <guid>https://forem.com/maciekchmura/how-not-to-learn-javascript-i79</guid>
      <description>&lt;p&gt;A few years ago when I was starting my journey as a programmer I asked my friend(an unnamed hero, who is an awesome programmer) a question:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How can I learn JavaScript?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;He answered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You don't want to learn JavaScript, you want to learn how to program.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I didn't understand it then. I wanted to learn JS. I wanted to learn React, and Node, and WebGL.&lt;/p&gt;

&lt;p&gt;And then I made lots of mistakes trying to. I've hit a roadblock after a roadblock when I was struggling to understand some basic concepts. &lt;/p&gt;

&lt;p&gt;I remember a specific point in time when my Unnamed Friend was trying to teach me about data structures. When we got into hash maps I was so frustrated that I saved the file with the exercise as "some stupid 💩.js"&lt;br&gt;
Why would somebody even need this!!??&lt;/p&gt;

&lt;p&gt;I was in the pit of despair...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hNeoLCQE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/4j6byh0mxhvzn0j0r1kt.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hNeoLCQE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/4j6byh0mxhvzn0j0r1kt.PNG" alt="pit of despair"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I got here by following some advice found on the internet that was not suited for me.&lt;br&gt;
I wouldn't say it was wasted time because all experience is valuable. But I've could use this time more efficiently.&lt;/p&gt;

&lt;p&gt;Here is my opinion what NOT to do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Don't do &lt;a href="https://adventofcode.com/"&gt;Advent Of Code&lt;/a&gt;. Instead of learning some good practices you will try to finish the task at all cost. This can produce really ugly code with lots of if statements. &lt;/li&gt;
&lt;li&gt;Don't read &lt;a href="https://eloquentjavascript.net/"&gt;Eloquent JavaScript&lt;/a&gt; Don't get me wrong, this is a good book, IMHO not good for beginners without a CS degree. It tries to teach you JS by solving complex problems with lots of abstractions. &lt;/li&gt;
&lt;li&gt;Don't read &lt;a href="https://github.com/getify/You-Dont-Know-JS/tree/1st-ed"&gt;You Don't Know JS&lt;/a&gt;. Again, great books but too complex for start. Get back here in a year or soo.&lt;/li&gt;
&lt;li&gt;Don't learn frameworks. React, Vue, Angular. You need to know what problems these frameworks solve in the first place. &lt;/li&gt;
&lt;li&gt;Don't jump from tutorial to tutorial without practicing what you learn. You can easily fall into watching an endless stream of YouTube videos. Probably you will not remember most of it the next day.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the next post, I will present a way that helped me get out of the pit.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Do you know about Teal? +React game</title>
      <dc:creator>Maciek Chmura</dc:creator>
      <pubDate>Mon, 22 Jul 2019 20:17:18 +0000</pubDate>
      <link>https://forem.com/maciekchmura/do-you-know-about-teal-react-game-3bd6</link>
      <guid>https://forem.com/maciekchmura/do-you-know-about-teal-react-game-3bd6</guid>
      <description>&lt;p&gt;TL;DR: just show me the &lt;a href="https://teal-adventure.netlify.com/" rel="noopener noreferrer"&gt;game&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Some time ago, while listening to a podcast, I stumbled upon a neat idea. &lt;/p&gt;

&lt;h3&gt;
  
  
  Teal Organisations
&lt;/h3&gt;

&lt;p&gt;Guests were talking about the structural and workforce changes happening in the tech industry.&lt;br&gt;
I'm generally interested in startups and tech industry so I was intrigued about this new way how to structure a tech organization. &lt;/p&gt;

&lt;p&gt;The idea of "Teal Organisation" was created by Frederic Laloux and described in his book: "Reinventing Organizations"&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The Teal paradigm refers to the next stage in the evolution of human consciousness. When applied to organizations, this paradigm views the organization as an independent force with its own purpose, and not merely as a vehicle for achieving management's objectives. Teal organizations are characterized by self-organization and self-management. The hierarchical "predict and control" pyramid of Orange is replaced with a decentralized structure consisting of small teams that take responsibility for their own governance and for how they interact with other parts of the organization. &lt;br&gt;
&lt;a href="http://reinventingorganizationswiki.com/Main_Page" rel="noopener noreferrer"&gt;wiki&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There is also a book by Polish author, Andrzej Blikle titled "Doktryna Jakosci" The &lt;a href="http://www.moznainaczej.com.pl/Download/DoktrynaJakosci/DoktrynaJako%C5%9Bci_wydanie_II.pdf" rel="noopener noreferrer"&gt;book&lt;/a&gt; is available for free in PDF format, unfortunately, there is no English translation yet.&lt;/p&gt;

&lt;p&gt;Teal answers a question:&lt;/p&gt;
&lt;h3&gt;
  
  
  How a group of people, happily united with the same goal, can cooperate to produce value.
&lt;/h3&gt;

&lt;p&gt;Some companies have a gut feeling about how to do this.&lt;/p&gt;

&lt;p&gt;You can see Teal values in companies that were started long before Frederic Laloux published his book.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Basecamp -&amp;gt; check any book or blog post from Jason Fried and David Heinemeier Hansson and discover what they think about creating a tech company. (I might be biased because I am a huge fan)  &lt;a href="https://basecamp.com/books" rel="noopener noreferrer"&gt;https://basecamp.com/books&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Buffer -&amp;gt; &lt;a href="https://buffer.com/about" rel="noopener noreferrer"&gt;https://buffer.com/about&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Valve -&amp;gt; ever heard about Half-Life, Counter-Strike or Steam Platform? Check the Handbook for New Employees, its hilarious, &lt;a href="https://www.valvesoftware.com/en/publications" rel="noopener noreferrer"&gt;https://www.valvesoftware.com/en/publications&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Teal ideas are not some kind of revolution. You can observe them popping up everywhere.&lt;/p&gt;

&lt;p&gt;Some of these ideas are about being happy at work:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/fLJsdqxnZb0"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Some of these ideas are about focusing on quality instead of growth.&lt;br&gt;
&lt;a href="https://www.amazon.com/Company-One-Staying-Small-Business/dp/1328972356" rel="noopener noreferrer"&gt;https://www.amazon.com/Company-One-Staying-Small-Business/dp/1328972356&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some of these ideas are about trust:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ReRcHdeUG9Y"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;I allowed myself to loosely translate 2 insightful fragments from the book from Andrzej Blikle.&lt;br&gt;&lt;br&gt;
Hopefully, this will make you dig deeper into Teal.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to decide what to work on?
&lt;/h3&gt;

&lt;p&gt;You can pick a task based on these rules:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;you do what you can do,&lt;/li&gt;
&lt;li&gt;you do what is necessary,&lt;/li&gt;
&lt;li&gt;you are responsible for it,&lt;/li&gt;
&lt;li&gt;what you do, you can change, but with preservation of 1, 2 and 3.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Teal principles:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Do not look for the guilty one to punish - look for the cause to remove it,&lt;/li&gt;
&lt;li&gt;Do not expect perfection that cannot be achieved - expect progress that is always possible,&lt;/li&gt;
&lt;li&gt;Avoid competition that destroys partnership - create conditions for cooperation,&lt;/li&gt;
&lt;li&gt;Do not judge, because it destroys - appreciate, because it strengthens,&lt;/li&gt;
&lt;li&gt;Do not say what is wrong - say what could be better,&lt;/li&gt;
&lt;li&gt;Do not ask people what they could do better - ask them what hinders their work,&lt;/li&gt;
&lt;li&gt;Do not build on control - build on trust,&lt;/li&gt;
&lt;li&gt;Do not say that someone is bad - say how you feel about it (the so-called "communication I"),&lt;/li&gt;
&lt;li&gt;Do not manage - create conditions for self-organization,&lt;/li&gt;
&lt;li&gt;Don't be a supervisor - be a teacher, moderator, and student.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As you can see all of these rules are very reasonable and natural.&lt;br&gt;
To illustrate how easy it is to follow them, I made a simple &lt;a href="https://teal-adventure.netlify.com/" rel="noopener noreferrer"&gt;game&lt;/a&gt; 😅&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fe3jaqdh4ov1pghsb7nma.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fe3jaqdh4ov1pghsb7nma.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Dear Creator,&lt;br&gt;
Now You know about Teal.&lt;br&gt;
You have a great tool to help you organize a team.&lt;br&gt;
What will you build now?&lt;/p&gt;

</description>
      <category>career</category>
      <category>productivity</category>
      <category>react</category>
    </item>
    <item>
      <title>How I structure a React project</title>
      <dc:creator>Maciek Chmura</dc:creator>
      <pubDate>Tue, 28 May 2019 10:51:01 +0000</pubDate>
      <link>https://forem.com/maciekchmura/how-i-structure-a-react-project-3c2i</link>
      <guid>https://forem.com/maciekchmura/how-i-structure-a-react-project-3c2i</guid>
      <description>&lt;p&gt;There are many guides on how to structure web apps and React in particular.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Move files into folders based on Smart/Dumb components.&lt;/li&gt;
&lt;li&gt;Organise them by the Header/Main/Footer&lt;/li&gt;
&lt;li&gt;Or throw everything to Components and combine them in Pages???&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’ve never been fully convinced to use any of these conventions.&lt;br&gt;
And then, about 2 months ago I started a new project. Simple tech stack: React + Express + MySQL.&lt;br&gt;
After a few commits, I had to move the components somewhere.&lt;br&gt;
After a little bit of research, I found something promising.&lt;br&gt;
It's based on 2 resources:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://react-file-structure.surge.sh/" rel="noopener noreferrer"&gt;Dan Abramov's official guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://atomicdesign.bradfrost.com/table-of-contents/" rel="noopener noreferrer"&gt;Brad Frost's Atomic Design&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Dan gave me freedom and Brad gave me structure 😅&lt;/p&gt;

&lt;p&gt;Atomic Design introduces a new, abstract way to think about project structure. Components are building blocks of an app.&lt;br&gt;
Atoms, molecules, organisms, templates, and pages. This concept brings a breath of fresh air to how we can think about structure.&lt;br&gt;
For my purpose, I used the first 3, but I encourage you to read Brad's guide and adapt it to your liking.&lt;/p&gt;

&lt;p&gt;I started with a sketch:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh2aixrrhinhos4vs5umf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh2aixrrhinhos4vs5umf.png" alt="sketch" width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Main idea:&lt;br&gt;
3 folders: Atoms, Molecules, Organisms&lt;br&gt;
If the component has logic/state -&amp;gt; move it to Organisms.&lt;br&gt;
If the component has other components -&amp;gt; move it to Molecules.&lt;br&gt;
Otherwise, the component is an Atom.&lt;/p&gt;

&lt;p&gt;I like the organic analogy. It creates a mental and logical box for React components. If needed, I can add more non-organic folders for Utils, Routes, API, etc.&lt;br&gt;
A Button will be in Atoms.&lt;br&gt;
A Card will be in Molecules.&lt;br&gt;
Component with Hooks will be in Organisms.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/
  Atoms/
    Button
    ProjectName
    ...
  Molecules/
    ControlBar
    DaysList
    ...
  Organisms/
    User
    CreateUser
    ...
  Utils
    formatMonthData.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For now, this works with no flaws with my project. I will reevaluate this concept when my project grows.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>3 topics in 1 JavaScript interview question</title>
      <dc:creator>Maciek Chmura</dc:creator>
      <pubDate>Tue, 12 Mar 2019 12:06:41 +0000</pubDate>
      <link>https://forem.com/maciekchmura/3-topics-in-1-javascript-interview-question-1gd7</link>
      <guid>https://forem.com/maciekchmura/3-topics-in-1-javascript-interview-question-1gd7</guid>
      <description>&lt;p&gt;Programming interviews are hard. Live coding during the interview is even harder.&lt;br&gt;
I have a feeling that as soon as I have to type code in front of another person &lt;code&gt;myIntelligence -= 10;&lt;/code&gt;&lt;br&gt;
At my current company, lead developers regularly conduct interviews with potential new candidates. There are prepared some sets of questions for JavaScript developers, but there is this one questions that almost always gets asked:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="c1"&gt;// what will be logged in the console&lt;/span&gt;
    &lt;span class="c1"&gt;// and how to fix it to log 0, 1, 2??&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's a pretty typical question.&lt;br&gt;
What is so special about it?&lt;br&gt;
Well, in my opinion, these 5 lines touch 3 interesting aspects of JavaScript.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;var, let and const&lt;/li&gt;
&lt;li&gt;closures&lt;/li&gt;
&lt;li&gt;event loop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's break it down to see what is happening here.&lt;/p&gt;
&lt;h2&gt;
  
  
  var let const
&lt;/h2&gt;

&lt;p&gt;ES6 introduced new variable assignment keywords: &lt;code&gt;const&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt;. You probably already know that they are block scoped and &lt;code&gt;var&lt;/code&gt; is function scoped. &lt;br&gt;
Some simple cases to illustrate this behavior.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="c1"&gt;// simplest JavaScript example in the world:&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;maciek&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;surname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;chmura&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// -&amp;gt; maciek&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;surname&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// -&amp;gt; surname is not defined&lt;/span&gt;

    &lt;span class="c1"&gt;// what's happening under the hood:&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;surname&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;maciek&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nx"&gt;surname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;chmura&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;surname&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OK, let’s put this in context of a for loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// -&amp;gt; 0 1 2&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// what will happen when var is changed to let?&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// -&amp;gt; 0 1 2&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both loops generate right output. But in some slightly different way. &lt;code&gt;var&lt;/code&gt; 'jumps' to &lt;code&gt;global scope&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt; 'jumps' into the loop, and gets initialized on each iteration.&lt;br&gt;
It can be illustrated like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="c1"&gt;// var lives here&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// -&amp;gt; 0 1 2&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// -&amp;gt; 3&lt;/span&gt;

    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// let is available only from here&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// -&amp;gt; 0 1 2&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ReferenceError: j is not defined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OK, easy peasy... This is how block scoping works... moving on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closures
&lt;/h2&gt;

&lt;p&gt;The mystical land of JavaScript Closure.&lt;br&gt;
What is the raw definition of a closure? &lt;br&gt;
Lets check &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A closure is the combination of a function and the lexical environment within which that function was declared.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Please take a deeper look at this article from MDN. Very smart people contribute to this knowledge base, let's trust them :)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What exactly is this &lt;code&gt;lexical environment&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;Does it go away at some point?&lt;/li&gt;
&lt;li&gt;Who and when decides about it?&lt;/li&gt;
&lt;li&gt;How can I control it?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a long time, I could not wrap my head around it.&lt;br&gt;
It was until I added 2 visual aids to help me understand it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;🎒 A Backpack. I like to think of closures as backpacks of functions. When a function is defined it adds to its backpack all the values it might need in the future.&lt;/li&gt;
&lt;li&gt;🚚 A Garbage Collector. A truck that removes old code. Unlike in C language, you don't have to do &lt;code&gt;malloc()&lt;/code&gt; and &lt;code&gt;free()&lt;/code&gt;, it will be handled automatically.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When some function has executed and returned a value, we can safely remove this function definition from memory 🚚🗑. The same thing goes for values that are not reachable anymore.&lt;br&gt;
Things get interesting when a function returns a function.&lt;br&gt;
I don't want to reinvent new examples and definitions, so I will just add some layer of visual helpers.&lt;br&gt;
MDN example (with line numbers):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;makeFunc&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;          &lt;span class="c1"&gt;// 1&lt;/span&gt;
      &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Mozilla&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;        &lt;span class="c1"&gt;// 2&lt;/span&gt;
      &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;displayName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;     &lt;span class="c1"&gt;// 3&lt;/span&gt;
        &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;               &lt;span class="c1"&gt;// 4&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;                            &lt;span class="c1"&gt;// 5&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;displayName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="c1"&gt;// 6&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;                              &lt;span class="c1"&gt;// 7&lt;/span&gt;
                                   &lt;span class="c1"&gt;// 8&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;myFunc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;makeFunc&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;       &lt;span class="c1"&gt;// 9&lt;/span&gt;
    &lt;span class="nf"&gt;myFunc&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;                      &lt;span class="c1"&gt;// 10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's imagine a simplified JavaScript interpreter workflow. What JavaScript runtime is ’thinking’ while running code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(line 1)&lt;code&gt;makeFunc&lt;/code&gt; function definition, moving on.&lt;/li&gt;
&lt;li&gt;(9)Declare &lt;code&gt;myFunc&lt;/code&gt; variable and assign to it the result of running &lt;code&gt;makeFunc&lt;/code&gt;, execute &lt;code&gt;makeFunc&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;(1)Jumping into &lt;code&gt;makeFunc&lt;/code&gt; definition.&lt;/li&gt;
&lt;li&gt;(2)Ok, a variable &lt;code&gt;name&lt;/code&gt; with value &lt;code&gt;Mozilla&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;(3)&lt;code&gt;displayName&lt;/code&gt; function definition, moving on.&lt;/li&gt;
&lt;li&gt;(4)&lt;code&gt;return&lt;/code&gt; &lt;code&gt;displayName&lt;/code&gt; function definition&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;First plot twist&lt;/strong&gt;. Whole function definition is returned here. There are no () at the end of &lt;code&gt;displayName&lt;/code&gt;.&lt;br&gt;
&lt;strong&gt;Second plot twist&lt;/strong&gt;. A closure is observed. Where? &lt;code&gt;displayName&lt;/code&gt; puts into its 🎒 &lt;code&gt;var name&lt;/code&gt; (it is within lexical scope of &lt;code&gt;displayName&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7jhdi37mxrjbssjuyfvg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F7jhdi37mxrjbssjuyfvg.png" alt="screen"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;makeFunc&lt;/code&gt; executed and returned the whole function definition of &lt;code&gt;displayName&lt;/code&gt; with its closure (a 🎒) holding a reference to a value in &lt;code&gt;name&lt;/code&gt;.&lt;br&gt;
The garbage collector can't delete lines 1 to 7 from memory because sometime in the future &lt;code&gt;myFunc&lt;/code&gt; might get executed, and then &lt;code&gt;displayName&lt;/code&gt; with its closure will be needed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;(10) execute &lt;code&gt;myFunc&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is how I understand closures. &lt;br&gt;
Now I can see it! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbb3dua6vjqupmuciycq3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbb3dua6vjqupmuciycq3.gif" alt="panda"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's move to the last part of the puzzle.&lt;/p&gt;
&lt;h2&gt;
  
  
  Event Loop
&lt;/h2&gt;

&lt;p&gt;There is no better way to learn about event loop than from amazing Philip Roberts talk at JSConf EU.&lt;br&gt;
Just watch it... &lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/8aGhZQkoFbQ"&gt;
&lt;/iframe&gt;
&lt;br&gt;
🤯 mind blowing right?&lt;br&gt;
OK! Finally, with all the knowledge, let's break down what is happening in the interview question.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With each iteration of the loop, &lt;code&gt;setTimeout&lt;/code&gt; sends function with &lt;code&gt;console.log(i)&lt;/code&gt; to the web APIs and start the countdown. &lt;br&gt;
In the meantime, we will continue with the loop. Another &lt;code&gt;console.log(i)&lt;/code&gt; will be pushed to web APIs and so on... &lt;br&gt;
Loop finished execution. Call Stack is empty. &lt;br&gt;
In the web APIs, after 1 second &lt;code&gt;console.log(i)&lt;/code&gt; gets pushed to the Callback Queue. And another one, and another one. &lt;br&gt;
Because the Call Stack is empty, Callback Queue can push its first element to the Call Stack to execute it.&lt;br&gt;
So the first &lt;code&gt;console.log(i)&lt;/code&gt; executes.&lt;br&gt;
It looks for an &lt;code&gt;i&lt;/code&gt;.&lt;br&gt;
What is the value of &lt;code&gt;i&lt;/code&gt;?&lt;br&gt;
It's 3. From the global scope.&lt;br&gt;
&lt;em&gt;Why?&lt;/em&gt;&lt;br&gt;
Loop finished its iteration and updated the &lt;code&gt;i&lt;/code&gt; to 3 at the end.&lt;br&gt;
var &lt;code&gt;i&lt;/code&gt; is function scoped (for loop is not a function), and was hoisted outside of the loop to the &lt;code&gt;global scope&lt;/code&gt;.&lt;br&gt;
Call Stack is empty again.&lt;br&gt;
Second &lt;code&gt;console.log(i)&lt;/code&gt; moves to the Call Stack.&lt;br&gt;
What is the value of &lt;code&gt;i&lt;/code&gt;? It's 3 again. It's the same value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fw74lv15u6nn3ntrz2apl.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fw74lv15u6nn3ntrz2apl.gif" alt="get_it"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How to fix it to log 0, 1, 2?&lt;br&gt;
One way of fixing it is by changing &lt;code&gt;var&lt;/code&gt; to &lt;code&gt;let&lt;/code&gt;.&lt;br&gt;
Now while looping, each &lt;code&gt;i&lt;/code&gt; is initialized and assigned a value of current iteration and put into closure (a 🎒) of function that will log it.&lt;br&gt;
After 1 second, when the Call Stack is empty, Callback Queue will push function with &lt;code&gt;console.log(i)&lt;/code&gt; and it's closed over value of &lt;code&gt;i&lt;/code&gt; back to Call Stack and execute it.&lt;br&gt;
0, 1, 2 will get logged respectively.&lt;br&gt;
&lt;em&gt;Done.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Next question please.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, when you know what is happening exactly, what else can be done to fix it?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclaimer:&lt;/em&gt;&lt;br&gt;
&lt;em&gt;I wrote this mainly for myself to study these topics. If anything here is wrong, please point it out in the comments so we all can learn :)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>career</category>
    </item>
    <item>
      <title>4 fast ways to run JavaScript</title>
      <dc:creator>Maciek Chmura</dc:creator>
      <pubDate>Thu, 14 Feb 2019 21:31:34 +0000</pubDate>
      <link>https://forem.com/maciekchmura/4-fast-ways-to-run-javascript-1h45</link>
      <guid>https://forem.com/maciekchmura/4-fast-ways-to-run-javascript-1h45</guid>
      <description>&lt;p&gt;I like to learn new things.&lt;br&gt;
When I experiment, I need a fast way to run a code snippet, do some debugging and figure out what is working and what is not.&lt;br&gt;
Depending on the situation and mood 🌅 I switch between these setups:&lt;/p&gt;

&lt;h2&gt;
  
  
  VSCode
&lt;/h2&gt;

&lt;p&gt;Most of the time I will write the code in my code_notes repository.&lt;br&gt;
I have the simplest VSCode configuration possible:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"request"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"launch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"single file"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"program"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"${file}"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With this config, VSCode will run currently opened file in the debugger.&lt;br&gt;&lt;br&gt;
Just hit &lt;code&gt;F5&lt;/code&gt; and look for the output in &lt;code&gt;DEBUG CONSOLE&lt;/code&gt;.&lt;br&gt;
Of course, you will have all the debugging goodies - read more &lt;a href="https://code.visualstudio.com/docs/editor/debugging" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  VSCode + Quokka.js
&lt;/h2&gt;

&lt;p&gt;To have 'live reload' for code evaluation check out &lt;a href="https://quokkajs.com/" rel="noopener noreferrer"&gt;Quokka.js&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Quokka.js is a rapid prototyping playground for JavaScript and TypeScript. It runs your code immediately as you type and displays various execution results in your code editor.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I use it when I am just starting out with an idea.&lt;br&gt;
It really helps to understand what effect has each line of the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chrome Snippets
&lt;/h2&gt;

&lt;p&gt;Sometimes the quickest way to run JavaScript is in Chrome directly.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F11sy5xamsrlcyzlv3dc6.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F11sy5xamsrlcyzlv3dc6.PNG" alt="logTree"&gt;&lt;/a&gt;&lt;br&gt;
Just open &lt;code&gt;Developer Tools&lt;/code&gt;, switch to &lt;code&gt;Sources&lt;/code&gt; tab and create a new code snippet. &lt;code&gt;Snippets&lt;/code&gt; might be hidden under the &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; icon.&lt;br&gt;
Remember to wrap the code in &lt;code&gt;{}&lt;/code&gt; to have a new local scope on each run.&lt;/p&gt;

&lt;h2&gt;
  
  
  Python Tutor
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnu4v7qin8oi0ezc54wld.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnu4v7qin8oi0ezc54wld.PNG" alt="python tutor"&gt;&lt;/a&gt;&lt;br&gt;
Don't be fooled by the name! It can run JavaScript also. And it even has a live mode too. &lt;br&gt;
The cool thing about this tool is that it visualizes what is happening at each step.&lt;br&gt;
It's great for educational purposes.&lt;br&gt;
&lt;a href="http://pythontutor.com/live.html#mode=edit" rel="noopener noreferrer"&gt;link&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Hardware idea</title>
      <dc:creator>Maciek Chmura</dc:creator>
      <pubDate>Tue, 05 Feb 2019 16:51:41 +0000</pubDate>
      <link>https://forem.com/maciekchmura/hardware-idea-541b</link>
      <guid>https://forem.com/maciekchmura/hardware-idea-541b</guid>
      <description>&lt;p&gt;Hardware is probably too big word for what I have in mind. A gadget? Helper?&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;I am learning to touch type. Right now I can pretty much type all words without looking on the keyboard. &lt;br&gt;
Problem starts when I have to write code. Beside typing names for variables, functions and methods I have to type language specyfic syntax:&lt;br&gt;
&lt;code&gt;: ; " ' { [ ] } - + = ( )&lt;/code&gt;  ...at least in JavaScript world. &lt;br&gt;
When I order my 'pinky' finger to press minus keycap, the process to show the minus sign on screen is something like this:&lt;br&gt;
&lt;code&gt;[]&lt;/code&gt; backspace &lt;code&gt;0&lt;/code&gt; backspace &lt;code&gt;-&lt;/code&gt; . Sometimes it takes me more steps to finally have what I want. Or even worse, eventually I have to look at the keyboard...&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;On J and F keycaps on the standard keyboard there is this raised dot or bar. This is an indicator for index fingers to find home row without looking.&lt;br&gt;
Cool idea that is very helpful. &lt;br&gt;
What if there were similar indicators for 'pinky' fingers?😄 On those hard to aim and reach keycaps. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ftpgvrxl306t0rubbihro.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ftpgvrxl306t0rubbihro.png" alt="layout"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When reaching to that keycap you can instantly know if you are about to press correct key.&lt;br&gt;
There could be indicators only on &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1&lt;/code&gt;. Or there could be some additional on &lt;code&gt;[&lt;/code&gt; or even &lt;code&gt;\&lt;/code&gt;. &lt;br&gt;
Of course, there is no limitation to shape. Only one condition: shapes need to be easily distinguishable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ffrse7o2kth71yls9pjqy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ffrse7o2kth71yls9pjqy.png" alt="bumps"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How to modify a keyboard like that?&lt;br&gt;
STICKERS!!!&lt;br&gt;
Black vinyl stickers. Transparent stickers. Anything that will have this 'bump'.&lt;/p&gt;

&lt;p&gt;What do you think?&lt;br&gt;
Is this idea valid?&lt;br&gt;
Would it help you?&lt;/p&gt;

&lt;p&gt;I think it would help me. 😅&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>idea</category>
      <category>hardware</category>
    </item>
    <item>
      <title>Bash magic spell to replace files</title>
      <dc:creator>Maciek Chmura</dc:creator>
      <pubDate>Fri, 04 Jan 2019 07:22:47 +0000</pubDate>
      <link>https://forem.com/maciekchmura/bash-magic-spell-to-replace-files-528j</link>
      <guid>https://forem.com/maciekchmura/bash-magic-spell-to-replace-files-528j</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I18XJX03--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/mahrtqnqhpmbssxs0hkr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I18XJX03--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/mahrtqnqhpmbssxs0hkr.jpg" alt="bash"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Most recently, at my work project, I assigned myself to a task to replace a png file across the project with new graphics.&lt;br&gt;
Same file name, different pixels.&lt;br&gt;&lt;br&gt;
A quick search for the file in VSCode showed around 35 results across different folders.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;But why there are 35 copies of the same png in the project?&lt;br&gt;&lt;br&gt;
Good question for which I have no answer 🤔&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What a can be done here to complete the task?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Manually track all the files in file explorer and replace them. This can take around 15 to 25 minutes depending if you double check copies and how fast you click... boooooring!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Or find a bash command to do the work for you.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Challenge accepted!&lt;/strong&gt;&lt;br&gt;
What should be done?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;have a reference to file with new data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;find the file by name&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;replace found file with new data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;repeat until all files in the folder are changed&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After some googling, reading stack overflow and MAN pages, I stitched this line to replace a file with new data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;find &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-print&lt;/span&gt; &lt;span class="nt"&gt;-type&lt;/span&gt; f &lt;span class="nt"&gt;-name&lt;/span&gt; apple.PNG &lt;span class="nt"&gt;-execdir&lt;/span&gt; &lt;span class="nb"&gt;cp&lt;/span&gt; /mnt/c/Users/Maciej_Chmura/replace_source/orange.PNG &lt;span class="o"&gt;{}&lt;/span&gt; &lt;span class="se"&gt;\;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Let's break it down to know exactly what is happening:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;find 👉 bash find command
. 👉 current execution context, current folder
-print 👉 log the process
-type f 👉 specify to look for files
-name file_name 👉 specify file name to search
-execdir 👉 execute command from the subdirectory
cp from_file to_file 👉 copy from one file to another
{} 👉 is a placeholder for file that `find` will find
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Don't stop here, learn more about these commands:&lt;br&gt;&lt;br&gt;
&lt;a href="https://ss64.com/bash/find.html"&gt;find&lt;/a&gt;&lt;br&gt;
&lt;a href="https://ss64.com/bash/cp.html"&gt;cp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this little line, all files in the current folder and subfolders will be replaced.&lt;/p&gt;

&lt;p&gt;After this research, I thought of another use case.&lt;br&gt;
What if you need to rename the file?&lt;br&gt;
The command is almost the same:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;find &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-print&lt;/span&gt; &lt;span class="nt"&gt;-type&lt;/span&gt; f &lt;span class="nt"&gt;-name&lt;/span&gt; apple.PNG &lt;span class="nt"&gt;-execdir&lt;/span&gt; &lt;span class="nb"&gt;mv&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt; orange.PNG &lt;span class="se"&gt;\;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Hopefully, this will save you some time in the future when encountered in a similar case.&lt;br&gt;&lt;br&gt;
Do you know any magic bash spells?&lt;/p&gt;

</description>
      <category>tips</category>
      <category>bash</category>
      <category>terminal</category>
    </item>
    <item>
      <title>How I stay productive in a big project</title>
      <dc:creator>Maciek Chmura</dc:creator>
      <pubDate>Tue, 18 Dec 2018 21:10:30 +0000</pubDate>
      <link>https://forem.com/maciekchmura/how-i-stay-productive-in-a-big-project-388b</link>
      <guid>https://forem.com/maciekchmura/how-i-stay-productive-in-a-big-project-388b</guid>
      <description>&lt;p&gt;...and not get lost on the way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;For almost a year I've been a part of a big and mature JavaScript project. No frameworks. Just Node, JS and MVC. Often times when I am fixing a bug I have to jump into multiple files and classes for investigation. My open files tab gets full really quickly. My main problem is jumping between different solutions for a particular fix. &lt;/p&gt;

&lt;p&gt;I want to perform some change in code, test it and leave it for later to go find a different approach. I repeat these steps a few times. Then, when I have a fix that is the best fit, in my opinion, I can make a PR for code review or discuss it with my team. &lt;/p&gt;

&lt;p&gt;So ideally I would like to quickly switch between possible fixes.&lt;br&gt;
For this, I have two approaches.&lt;/p&gt;
&lt;h2&gt;
  
  
  Save a diff file
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git diff &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; fix1.diff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Git will generate a patch file with all the changes made to the repository. I can send this file to someone, open it in its own window to compare with the current state, etc. &lt;br&gt;
Very easy for quick verification.&lt;/p&gt;

&lt;p&gt;To apply this file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git apply fix1.diff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This is the simplest workflow for progressively save your work between commits. &lt;br&gt;
I have just a file with all of the changes.&lt;br&gt;
This is nice and simple, but there are better solutions.&lt;/p&gt;
&lt;h2&gt;
  
  
  Git Stash
&lt;/h2&gt;

&lt;p&gt;Stashing is saving work for later.&lt;br&gt;
There are many great tutorials and documentation on this topic. &lt;br&gt;
&lt;a href="https://pl.atlassian.com/git/tutorials/saving-changes/git-stash" rel="noopener noreferrer"&gt;atlassian&lt;/a&gt;&lt;br&gt;
&lt;a href="https://git-scm.com/docs/git-stash" rel="noopener noreferrer"&gt;git-scm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I found this 2 commands helpful in my case:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash save &amp;lt;message&amp;gt;
git stash apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;git stash save&lt;/code&gt; will save the changes and clean my working directory, soo to continue working I must apply them back. (&lt;code&gt;git stash pop&lt;/code&gt; will also apply changes but they will be deleted from stash).&lt;/p&gt;

&lt;p&gt;Now I have a saved point in working "timeline" that I can easily evaluate or revert back to.&lt;br&gt;
This can also be done inside VScode(if you use it) with &lt;a href="https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens" rel="noopener noreferrer"&gt;Gitlens&lt;/a&gt; plugin(Webstorm also has this functionality)&lt;/p&gt;

&lt;p&gt;** Update&lt;br&gt;
As highlighted by &lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__47820"&gt;
    &lt;a href="/heberqc" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F47820%2F6def7d5b-1de1-49fe-b5be-2d43c5a96724.png" alt="heberqc image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/heberqc"&gt;Heber Quequejana&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/heberqc"&gt;I'm from Perú 🇵🇪, I work as web developer 👨🏽‍💻. I like learning about computing topics.&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;code&gt;git stash save&lt;/code&gt; is deprecated. Please use &lt;code&gt;git stash push&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Micro-tip: personalized comments
&lt;/h2&gt;

&lt;p&gt;I put a comment in this manner:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// @mch &amp;lt;what I think is happening here&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;mch &amp;gt; my initials&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Within editor, I've set up a rule to highlight &lt;code&gt;@mch&lt;/code&gt; string.&lt;br&gt;
For VScode there is nice plugin: &lt;a href="https://marketplace.visualstudio.com/items?itemName=wayou.vscode-todo-highlight" rel="noopener noreferrer"&gt;TODO&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've customized it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;todohighlight.keywords&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TODO&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#000000&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;backgroundColor&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;gold&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;borderRadius&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@mch&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#66ffdd&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;backgroundColor&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#116644&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;borderRadius&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is helpful to quickly lookup all the places that cought my eye.&lt;br&gt;
Ctrl + Shift + F for them with &lt;code&gt;@mch&lt;/code&gt; or use TODO plugin lookup.&lt;/p&gt;

&lt;p&gt;These 3 tips help me with day to day work.&lt;br&gt;
What are your hacks for productive work??&lt;/p&gt;

&lt;p&gt;Disclaimer:&lt;br&gt;
This post is my first blog'ish publication like ever ever :D&lt;br&gt;
Thank you DEV team for making it possible for me to share :D&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>node</category>
    </item>
  </channel>
</rss>
