<?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>DEV Community: Alex Parra</title>
    <description>The latest articles on DEV Community by Alex Parra (@alexparra).</description>
    <link>https://dev.to/alexparra</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%2F186992%2Fb8164f84-69f8-4d46-b9b0-09fe73b6820f.jpg</url>
      <title>DEV Community: Alex Parra</title>
      <link>https://dev.to/alexparra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alexparra"/>
    <language>en</language>
    <item>
      <title>React PWA: Salary per time calculator</title>
      <dc:creator>Alex Parra</dc:creator>
      <pubDate>Mon, 16 Nov 2020 17:45:20 +0000</pubDate>
      <link>https://dev.to/alexparra/react-pwa-salary-per-time-calculator-10il</link>
      <guid>https://dev.to/alexparra/react-pwa-salary-per-time-calculator-10il</guid>
      <description>&lt;p&gt;This weekend I took on automating something many of us probably do over and over... (at least I do). &lt;/p&gt;

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

&lt;p&gt;If I make x€ per hour how much is that per year in £? &lt;br&gt;
If I make y$ per year, how much is that per month in €?&lt;/p&gt;

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

&lt;p&gt;A pwa that calculates all other values when I change one of them.&lt;/p&gt;

&lt;p&gt;App: &lt;a href="https://alex-parra.github.io/salary-per-time-calculator/"&gt;https://alex-parra.github.io/salary-per-time-calculator/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/alex-parra/salary-per-time-calculator"&gt;https://github.com/alex-parra/salary-per-time-calculator&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TODO
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;favicon images&lt;/li&gt;
&lt;li&gt;local storage&lt;/li&gt;
&lt;li&gt;??&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>react</category>
      <category>pwa</category>
      <category>sideprojects</category>
    </item>
    <item>
      <title>My first npm package: sequelize-airtight</title>
      <dc:creator>Alex Parra</dc:creator>
      <pubDate>Sat, 31 Oct 2020 18:51:14 +0000</pubDate>
      <link>https://dev.to/alexparra/my-first-npm-package-sequelize-airtight-1b0l</link>
      <guid>https://dev.to/alexparra/my-first-npm-package-sequelize-airtight-1b0l</guid>
      <description>&lt;p&gt;I've recently published my first npm package: &lt;a href="https://www.npmjs.com/package/sequelize-airtight"&gt;sequelize-airtight&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are some features to add before bumping to v1.0.0 but it's taking shape and progressing a little bit every day.&lt;/p&gt;

&lt;p&gt;The goal is to extend the validation methods available in sequelize (through &lt;code&gt;validate.js&lt;/code&gt;) in order to make your models and data safer and reliable.&lt;/p&gt;

&lt;p&gt;Additionally, it includes &lt;code&gt;mutators&lt;/code&gt; that allow you to transform values on write (overloading each field's &lt;code&gt;set&lt;/code&gt; method) or on read (overloading each field's &lt;code&gt;get&lt;/code&gt; method).&lt;/p&gt;

&lt;p&gt;All validators and mutators are opt-in meaning that just installing the module won't cause any changes to your models.&lt;br&gt;
Per field, you can add a new attribute &lt;code&gt;airtight&lt;/code&gt; that can contain the validators and mutators to apply. &lt;/p&gt;

&lt;p&gt;I'll surely write more about how everything works closer or at time of the release of v1.&lt;/p&gt;

&lt;p&gt;I took this opportunity to learn and use GitHub Actions workflows and also dependency aliases which allowed me to easily test against &lt;code&gt;sequelize&lt;/code&gt; v5 and v6 continuously.&lt;/p&gt;

&lt;p&gt;Today, I'm just putting the word out and inviting you to have a look and possibly find something I've overlooked till now.&lt;br&gt;
All constructive feedback is highly appreciated.&lt;/p&gt;

&lt;p&gt;Very curious to know if this "clicks" with the community.&lt;/p&gt;

&lt;p&gt;Package: &lt;a href="https://www.npmjs.com/package/sequelize-airtight"&gt;https://www.npmjs.com/package/sequelize-airtight&lt;/a&gt;&lt;br&gt;
Repository: &lt;a href="https://github.com/alex-parra/sequelize-airtight"&gt;https://github.com/alex-parra/sequelize-airtight&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Best&lt;/p&gt;

</description>
      <category>node</category>
      <category>sequelize</category>
      <category>validation</category>
      <category>mutators</category>
    </item>
    <item>
      <title>Creating a JS repo for your ProjectEuler100 solutions</title>
      <dc:creator>Alex Parra</dc:creator>
      <pubDate>Sun, 05 Jan 2020 14:00:06 +0000</pubDate>
      <link>https://dev.to/alexparra/creating-a-js-repo-for-your-projecteuler100-solutions-3m39</link>
      <guid>https://dev.to/alexparra/creating-a-js-repo-for-your-projecteuler100-solutions-3m39</guid>
      <description>&lt;h1&gt;
  
  
  Intro
&lt;/h1&gt;

&lt;p&gt;If you haven't ever solved the Project Euler problems, you now have a good opportunity by committing to the &lt;a href="https://twitter.com/search?q=%23ProjectEuler100"&gt;#ProjectEuler100&lt;/a&gt; challenge posted by &lt;a href="https://dev.to/ossia"&gt;Quincy Larson&lt;/a&gt;. Find out more about this on the &lt;a href="https://www.freecodecamp.org/news/projecteuler100-coding-challenge-competitive-programming/"&gt;announcement post&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Topic
&lt;/h1&gt;

&lt;p&gt;As described in the announcement post, you can go through the problems on the &lt;a href="https://projecteuler.net/archives"&gt;Project Euler website&lt;/a&gt; or solve them on &lt;a href="https://www.freecodecamp.org/learn/coding-interview-prep/project-euler/"&gt;freeCodeCamp&lt;/a&gt; as there you have ready made tests to run against your code instantly. Plus it'll be recorded on your freeCodeCamp profile.&lt;/p&gt;

&lt;p&gt;But, as the challenge requires posting a link your solution on a GitHub repo, you'll need it anyhow. As I was creating mine I though some of you would benefit from a little help in creating your own repo with tests. So here we are...&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 1 - Create a repo
&lt;/h1&gt;

&lt;p&gt;Head over to your GitHub main page and create a new repo: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Name it &lt;code&gt;project-euler-100&lt;/code&gt; or something similar;&lt;/li&gt;
&lt;li&gt;Fill the description with whatever you wish;&lt;/li&gt;
&lt;li&gt;Leave &lt;code&gt;Public&lt;/code&gt; checked;&lt;/li&gt;
&lt;li&gt;Check &lt;code&gt;Initialize this repository with a README&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;On &lt;code&gt;Add .gitignore&lt;/code&gt; select &lt;code&gt;Node&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;Click &lt;code&gt;Create repository&lt;/code&gt;;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Step 2 - Clone the repo to your machine
&lt;/h1&gt;

&lt;p&gt;On your computer Terminal, &lt;code&gt;cd&lt;/code&gt; into a folder where you'd like to keep your projects and clone the repo with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/USERNAME/REPONAME.git
&lt;span class="c"&gt;# You can get the above url on the GitHub repo page:&lt;/span&gt;
&lt;span class="c"&gt;# 1. by clicking the green `Clone or Download` button. &lt;/span&gt;
&lt;span class="c"&gt;# 2. by copying from the browser address bar.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above will create a directory with the same name as your repo with two files: &lt;code&gt;.gitignore&lt;/code&gt; and &lt;code&gt;README&lt;/code&gt;. &lt;br&gt;
Now &lt;code&gt;cd&lt;/code&gt; into that folder and open it with your preferred code editor. For VSCode do &lt;code&gt;code .&lt;/code&gt;.&lt;/p&gt;
&lt;h1&gt;
  
  
  Step 3 - Adding dependencies
&lt;/h1&gt;

&lt;p&gt;We want to be able to run tests on our code and we'll do that with &lt;a href="https://jestjs.io/"&gt;Jest&lt;/a&gt;. We also want to use ES6 &lt;code&gt;imports&lt;/code&gt; so we'll also need &lt;a href="https://babeljs.io/"&gt;Babel&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Before installing dependencies we need to create a &lt;code&gt;package.json&lt;/code&gt; file. &lt;br&gt;
On your Terminal, at the repo folder root, type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some questions will be asked for you to customise the values of &lt;code&gt;package.json&lt;/code&gt;. To use defaults, just press &lt;code&gt;ENTER&lt;/code&gt; on all or run &lt;code&gt;yarn init -y&lt;/code&gt; instead.&lt;/p&gt;

&lt;p&gt;Now we'll install our dependencies with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add &lt;span class="nt"&gt;--dev&lt;/span&gt; jest babel-jest @babel/core @babel/preset-env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above will add a &lt;code&gt;devDependencies&lt;/code&gt; property to &lt;code&gt;package.json&lt;/code&gt; and also create a new &lt;code&gt;node_modules&lt;/code&gt; folder with the dependencies required.&lt;/p&gt;

&lt;p&gt;We need to configure babel by creating a file named &lt;code&gt;babel.config.js&lt;/code&gt; at the root of our repo folder. An easy way is to run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;babel.config.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;code&gt;babel.config.js&lt;/code&gt; with your code editor and set it's contents to:&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="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="na"&gt;presets&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="s1"&gt;@babel/preset-env&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;targets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;current&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="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;Finally, we need to edit our &lt;code&gt;package.json&lt;/code&gt; file and create a &lt;code&gt;scripts&lt;/code&gt; property as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&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;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jest"&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;Here is the full content of my &lt;code&gt;package.json&lt;/code&gt; right now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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="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;"project-euler-100"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"index.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"repository"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://github.com/alex-parra/project-euler-100.git"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"license"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"MIT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"devDependencies"&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;"@babel/core"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^7.7.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;"@babel/preset-env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^7.7.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;"babel-jest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^24.9.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"jest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^24.9.0"&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;"scripts"&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;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"jest"&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;To verify it's all set up fine run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should get the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn run v1.21.1
&lt;span class="nv"&gt;$ &lt;/span&gt;jest
No tests found, exiting with code 1
&lt;span class="c"&gt;# more info about the "error"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a good time to commit our changes so far as in the next step we'll create the files for the first problem.&lt;/p&gt;

&lt;p&gt;Before committing, run &lt;code&gt;git status&lt;/code&gt; to make sure which files are being committed. You should see &lt;code&gt;babel.config.js&lt;/code&gt;, &lt;code&gt;package.json&lt;/code&gt; and &lt;code&gt;yarn.lock&lt;/code&gt; listed as &lt;em&gt;Untracked files&lt;/em&gt;. &lt;br&gt;
The &lt;code&gt;node_modules&lt;/code&gt; folder should not be committed as it contains third-party code. Our &lt;code&gt;.gitignore&lt;/code&gt; file as an entry for it to tell &lt;code&gt;git&lt;/code&gt; to ignore it.&lt;br&gt;
If you're on a Mac, you may see a &lt;code&gt;.DS_Store&lt;/code&gt; file as &lt;em&gt;Untracked&lt;/em&gt;. These files can/should also be ignored by &lt;code&gt;git&lt;/code&gt;. Add a line to &lt;code&gt;.gitignore&lt;/code&gt; with &lt;code&gt;.DS_Store&lt;/code&gt; to ignore them.&lt;/p&gt;

&lt;p&gt;Now the commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="c"&gt;# add all untracked files to the staging area&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Set up dependencies"&lt;/span&gt; &lt;span class="c"&gt;# commit with message&lt;/span&gt;
git push &lt;span class="c"&gt;# push latest commit to GitHub remote&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Step 4 - The first problem
&lt;/h1&gt;

&lt;p&gt;In this post, I won't solve the first problem. That's on you. ;)&lt;br&gt;
But I'll show you how to set up the folder and files in a way that allows you to run the tests on your code locally.&lt;/p&gt;

&lt;p&gt;Start by creating a folder for the problem to be solved. In this case, we'll create a folder named &lt;code&gt;001-multiples-of-3-and-5&lt;/code&gt;.&lt;br&gt;
Inside that folder create a file named &lt;code&gt;001-multiples-of-3-and-5.js&lt;/code&gt; and another named &lt;code&gt;001-multiples-of-3-and-5.spec.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In order to make it easy to code locally and also post the solutions on freeCodeCamp, we'll keep the naming used on the freeCodeCamp stubs.&lt;br&gt;
As such, you can go to &lt;a href="https://www.freecodecamp.org/learn/coding-interview-prep/project-euler/problem-1-multiples-of-3-and-5"&gt;freeCodeCamp - Project Euler - Problem 1&lt;/a&gt; and copy the function stub present on the right hand pane:&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="nx"&gt;multiplesOf3and5&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Good luck!&lt;/span&gt;
  &lt;span class="k"&gt;return&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The only change we need is to export this function so that we can use it in the tests. As such, make the contents of &lt;code&gt;001-multiples-of-3-and-5.js&lt;/code&gt; look like:&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;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;multiplesOf3and5&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Good luck!&lt;/span&gt;
  &lt;span class="k"&gt;return&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nice!&lt;/p&gt;

&lt;p&gt;Lastly, we need to set up the content of the tests file &lt;code&gt;001-multiples-of-3-and-5.spec.js&lt;/code&gt;.&lt;br&gt;
This file will be run by &lt;em&gt;jest&lt;/em&gt; and needs to import the code file and implement at least one test:&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;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;multiplesOf3and5&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./001-multiples-of-3-and-5&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;multiplesOf3and5(1000) should return 233168&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;multiplesOf3and5&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="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;233168&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;In review:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;we import the function from the implementation file;&lt;/li&gt;
&lt;li&gt;we write tests to validate the return values match what we expect;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's write all the tests present on freeCodeCamp for problem one:&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;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;multiplesOf3and5&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./001-multiples-of-3-and-5&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;multiplesOf3and5(1000) should return 233168&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;multiplesOf3and5&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="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;233168&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;multiplesOf3and5(49) should return 543&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;multiplesOf3and5&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;49&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;543&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;multiplesOf3and5(19564) should return 89301183&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;multiplesOf3and5&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;19564&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;89301183&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;multiplesOf3and5(8456) should return 16687353&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;multiplesOf3and5&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8456&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nx"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16687353&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;And now run the tests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn &lt;span class="nb"&gt;test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should get a long error output that ends with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Test Suites: 1 failed, 1 total
Tests:       4 failed, 4 total
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The error is expected as we haven't implemented our solution yet. And this is also the recommended way to go about it: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;write tests;&lt;/li&gt;
&lt;li&gt;run tests and see them fail; &lt;/li&gt;
&lt;li&gt;write code that makes the tests pass;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's commit what we have and push to GitHub.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Set up is now finished!&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Now it's problem solving time!&lt;br&gt;
Once you get all tests passing, commit the solution and push to GitHub.&lt;br&gt;
Best of luck!&lt;/p&gt;

&lt;h1&gt;
  
  
  A template
&lt;/h1&gt;

&lt;p&gt;I hope you went about the steps above and created your own repo.&lt;br&gt;
In any case, I'll finish this post with a lazy solution for you which is to fork the template repo I made &lt;a href="https://github.com/alex-parra/project-euler-100-js-template"&gt;https://github.com/alex-parra/project-euler-100-js-template&lt;/a&gt;, clone it to your computer and running &lt;code&gt;yarn install&lt;/code&gt; to set up the dependencies.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>projecteuler100</category>
    </item>
    <item>
      <title>CSS display "stack"</title>
      <dc:creator>Alex Parra</dc:creator>
      <pubDate>Thu, 02 Jan 2020 18:55:21 +0000</pubDate>
      <link>https://dev.to/alexparra/css-display-stack-flh</link>
      <guid>https://dev.to/alexparra/css-display-stack-flh</guid>
      <description>&lt;p&gt;&lt;strong&gt;NOTE: &lt;code&gt;display: stack&lt;/code&gt; does not exist. Read on for more info.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;Two and half years ago, I wrote a post on Medium about this possible new kind of display I called &lt;code&gt;stack&lt;/code&gt; that "would be a hybrid of flexbox and z-index".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@alexpds/css-display-stack-7bdc02bc1434"&gt;https://medium.com/@alexpds/css-display-stack-7bdc02bc1434&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This new layout method, would allow the ‘stack’ wrapping element to automatically assume the height of the tallest of it’s childs.&lt;br&gt;
So, with similar syntax to flexbox, we could override the order (z-order) of the various elements, more or less like we can with z-index, but the tallest child would affect the ‘stack’ height and thus no issues with unwanted overflows, uncontrollable overlaps.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Grid to the rescue!
&lt;/h2&gt;

&lt;p&gt;Back then (May 2017), CSS Grid was still being defined and if what I'm showing below was possible back then I didn't know. &lt;br&gt;
But today CSS Grid support is very broad and it allows exactly what I described in the original article.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.stack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-areas&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"stack"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* or whatever name you prefer */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.stack&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;grid-area&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;stack&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* same name as used above without quotes */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.stack&lt;/span&gt; &lt;span class="nc"&gt;.top-most&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;z-index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* default order is 0. Highest shows on top  */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example on CodeSandbox&lt;/strong&gt;&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/0nv9b"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;a href="https://codesandbox.io/s/dry-worker-0nv9b"&gt;https://codesandbox.io/s/dry-worker-0nv9b&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
    </item>
    <item>
      <title>JavaScript - Seconds to HH:MM:SS</title>
      <dc:creator>Alex Parra</dc:creator>
      <pubDate>Tue, 31 Dec 2019 10:35:19 +0000</pubDate>
      <link>https://dev.to/alexparra/js-seconds-to-hh-mm-ss-22o6</link>
      <guid>https://dev.to/alexparra/js-seconds-to-hh-mm-ss-22o6</guid>
      <description>&lt;p&gt;Yesterday, while making a game where I wanted to show the time elapsed since the game started I put together this short helper:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SECONDS_PER_DAY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;86400&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;HOURS_PER_DAY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/**
 * Convert seconds to HH:MM:SS
 * If seconds exceeds 24 hours, hours will be greater than 24 (30:05:10)
 *
 * @param {number} seconds
 * @returns {string}
 */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;secondsToHms&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;string&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;days&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;SECONDS_PER_DAY&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;remainderSeconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="nx"&gt;SECONDS_PER_DAY&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;hms&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;remainderSeconds&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toISOString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;substring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;19&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;hms&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;(\d&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;days&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;HOURS_PER_DAY&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;padStart&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The above converts seconds &lt;code&gt;1234&lt;/code&gt; to &lt;code&gt;00:20:34&lt;/code&gt;.&lt;/strong&gt;&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="nx"&gt;secondsToHms&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1234&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// '00:20:34'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first version I wrote didn't handle the case of seconds being over 24 hours. &lt;br&gt;
Not really needed in the situation at hand but for the sake of completeness I opted to handle it, especially because &lt;a href="https://www.google.com/search?q=js+seconds+to+hh+mm+ss"&gt;the various existing examples I've found&lt;/a&gt; don't deal with the day overflow and that's why I decided to share this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interactive and tested at CodeSandbox&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://codesandbox.io/embed/js-seconds-to-hhmmss-32zo4?fontsize=14&amp;amp;hidenavigation=1&amp;amp;module=%2Findex.ts&amp;amp;previewwindow=tests&amp;amp;theme=dark"&gt;https://codesandbox.io/embed/js-seconds-to-hhmmss-32zo4?fontsize=14&amp;amp;hidenavigation=1&amp;amp;module=%2Findex.ts&amp;amp;previewwindow=tests&amp;amp;theme=dark&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/32zo4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hope it's useful to you. Cheers.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PS: In case you prefer plain JavaScript...&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;const&lt;/span&gt; &lt;span class="nx"&gt;SECONDS_PER_DAY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;86400&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;HOURS_PER_DAY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/**
 * Convert seconds to HH:MM:SS
 * If seconds exceeds 24 hours, hours will be greater than 24 (30:05:10)
 *
 * @param {number} seconds
 * @returns {string}
 */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;secondsToHms&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;seconds&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;days&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;SECONDS_PER_DAY&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;remainderSeconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="nx"&gt;SECONDS_PER_DAY&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;hms&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;remainderSeconds&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;toISOString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;substring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;19&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;hms&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;(\d&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;days&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;HOURS_PER_DAY&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;padStart&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
    </item>
    <item>
      <title>filterMap - JavaScript filter and map in O(n)</title>
      <dc:creator>Alex Parra</dc:creator>
      <pubDate>Mon, 18 Nov 2019 12:52:24 +0000</pubDate>
      <link>https://dev.to/alexparra/filtermap-javascript-filter-and-map-in-o-n-57p6</link>
      <guid>https://dev.to/alexparra/filtermap-javascript-filter-and-map-in-o-n-57p6</guid>
      <description>&lt;p&gt;It's common that we need to get a subset of items from an array. For example, get only the users that are subscribed to the newsletter from the list of all users. This is commonly a job for Array.filter.&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="cm"&gt;/**
 * Get list of subscribed users
 * @param {User[]} users The list of all users
 * @retuns {User[]} Only users that are subscribed
 */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getSubscribedUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;is_subscribed&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 also common that we need to apply some transformation to a set of data. For example, get a list of full names from a list of users by concatenating each user's &lt;code&gt;first_name&lt;/code&gt; and &lt;code&gt;last_name&lt;/code&gt;.&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="cm"&gt;/**
 * Get list of users full names
 * @param {User[]} users The list of all users
 * @retuns {string[]} Users full names
 */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getUsersFullNames&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;first_name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;last_name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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;*&lt;em&gt;But what if we need the full names of the subscribed users only?&lt;/em&gt;&lt;br&gt;
Frequently we'll see:&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;const&lt;/span&gt; &lt;span class="nx"&gt;subscribedUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;getSubscribedUsers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&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;subscribedUsersNames&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;getUsersFullNames&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;subscribedUsers&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem with this approach, which might not be too significant on a small set of users but is when dealing with large sets, is that it requires two loops: the first across every &lt;code&gt;user&lt;/code&gt; and the second across every &lt;code&gt;subscribedUser&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The method I'm sharing with you here accomplishes the same result but looping just once over the data set – O(n) – thus making it more performant:&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;const&lt;/span&gt; &lt;span class="nx"&gt;isFn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;function&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/**
 * Filter and Map an Array in a single loop
 * @param {array} arr The list to process
 * @param {function} filterFn The filtering logic
 * @param {function} mapFn The transforming logic
 */&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;filterMap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;filterFn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;mapFn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;item&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isFn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filterFn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;filterFn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&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="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;false&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;acc&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;newItem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;isFn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mapFn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;mapFn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&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="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;newItem&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="p"&gt;};&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;And an example usage would be:&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;const&lt;/span&gt; &lt;span class="nx"&gt;isSubscribed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;is_subscribed&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;getFullName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;first_name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;last_name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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;subscribedUsersNames&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;filterMap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isSubscribed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getFullName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, &lt;code&gt;isSubscribed&lt;/code&gt; is a utility function that will be used to evaluate if the item (each &lt;code&gt;user&lt;/code&gt;) should be kept or excluded, and &lt;code&gt;getFullName&lt;/code&gt; is a utility function that will determine the data we get back in the new list.&lt;/p&gt;

&lt;p&gt;Check it out at CodeSandbox with tests:&lt;br&gt;
&lt;a href="https://codesandbox.io/embed/js-array-filtermap-mvi1q?fontsize=14&amp;amp;hidenavigation=1&amp;amp;module=%2Findex.ts&amp;amp;previewwindow=tests&amp;amp;theme=dark"&gt;https://codesandbox.io/embed/js-array-filtermap-mvi1q?fontsize=14&amp;amp;hidenavigation=1&amp;amp;module=%2Findex.ts&amp;amp;previewwindow=tests&amp;amp;theme=dark&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Spotted a mistake?&lt;/strong&gt; Let me know!&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Basic Svelte app with Parcel</title>
      <dc:creator>Alex Parra</dc:creator>
      <pubDate>Sat, 19 Oct 2019 15:55:39 +0000</pubDate>
      <link>https://dev.to/alexparra/basic-svelte-app-with-parcel-30i5</link>
      <guid>https://dev.to/alexparra/basic-svelte-app-with-parcel-30i5</guid>
      <description>&lt;p&gt;The easiest way to start a Svelte app is to use &lt;code&gt;create-svelte-app&lt;/code&gt; (&lt;a href="https://github.com/ph1p/create-svelte-app" rel="noopener noreferrer"&gt;https://github.com/ph1p/create-svelte-app&lt;/a&gt;) which uses &lt;em&gt;webpack&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;But going through a setup of your own allows for more freedom and increased knowledge... So the following is a step-by-step approach to setting up your own Svelte app from scratch, using Parcel.js bundler. &lt;/p&gt;

&lt;h2&gt;
  
  
  Kick-off
&lt;/h2&gt;

&lt;p&gt;On your terminal, navigate to wherever you put your dev projects in and create a directory with a name of your choosing by running &lt;code&gt;mkdir myFirstSvelteApp&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then, &lt;code&gt;cd&lt;/code&gt; into the newly created directory and initialise a &lt;code&gt;git&lt;/code&gt; repo with &lt;code&gt;git init&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, run &lt;code&gt;yarn init&lt;/code&gt; to quickly set up the project details in &lt;code&gt;package.json&lt;/code&gt;. This will show some questions that you can either accept the default (leave blank and press &lt;code&gt;Enter&lt;/code&gt;) or type in something more fitting.  &lt;/p&gt;

&lt;p&gt;With the basic done, we now need to install a couple of packages:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;parcel-bundler&lt;/code&gt; &lt;a href="https://parceljs.org/" rel="noopener noreferrer"&gt;Parcel.js&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;svelte&lt;/code&gt; &lt;a href="https://svelte.dev/" rel="noopener noreferrer"&gt;Svelte&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;parcel-plugin-svelte&lt;/code&gt; (&lt;a href="https://github.com/DeMoorJasper/parcel-plugin-svelte" rel="noopener noreferrer"&gt;https://github.com/DeMoorJasper/parcel-plugin-svelte&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can easily install all with a single command:&lt;br&gt;
&lt;code&gt;yarn add -D parcel-bundler parcel-plugin-svelte svelte&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As we're using the &lt;code&gt;-D&lt;/code&gt; flag, these will be installed as &lt;code&gt;devDependencies&lt;/code&gt;.  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you now open your &lt;code&gt;package.json&lt;/code&gt; file you'll see not only the content of the questions you answered after &lt;code&gt;yarn init&lt;/code&gt; but also a section &lt;code&gt;devDependencies&lt;/code&gt; with the entries listed above. Also note that &lt;code&gt;yarn add&lt;/code&gt; not only added the dependencies to &lt;code&gt;package.json&lt;/code&gt; but also installed them so you now have a &lt;code&gt;node_modules&lt;/code&gt; folder with all the packages needed.  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As an extra exercise, if you need to get a better feel of how dependencies "work", delete the &lt;code&gt;node_modules&lt;/code&gt; folder with &lt;code&gt;rm -rf ./node_modules/&lt;/code&gt; and then run &lt;code&gt;yarn install&lt;/code&gt; which will recreate it and download/install all the packages from scratch.  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Before we make our first &lt;code&gt;commit&lt;/code&gt; to save what we did above, we need to tell &lt;code&gt;git&lt;/code&gt; to ignore the &lt;code&gt;node_modules&lt;/code&gt; folder and some other default files. You may have these already ignored via a global &lt;code&gt;gitignore&lt;/code&gt; but it's wise to have it at the project root.&lt;br&gt;
As such, a quick way to create a &lt;code&gt;.gitignore&lt;/code&gt; file that tells &lt;code&gt;git&lt;/code&gt; to disregard &lt;code&gt;node_modules&lt;/code&gt; and other sensitive files is below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "node_modules" &amp;gt;&amp;gt; ./.gitignore
echo "dist" &amp;gt;&amp;gt; ./.gitignore
echo ".cache" &amp;gt;&amp;gt; ./.gitignore
echo ".env" &amp;gt;&amp;gt; ./.gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Each line above appends the content between double-quotes into the file .gitignore. You can also manually edit the file in VS Code or similar. This file can have comments with &lt;code&gt;#&lt;/code&gt; as a marker.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It's highly advisable to also create a &lt;code&gt;README.md&lt;/code&gt; file with details about this project but I won't go into detail about it on this post. &lt;br&gt;
In my opinion, this is a good time to make a first commit.&lt;/p&gt;


&lt;h2&gt;
  
  
  Getting some Hello
&lt;/h2&gt;

&lt;p&gt;As we've left it, we're still missing a couple of things. &lt;br&gt;
Let's get to it... We need to create the basic app files which will be:&lt;br&gt;
&lt;code&gt;./src/index.html&lt;/code&gt; &lt;em&gt;used by parcel as starting point&lt;/em&gt;&lt;br&gt;
&lt;code&gt;./src/index.js&lt;/code&gt; &lt;em&gt;our boot up script&lt;/em&gt;&lt;br&gt;
&lt;code&gt;./src/components/App.svelte&lt;/code&gt; &lt;em&gt;the root component&lt;/em&gt;&lt;br&gt;
&lt;code&gt;./src/css/styles.scss&lt;/code&gt; &lt;em&gt;our global generic styles&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note the subfolders &lt;code&gt;src&lt;/code&gt;, &lt;code&gt;src/components&lt;/code&gt;, &lt;code&gt;src/css&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  index.html
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"utf8"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Svelte with Parcel&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"./css/styles.scss"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"./index.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Parcel.js will read this file and compile whatever it "imports". &lt;br&gt;
This file is just pure HTML.&lt;/p&gt;
&lt;h3&gt;
  
  
  index.js
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./components/App.svelte&lt;/span&gt;&lt;span class="dl"&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;App&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Svelte&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This file is parsed by Parcel.js because it is referenced in &lt;code&gt;index.html&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  App.svelte
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Hello {name}!&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This is our root component. We'll keep it really basic now.&lt;/p&gt;
&lt;h3&gt;
  
  
  styles.scss
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;html&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;*,&lt;/span&gt;
&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nd"&gt;:after&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;box-sizing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inherit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;-apple-system&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;BlinkMacSystemFont&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'Segoe UI'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Roboto&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Oxygen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Ubuntu&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Cantarell&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'Open Sans'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'Helvetica Neue'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;scroll-behavior&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;smooth&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-rendering&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;optimizeSpeed&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#212223&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;flex-direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&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;Just regular &lt;code&gt;scss&lt;/code&gt;. Import partials, declare variables, etc...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Almost there!!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In order to easily run the parcel bundler in &lt;code&gt;dev&lt;/code&gt; mode or build for production we're going to add a &lt;code&gt;scripts&lt;/code&gt; section to our &lt;code&gt;package.json&lt;/code&gt; file:&lt;br&gt;
&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="nl"&gt;"browserslist"&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="s2"&gt;"last 1 chrome versions"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&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;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"parcel src/index.html"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"parcel build src/index.html"&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;blockquote&gt;
&lt;p&gt;Add the above, wherever you prefer inside &lt;code&gt;package.json&lt;/code&gt; as long as it's inside the root &lt;code&gt;{}&lt;/code&gt;.&lt;br&gt;
The &lt;code&gt;browserslist&lt;/code&gt; entry is need to prevent a compilation bug. &lt;a href="https://github.com/DeMoorJasper/parcel-plugin-svelte/issues/44" rel="noopener noreferrer"&gt;More info&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;All done!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At your root folder, run &lt;code&gt;yarn dev&lt;/code&gt; and then open &lt;code&gt;http:localhost:1234&lt;/code&gt;&lt;br&gt;
You should see:&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fnwlcirlnf6jp966nkpyo.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%2Fnwlcirlnf6jp966nkpyo.png" alt="Hello Svelte"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now head over to the &lt;a href="https://svelte.dev/tutorial/basics" rel="noopener noreferrer"&gt;Svelte tutorial&lt;/a&gt; and try it out on your newly created app.&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

&lt;p&gt;PS: This took way longer to write than I imagined and much much longer that the process itself takes. Phew...&lt;/p&gt;

</description>
      <category>svelte</category>
      <category>parceljs</category>
    </item>
    <item>
      <title>Prevent scroll “bubbling”</title>
      <dc:creator>Alex Parra</dc:creator>
      <pubDate>Sat, 19 Oct 2019 07:40:16 +0000</pubDate>
      <link>https://dev.to/alexparra/prevent-scroll-bubbling-3j3</link>
      <guid>https://dev.to/alexparra/prevent-scroll-bubbling-3j3</guid>
      <description>&lt;p&gt;A few days ago I stumbled upon a post about a CSS property I hadn’t seen before: overscroll-behavior &lt;/p&gt;

&lt;p&gt;As per MDN docs:&lt;br&gt;
“ The overscroll-behavior CSS property sets what a browser does when reaching the boundary of a scrolling area. It's a shorthand for overscroll-behavior-x and overscroll-behavior-y.”&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It struck me as it was exactly what we needed on a piece of overlayed ui that had inner scroll and was causing the less than ideal effect of scrolling the entire page too. &lt;/p&gt;

&lt;p&gt;Tested it out yesterday and it did the job wonderfully. &lt;/p&gt;

&lt;p&gt;So, apart from some exceptions, whenever you set &lt;code&gt;overflow: auto&lt;/code&gt; on a panel or some modal content, add this property too: &lt;code&gt;overscroll-behavior: contain&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Although it’s still in Draft, it already has a fairly broad browser support:&lt;/p&gt;

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

&lt;p&gt;It’s also available at CanIUse:&lt;br&gt;
&lt;a href="https://caniuse.com/#feat=css-overscroll-behavior"&gt;https://caniuse.com/#feat=css-overscroll-behavior&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>ux</category>
    </item>
    <item>
      <title>What’s your preferred way to test Internet Explorer and Edge from Linux or Mac?</title>
      <dc:creator>Alex Parra</dc:creator>
      <pubDate>Mon, 19 Aug 2019 12:54:52 +0000</pubDate>
      <link>https://dev.to/alexparra/what-s-your-preferred-way-to-test-internet-explorer-and-edge-from-linux-or-mac-39ai</link>
      <guid>https://dev.to/alexparra/what-s-your-preferred-way-to-test-internet-explorer-and-edge-from-linux-or-mac-39ai</guid>
      <description>&lt;p&gt;I’m setting up Parallels with Microsoft’s free developer images. &lt;/p&gt;

&lt;p&gt;Do you have a better way?&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Insightful Quotes</title>
      <dc:creator>Alex Parra</dc:creator>
      <pubDate>Sun, 11 Aug 2019 14:55:57 +0000</pubDate>
      <link>https://dev.to/alexparra/insightful-quotes-21lg</link>
      <guid>https://dev.to/alexparra/insightful-quotes-21lg</guid>
      <description>&lt;p&gt;‪“We’ve always been better at inventing tools than at using them wisely.”‬&lt;br&gt;
‪— Yuval Noah Harari ‬&lt;/p&gt;

&lt;p&gt;Your turn...&lt;/p&gt;

</description>
    </item>
    <item>
      <title>GitHub - Set up SSH Key</title>
      <dc:creator>Alex Parra</dc:creator>
      <pubDate>Sun, 28 Jul 2019 13:16:59 +0000</pubDate>
      <link>https://dev.to/alexparra/github-set-up-ssh-key-2n8d</link>
      <guid>https://dev.to/alexparra/github-set-up-ssh-key-2n8d</guid>
      <description>&lt;h3&gt;
  
  
  TLDR
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Generate Key: &lt;code&gt;ssh-keygen -t rsa -b 4096 -C "your_email@example.com"&lt;/code&gt;&lt;br&gt;&lt;br&gt;
Use descriptive name: &lt;code&gt;/Users/[YourUser]/.ssh/github-[user]-[machine]&lt;/code&gt;&lt;br&gt;&lt;br&gt;
Set a passphrase: &lt;code&gt;something-i-will-never-forget&lt;/code&gt;&lt;br&gt;&lt;br&gt;
Add to ssh-agent: &lt;code&gt;eval "$(ssh-agent -s)" &amp;amp;&amp;amp; ssh-add -K ~/.ssh/MY_KEY_NAME&lt;/code&gt;&lt;br&gt;&lt;br&gt;
Copy public key: &lt;code&gt;pbcopy &amp;lt; ~/.ssh/MY_KEY_NAME.pub&lt;/code&gt;&lt;br&gt;&lt;br&gt;
Paste key at GitHub: &lt;code&gt;Settings&lt;/code&gt; &amp;gt; &lt;code&gt;SSH Keys&lt;/code&gt; &amp;gt; &lt;code&gt;New SSH Key&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The SSH protocol, allows you to securely connect and authenticate to remote servers and services. Setting up SSH keys on your GitHub account for each computer you work on, allows you to pull/push/commit without supplying your username or constantly typing your password.  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To know more about SSH, see &lt;a href="https://en.wikipedia.org/wiki/Secure_Shell"&gt;https://en.wikipedia.org/wiki/Secure_Shell&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this article, we'll go through the steps of generating a new SSH key &lt;strong&gt;on a Mac&lt;/strong&gt; and registering it on your GitHub account. While I've done this more than I can count, I always have to check the steps so this article also serves as a quick future reference for me.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Do I have any SSH keys on this machine?
&lt;/h2&gt;

&lt;p&gt;The following command lists the contents of the &lt;code&gt;.ssh&lt;/code&gt; folder of the current user. &lt;strong&gt;SSH keys are just "plain" text files!&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls -al ~/.ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  So how exactly can I generate an SSH key?
&lt;/h2&gt;

&lt;p&gt;On your preferred Terminal app, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next you'll be asked where to save the key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since you'll probably have more than one key, it's better to not accept the default suggestion &lt;code&gt;/Users/[YourUser]/.ssh/id_rsa&lt;/code&gt; and instead use something like:&lt;br&gt;&lt;br&gt;
&lt;code&gt;/Users/[YourUser]/.ssh/github-[user]-[machine]&lt;/code&gt;&lt;br&gt;&lt;br&gt;
 &lt;br&gt;&lt;br&gt;
This will make it easier to know which key is used where.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;We'll refer to the name chosen above for the SSH key as &lt;code&gt;MY_KEY_NAME&lt;/code&gt;, in the rest of this article&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
   &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;In my experience, the path entered needs to be absolute so you can't use &lt;code&gt;~/.ssh/some-key-name&lt;/code&gt;.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
 &lt;br&gt;&lt;br&gt;
The rationale of using a generic &lt;code&gt;id_rsa&lt;/code&gt; name is that you can have just one key that identifies this computer and you use that key on any services (GitHub, BitBucket, etc...) that you need to access. If at some point you need to revoke access to a certain service, you can delete the key on that service settings. (GitHub profile settings, etc...).&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Personally I find it clearer to have specific keys for each service.&lt;/strong&gt;  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Lastly, you'll be prompted to enter a passphrase.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Enter passphrase (empty for no passphrase):
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This allows securing your SSH key. While you can leave this empty (press ENTER) and not use a passphrase &lt;strong&gt;it's usually highly recommended&lt;/strong&gt;. And by adding the key to &lt;code&gt;ssh-agent&lt;/code&gt; via &lt;code&gt;ssh-add&lt;/code&gt; we'll avoid having to type it constantly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;At this point, your new SSH key has been created&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
You can see it by running the list command: &lt;code&gt;ls -al ~/.ssh&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You'll see two entries with &lt;code&gt;MY_KEY_NAME&lt;/code&gt;. One is the private key which you should never share and the other, ending in &lt;code&gt;.pub&lt;/code&gt;, is the public key, which you can use to gain access to remote services. Whenever you need to provide your SSH key, you always give the &lt;code&gt;public&lt;/code&gt; key, never the &lt;code&gt;private&lt;/code&gt; key.  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's ensure the SSH agent "knows" about our new key and loads it automatically, which saves us from having to constantly re-type the passphrase.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Run each of the lines below in you terminal app:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;eval "$(ssh-agent -s)" &amp;amp;&amp;amp; ssh-add -K ~/.ssh/MY_KEY_NAME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We've finished generating a new SSH key, named it with a clear name that allows us to differentiate the keys in the future should we have more that one, and saved it to the ssh-agent so we don't need to constantly type the passphrase.&lt;br&gt;&lt;br&gt;
 &lt;br&gt;&lt;br&gt;
But GitHub has no knowledge of this key yet...  &lt;/p&gt;
&lt;h2&gt;
  
  
  Hey GitHub, here's my new SSH key!
&lt;/h2&gt;

&lt;p&gt;Start by copying the &lt;code&gt;public&lt;/code&gt; key (note the ending &lt;code&gt;.pub&lt;/code&gt;) to the clipboard so we can paste it at GitHub's dashboard:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pbcopy &amp;lt; ~/.ssh/MY_KEY_NAME.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now go to your GitHub account Settings &amp;gt; SSH Keys. At the time of writing the URL is &lt;a href="https://github.com/settings/keys"&gt;https://github.com/settings/keys&lt;/a&gt; and click the button &lt;code&gt;New SSH Key&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
You'll see a form with two fields:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Title&lt;/code&gt;: Enter a descriptive name for this key. Ex: &lt;code&gt;My Work Mac&lt;/code&gt;&lt;br&gt;&lt;br&gt;
it's important to use a clear title as it's what will allow you to know which key is used where and as such know which ones can/should be deleted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Key&lt;/code&gt;: Hit &lt;code&gt;CMD+V&lt;/code&gt; to paste the SSH public key copied above.&lt;br&gt;&lt;br&gt;
it should be a long string that starts with &lt;code&gt;ssh-rsa ...&lt;/code&gt; and ends with the email address entered when the key was created.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Yay! All done!
&lt;/h2&gt;

&lt;p&gt;Hope this article has been useful for you.&lt;br&gt;&lt;br&gt;
Any amends or suggestions are welcome in the comments below.  &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>github</category>
      <category>ssh</category>
    </item>
  </channel>
</rss>
