<?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: HarveyDanger</title>
    <description>The latest articles on DEV Community by HarveyDanger (@harveydanger).</description>
    <link>https://dev.to/harveydanger</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%2F134472%2Fc622ca56-8c0f-452c-98cf-8b27fba54c00.png</url>
      <title>DEV Community: HarveyDanger</title>
      <link>https://dev.to/harveydanger</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harveydanger"/>
    <language>en</language>
    <item>
      <title>Which programming language is the best out there!</title>
      <dc:creator>HarveyDanger</dc:creator>
      <pubDate>Fri, 04 Oct 2019 05:45:52 +0000</pubDate>
      <link>https://dev.to/harveydanger/which-programming-language-is-the-best-out-there-4aac</link>
      <guid>https://dev.to/harveydanger/which-programming-language-is-the-best-out-there-4aac</guid>
      <description>&lt;h1&gt;
  
  
  A-HA! Got your attention.
&lt;/h1&gt;

&lt;p&gt;Long story short, the answer is &lt;strong&gt;It does not matter&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Reasoning behind that statement.
&lt;/h1&gt;

&lt;p&gt;For quite a while now I am serving as a Software Engineer with two Master degrees and publication in Robotics.&lt;/p&gt;

&lt;p&gt;Throughout my professional life I have met loads of other developers, good and not that much. The only thing though, binding them all together in one group is a simple statement : "I hate this, and I like this"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Nah.. I am not going to participate in the holy war :) Don't ask who prefers what. Though I will provide some of the examples&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When it comes to development planning, you may think of the following.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"I might stick to the Node.js in my web application"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;OR &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"I am the Python dood.. logic should be done in Python!"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;OR even better&lt;br&gt;
&lt;em&gt;read with &lt;strong&gt;viking accent&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Ya all mates are stoopid, Functional Programming and Haskell, a sir - war axe would cut your bugs in half O_O "&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Well, surprisingly you are all right. You have chosen a platform and a paradigm that comes with it for free. However, a person who has strong skills in systems development will say: "brah.. morons, C\C++ is the fastest I only make FASTEST software out there".&lt;/p&gt;

&lt;p&gt;Why am I playing comedy here? It is very simple. Human being is very protective animal and always tries to defend the only holy opinion (not all :) but many). However, being a rough C++ bloke does not mean you are always right (I am with you guys, I am C++ dev as well, I know that feeling.)&lt;/p&gt;

&lt;p&gt;This protectiveness defines the relationship between a technology and a choice you make when starting a new project. However, things can be achieved with different technologies and you will never know the difference as a user full stop.&lt;/p&gt;

&lt;h1&gt;
  
  
  Ok, a few examples from holy war book of Knowledge (HWBoK)
&lt;/h1&gt;

&lt;p&gt;Nowadays, people tend to say that Node.js is the choice number one, NASA uses it; but at the same time not many of those people would think in which particular field it is used. And as a result, we have 100% "async-await hell" compatible software that runs smooth. Could you achieve the same thing with Python, PHP, JAVA, C, Rust, Go, FORT.. .. blah and blah. &lt;strong&gt;The answer is yes.&lt;/strong&gt; And it would all work well on the current hardware. Let's admit, that if you are making something very very big and important, you are probably at the stage when you defo know what tech. to utilise.&lt;/p&gt;

&lt;h1&gt;
  
  
  Wait, hang on.. he is bu11shEEtn us!
&lt;/h1&gt;

&lt;p&gt;No, unfortunately, I am a witness of having "hevay computations" on node.js, while some would say, make it on Go, it is faster. It does its job though!. Moreover, I don't want to praise node.js, instead I am not a big fan of it, but using it heavily for different tasks. What I am saying here: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;It does not really matter what you choose, you can do that (if you are not programming something like Opportunity - would be funny to see it running on node.js tho)&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Which means that the more technologies you know and familiar with, the more freedom of choice you have, and smarter that choice will be! &lt;/p&gt;

&lt;h1&gt;
  
  
  Learn as many languages and frameworks as possible.
&lt;/h1&gt;

&lt;p&gt;When you will have a nice backpack of knowledge behind your back, the probability that you will choose the optimal tool will tend to reach infinity and beyond.&lt;/p&gt;

&lt;p&gt;Don't be inside the box! Love, Learn programming and love every unicorn and crab out there. It makes you wiser and open in your choice.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>thoughts</category>
      <category>opinion</category>
    </item>
    <item>
      <title>Restorator.js - Synchronise your INPUT DOM</title>
      <dc:creator>HarveyDanger</dc:creator>
      <pubDate>Fri, 04 Oct 2019 04:58:09 +0000</pubDate>
      <link>https://dev.to/harveydanger/restorator-js-synchronise-your-input-dom-2jc</link>
      <guid>https://dev.to/harveydanger/restorator-js-synchronise-your-input-dom-2jc</guid>
      <description>&lt;h1&gt;
  
  
  Restorator.js
&lt;/h1&gt;

&lt;p&gt;Restorator - is a tool that synchronises the input from your DOM to Virtual object | Local Storage | Server&lt;/p&gt;

&lt;p&gt;Original repo can be found &lt;a href="https://github.com/HarveyDanger/Restorator"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a simple, yet powerful tool to make an auto save feature on your web app. &lt;/p&gt;

&lt;h1&gt;
  
  
  Simply put it that way
&lt;/h1&gt;

&lt;p&gt;User enters information to the field, and you control, when a snapshot is synchronised between localStorage and server.&lt;/p&gt;

&lt;h1&gt;
  
  
  So what's good about it O_o?
&lt;/h1&gt;

&lt;p&gt;Good thing is that Restorator can then obtain a snapshot from localStorage or remote server and restore the last state where the save action had been performed.&lt;/p&gt;

&lt;h1&gt;
  
  
  Example
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Clone that boilerplate:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/HarveyDanger/WebpackBabel-minimal.git restorator_demo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;this is basically a minimal setup for your demo example. Btw, do not hesitate to use it as well :)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install dependencies and restorator:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install &amp;amp;&amp;amp; npm install restoratorjs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now create a public folder with index.html inside
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir public &amp;amp;&amp;amp; touch public/index.html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Paste contents into that file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="ie=edge"&amp;gt;
    &amp;lt;title&amp;gt;RestoratorJS demo&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;input type="text" id="one"&amp;gt;
    &amp;lt;textarea name="two" id="two" cols="30" rows="10"&amp;gt;&amp;lt;/textarea&amp;gt;
    &amp;lt;input type="text" id="three"&amp;gt;

    &amp;lt;button id="sync"&amp;gt;Sync&amp;lt;/button&amp;gt;
    &amp;lt;script src="bundle.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Navigate to src/main.js and insert the following
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Restorator } from 'restoratorjs';

const r = new Restorator({

        name: "dev_to_example", // instance reference, useful if you use several of those
        applicable:['input', 'textarea', 'select'], // which data fields to sync
        ignoreIds: [''],  // ignore specific DOM ids
        debug: {use: true, highlight: true},  // funny burst in your console :)
        saveLocal: true,  // save to localStorage
        saveRemote: false,  // save to Server. Refer to github repo for details https://github.com/HarveyDanger/Restorator
        onComplete: (json)=&amp;gt;{
            console.log(json);
        } // callback on synchronisation

});

let syncButton = document.getElementById('sync');

syncButton.addEventListener('click', ()=&amp;gt;{
    // Normally you would not have a save button, so you can bind it to the event
    r.Sync({repeat: true, delay: 3000})
    // Other parameters that Sync accepts are crucial for the Server sync. Refer to github.
})
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now simply run
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  How can I test it?
&lt;/h1&gt;

&lt;p&gt;After you started a dev server, you can now fill data to your fields. open a console and then push Sync button. You will see, that Restorator has collected all the data and saved it locally. This example does not assume that you use a server for Sync (it is a separate long topic with backend part, but basically Restorator pushes JSON object with all the inputs).&lt;/p&gt;

&lt;p&gt;Now, reload the page and hit Sync once again and voila. Previous state has been restored.&lt;/p&gt;

&lt;p&gt;Thanks for reading! &lt;br&gt;
Hope you liked it!  &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>dom</category>
      <category>html</category>
    </item>
    <item>
      <title>Vasilisk.js - Powerful HTML input validation tool</title>
      <dc:creator>HarveyDanger</dc:creator>
      <pubDate>Fri, 04 Oct 2019 03:48:42 +0000</pubDate>
      <link>https://dev.to/harveydanger/vasilisk-js-powerful-html-validation-tool-i34</link>
      <guid>https://dev.to/harveydanger/vasilisk-js-powerful-html-validation-tool-i34</guid>
      <description>&lt;h1&gt;
  
  
  TL;DR
&lt;/h1&gt;

&lt;p&gt;Vasilisk is a node.js module that allows you to incorporate HTML input validation on the fly. Original repo can be found &lt;a href="https://github.com/HarveyDanger/VasiliskJS"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  What's the purpose?
&lt;/h1&gt;

&lt;p&gt;Vasilisk is the lightweight tool that allows you to validate field values and logic groups (forms, but without &lt;code&gt;form&lt;/code&gt; tag) on the fly.&lt;/p&gt;

&lt;h1&gt;
  
  
  Features:
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Write once, use anywhere - if you may think of any rough validation, say dates between, you can easily write that function once and apply it to as many fields as you want&lt;/li&gt;
&lt;li&gt;Create Virtual Forms - Vasilisk allows you to combine inputs of any kind to the logical group. This group is validated and fail|success callbacks are triggered once the form is completed or failed respectively. &lt;/li&gt;
&lt;li&gt;Easy to setup settings &lt;em&gt;please refer to the example below&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;No dependencies &lt;/li&gt;
&lt;li&gt;Lightweight&lt;/li&gt;
&lt;li&gt;No busy waiting because of standard js event loop utilisation&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Ready to make your hands dirty?
&lt;/h1&gt;

&lt;p&gt;Vasilisk can be obtained to your project in a classic way... bruh&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install vasilisk
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Quick project setup (may skip if familiar with webpack and babel minimal setup)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;cd&lt;/code&gt; into the directory of your preference e.g. &lt;code&gt;cd ~/Documents/Projects&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;In your terminal write:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir vasilisk_demo &amp;amp;&amp;amp; cd vasilisk_demo &amp;amp;&amp;amp; npm init -y; \
npm install vasilisk &amp;amp;&amp;amp; npm install babel-cli babel-preset-env --save-dev; \
npm install webpack webpack-dev-server webpack-cli --save-dev; \
mkdir src; touch src/main.js; echo "const path=require(\"path\");module.exports={mode:\"development\",entry:\"./src/main.js\",output:{path:path.resolve(__dirname,\"public\"),filename:\"bundle.js\"},devServer:{contentBase:path.join(__dirname,\"public\"),compress:true,port:8989}};" &amp;gt; webpack.config.js; echo "{\"presets\":[[\"env\",{\"targets\": {\"browsers\": [\"last 2 versions\", \"safari &amp;gt;= 7\"]}}]]}" &amp;gt; .babelrc; \
mkdir public; touch public/index.html;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;In the &lt;code&gt;package.json&lt;/code&gt; file, add new script instructions:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
   "build": "webpack --config webpack.config.js",
   "start": "npm run build &amp;amp;&amp;amp; webpack-dev-server"
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to public/index.html file and paste the following snippet. Basically it is a simple web page with 3 input fields
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="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&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&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;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&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, initial-scale=1.0"&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;http-equiv=&lt;/span&gt;&lt;span class="s"&gt;"X-UA-Compatible"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"ie=edge"&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;Vasilisk demo&lt;span class="nt"&gt;&amp;lt;/title&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;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"one"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"one"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"two"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"two"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"three"&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"three"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"bar"&lt;/span&gt;&lt;span class="nt"&gt;&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;"./bundle.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;ul&gt;
&lt;li&gt;In your src/main.js insert the following snippet
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Vasilisk } from 'vasilisk';

const v = new Vasilisk({
    callBackOnEveryValid: true
})

v.CreateGroup(
    'inp-group', // Group ID
    (gid) =&amp;gt; { // Success callback
        alert("All fields are just fine")
    },
    (gid, failed) =&amp;gt; { // Fail callback
        alert(`Bugga, ${failed[0].e.internal.name} has incorrect value`)
    }, [{ // Input fields
            id: 'one', // DOM id
            validation: (elem) =&amp;gt; { // validation rule, must return bool
                return elem.value &amp;gt;= 5
            },
            failed: (elem) =&amp;gt; { // what to do if validation failed
                alert(`Input one can be only 5+, your input is ${elem.value}`)
            }
        },
        { // Input fields
            id: 'two', // DOM id
            validation: (elem) =&amp;gt; { // validation rule, must return bool
                return elem.value === "foo"
            },
            failed: (elem) =&amp;gt; { // what to do if validation failed
                alert(`Incorrect secret word ${elem.value}, should be foo`)
            }
        },
        { // Input fields
            id: 'three', // DOM id
            validation: (elem) =&amp;gt; { // validation rule, must return bool
                return elem.value === "bar"
            },
            pristine: true, // Identifies that by default, on DOM load, this field is correct and valid
            failed: (elem) =&amp;gt; { // what to do if validation failed
                alert(`Incorrect secret word ${elem.value}, should be bar`)
            }
        }
])
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now run webpack development server by executing &lt;code&gt;npm start&lt;/code&gt; and follow the link: &lt;code&gt;http://localhost:8989/&lt;/code&gt; in your browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That was easy, wasn't it? =).&lt;/p&gt;

&lt;p&gt;All other useful features can be found in the &lt;a href="https://github.com/HarveyDanger/VasiliskJS"&gt;repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for the reading, next chapter will have Restorator.js introduction.&lt;/p&gt;

</description>
      <category>validation</category>
      <category>htmlinput</category>
      <category>javascript</category>
      <category>npmmodule</category>
    </item>
  </channel>
</rss>
