teleren/devto huggingface dataset:
Vanilla JavaScript get all elements in a form
Tags: javascript
Published: 2020-12-30 06:01:43

If you ever made your own validation you will understand the struggle of getting all the form elements.

I've made code that would loop over each type of input as such:

```js
types = ['input', 'select', 'texture'];
// Manually loop and get all those
```

That will work, but it's very easy to miss one, and not really maintainable.

Did you know there is a simpler way to retrieve all the elements inside a form?

## Vanilla JavaScript get a form's elements

So let's say we have a form with all kinds of inputs like this:

```html
<form id="form">
  <div class="container">
    <div class="row">
      <label for="firstname">Firstname</label>
      <input type="text" name="firstname" id="firstname" />
    </div>
    <div class="row">
      <label for="email">Email</label>
      <input type="email" name="email" id="email" />
    </div>
    <div class="row">
      <label for="select">Select</label>
      <select name="select" id="select">
        <option value="1">Option 1</option>
        <option value="2">Option 2</option>
      </select>
    </div>
    <div class="row">
      <p>Do you agree?</p>
      <label>
        <input type="radio" name="agree" value="yes">
        Yes
      </label>
      <label>
        <input type="radio" name="agree" value="no">
        No
      </label>
    </div>
    <div class="row">
      <p>Your favorite animal?</p>
      <label>
        <input type="checkbox" name="agree" value="penguin">
        🐧
      </label>
      <label>
        <input type="checkbox" name="agree" value="dog">
        🐶
      </label>
    </div>
  </div>
  </div>
</form>
```

This is a typical form, it has some regular inputs, some select elements, checkboxes, and radio groups.

It also has random markup in between to style your form, see the divs and labels.

So how can we distinguish these elements?

First, let's define a variable that will get our form.

```js
const form = document.getElementById('form');
```

Now it is literally as simple as calling `.elements` on this const.

```js
console.log(form.elements);
```

This will give us an `HTMLFormControlsCollection` which looks as follows.

![HTML form controls collection](https://cdn.hashnode.com/res/hashnode/image/upload/v1608785703987/cI0PzCDa5.png)

As you can see these holds are our form elements, which is already super useful.

You can then loop over them using a forEach loop for instance.

```js
[...form.elements].forEach(item => {
  console.log(item);
});
```

Now it's up to you to create your own validation with this.

You can find this full demo on the following Codepen.

{% codepen https://codepen.io/rebelchris/pen/LYRzaNG %}

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
Calendar / date in java
Tags: java, tutorial, programming, beginners
Published: 2020-12-30 05:58:10

Here I would like to discuss about such objects as _Calendar_ or _Date_ with those, who beggin their way in Java.

**What is the difference in Date and Calendar?**
_Date_ - amount of milliseconds, starting from 01.01.1970
_Calendar_ - work with a usual date

**What is better to use?**
We can't say which way is better, but I prefer _Calendar_ to _Date_ as it is richer in functions and usual for us.

*1. Coding Calendar
Making object
`Calendar calendar = GregorianCalendar.getInstance();`

Set the value of your object
`calendar.set(... , ...);`
The first parameter can be _Calendar.MONTH_, _Calendar.YEAR_, _Calendar.DAY_OF_MONTH_ and so on, like what you set.
The second value is your variable, you set parameter with, and, as you guess, it is _numeric_

You can also use others, but they are similar to each other, so I think only _calendar.add_ is needed.
`calendar.add(parameter,value);`
Change your parameters by adding some value.

*2. Coding Date
Making object
`Date date = new Date();`

How to get the date from Calendar?
`date=calendar.getTime();`

How to get milliseconds?
`long millis = date.getTime();`
Yes, we use _long_ to describe time in our _Date_ (milliseconds)

*3. Display

_Calendar:_
`System.out.println("Date in type CALENDAR:" + calendar.getTime());`

_Date:_
`System.out.println("Date in type DATE:" + String.valueOf(millis));`
Don't forget that to display/write you need to convert into string your value.

*4. Format
There are different ways to change your format (the way it displays value).

_1st - Formatter._
Make object
` Formatter formatter = new Formatter();`

Set the pattern
`formatter.format("%t.. %t.., %t..",object for % 1,object for % 2,object for % 3);`
Here is a useful link with a table of patterns: [Formatter](https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html)
It is used with type _Date_.

Display
`System.out.println("FORMATTER date" + formatter);`

_2nd - SimpleDateFormat:_
Make object
`SimpleDateFormat dateFormat = new SimpleDateFormat("pattern");`
Table with patterns: [SimpleDateFormat](https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html)
Here we also work with type _Date_

Display
`System.out.println("SIMPLEDATEFORMAT date" + dateFormat.format(date));`

*5. Tips
- If you want to change you _Formatter_ pattern or _SimpleDateFormat_ pattern, make another one object. If you change the existing object, you will catch a mistake.
- Always check the _Calendar_ type for the right values (month <13 and so on)
- Set to set, get to get something from _Calendar_

Hopefully, it was useful for you and understable! If you have any questions, write me anytime.

Good luck in your job!
Stroop Test
Tags: dohackathon
Published: 2020-12-30 04:11:42

## What I built
A basic task that demonstrates the Stroop effect occurs when there is a mismatch between the name of a color and the color it is printed on. Adding Speech Recognition to recognize the answers makes it more interactive and the Speech synthesizer will guide you through the test

### series: [“v0.0.1”]

### Category Submission: Built for Business

### App Link: Work in Progress
Github: https://github.com/saravananselvamohan/stroop

### Screenshots
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/m5pdp5sjkw4e3a6813cj.PNG)

### Description
 The famous "Stroop Effect" is named after J. Ridley Stroop who discovered this strange phenomenon in the 1930s. Here is your job: name the colors of the following words. Do NOT read the words...rather, say the color of the words. For example, if the word "BLUE" is printed in a red color, you should say "RED". Say the colors as fast as you can. It is not as easy as you might think!

### Link to Source Code
https://github.com/saravananselvamohan/stroop

### Permissive License
MIT

## Background
To analyze neural skills using the Stroop test

### How I built it 
Built using HTML, JS & CSS
Deploy in DigitalOcean -- Work in Progress


### Additional Resources/Info
https://bennettfeely.com/ztext/
https://faculty.washington.edu/chudler/words.html
https://en.wikipedia.org/wiki/Stroop_effect
Diving In
Published: 2020-12-30 05:31:26

 As a tech enthusiast, am always amazed at how far the world has gone and our problems have been solved using tech. There is that part of me that will say you can fit in and there is another part of me which always say you can solve the problem, even though i know am coming from a non tech background. We are never constrained in problem solving using tech, cos there are lot of technological tools that can be used to solve the same problem, but where the constraint lies is in the thinking and perspective.
Successfully, some may create a solution in which the whole world we go wow, while some will create another solution and it will be a wack. The part that mostly got my attention is design thinking which I think the space there is not totally tapped in globally and locally by SW firms... I am an enthusiast and will soon be a savvy, so I will know what distraction caused the less attention given to the industry of the design thinking.
Answer: 
Published: 2020-12-30 05:30:30

---
title: Answer: 
published: true
---

{% stackoverflow 11890871 %}

router, may sometimes have a built in DNS resolver if it happens to also have a DHCP server, but if it does, it's usually just a forwarding resolver that passes the query along to an upstream nameserver (obtained from an ISP) if it doesn't know the answer
Imbalance Of Power In JavaScript
Tags: javascript
Published: 2020-12-30 05:14:06

> This article was originally published on my blog: resynth1943.net. If you'd like more timely notifications of new posts, consider subscribing to my [RSS feed](https://resynth1943.net/feed.xml).

From its inception, Node.js, a server-side runtime for JavaScript, has heavily relied on NPM. NPM is a closed-source, corporate package manager.

In many ways, NPM embodies the JavaScript ecosystem. Without NPM, JavaScript just wouldn't work. And this has happened. [NPM has gone down before](https://github.com/npm/npm/issues/4131), and it's stalled developers in their tracks. 

That's one of the problems with a centralised architecture: **uptime**.

Many of my followers will know that I actively oppose [Cloudflare](https://outline.com/MHJTCP). Centralised structures that "just can't fail" end up harming and restricting users, instead of helping them power the open web.

They also stifle competition. Take Google, for example, who are now facing a [huge anti-trust case](https://www.theguardian.com/technology/2020/oct/21/google-antitrust-charges-what-is-next), for limiting and actively stifling opposition. Google took advantage of the trust they've garnered from users, and now use that to prevent competitive search engines (like [DuckDuckGo](https://duckduckgo.com)) from gaining market share.

All of these companies have one thing in common: **they're very useful at what they do**. Centralised structures *have* empowered us, but there's a substantial issue underpinning them: they create walled gardens, designed to entrap and, in many ways, actively harm the user.

In 2016, NPM received notice from Kik that one of their packages violated their trademarks. The package name was, of course, named "kik". This then led to a dispute between Azer, the maintainer of the "kik" package, and Kik, who went on to send baseless legal threats and egregious accusations.

[*Eventually, NPM sided with kik.*](https://medium.com/@kolorahl/kik-left-pad-and-npm-oh-my-e6f216a22766)

Although I disagree with NPM's decision, it does beg the question: what happens when these centralised companies *do something wrong?* Where do people move to from NPM?

The short answer is: *you don't.* The NPM command-line tool makes it [especially difficult](https://about.scarf.sh/post/package-registries-and-open-source) to switch from *their* package repository. Essentially, you have to persuade end-users of your package to adopt a new registry, by editing mysterious configuration files.

This isn't good enough.
Hello, world!
Tags: python, programming, beginners, tutorial
Published: 2020-12-30 04:57:00

*Programming is fun!*
Isn't it?
Anyone interested in logic with some creativity will fall in love with coding.

Alright then, if you are interested to start the journey with me in learning a programming language: let's start our first step in learning to code.

OK, but there so many coding languages in the world, right?
Which one to choose?
Now, calm down. I am here to help you with providing some top choices by any beginner in this field:
* C++

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/x4b7jgtospbu0kkzuu38.png)


* Java

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/txktwj42a8n9hno2vnqu.png)


* Python

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1qtuwhxg0kwksaatdwd0.png)


OK, which one did you find easy?
I bet that it's Python!
Well then, welcome to the Python community!

Let's start this journey of programming with gaining some knowledge on Python programming language.

Python is a powerful general-purpose programming language.
It is created by Guido van Rossum.
Python is easy to learn and easy to code.

**Python Installation**
Check out the following guidelines for getting python installed in your computer
[W3Schools](https://www.w3schools.com/python/python_getstarted.asp)
[Youtube](https://youtu.be/mbryl4MZJms)

### Best Resources

- [Learn more about Python Programming Language](https://dev.to/aswin2001barath/python-programming-a-beginner-s-guide-k8n)

- [Python Blog Series](https://dev.to/aswin2001barath/series/10416) : A Blog series where I will be learning and sharing my knowledge on each of the above topics.

- [Learn Python for Free, Get Hired, and (maybe) Change the World!](https://academy.zerotomastery.io/a/aff_tz1t0tpx/external?affcode=441520_dcwk-s8s) : A detailed roadmap blog by Jayson Lennon (a Senior Software Engineer) with links to free resources.

- **Zero To Mastery Course** - [Complete Python Developer](https://academy.zerotomastery.io/a/aff_9khypm7v/external?affcode=441520_dcwk-s8s) : A comprehensive course by Andrei Neagoie (a Senior Developer) that covers all of the above topics.

**Who Am I?**

I’m Aswin Barath, a Software Engineering Nerd who loves building Web Applications, now sharing my knowledge through [Blogging](https://medium.com/techsoftware) during the busy time of my freelancing work life. Here’s the link to all of my socials categorized by platforms under one place: https://linktr.ee/AswinBarath

**Thank you** so much for reading my blog🙂.
Calendar Heatmap using React on JSitor
Tags: javascript, react, css, 100daysofcode
Published: 2020-12-30 04:10:07

A calendar heatmap coded using [react-day-picker](https://github.com/gpbl/react-day-picker)


![](https://i.ibb.co/R6604gD/Screenshot-2020-12-30-at-9-34-02-AM.png)
{% jsitor fyVgK7GhND %}

Twitter
[@ashvin_777](https://twitter.com/ashvin_777)
[@JSitorEditor](https://twitter.com/JSitorEditor)
Who is Mr Kabatullah?
Published: 2020-12-30 04:09:09

Mr kabatullah is an Indian blogger and YouTuber 
Born: 24 August 2005
Born Place: Teosa Jama Mashjid Road,Ward No 14,Teosa kishanganj (855107)Bihar,India 
Father's Name: Md Uzeer Hussain
 School Name : Dr Kalam Memorial Academy 
Lives: Teosa kishanganj Bihar India
 From: Teosa kishanganj Bihar India 
Mobile No:📞 9631841160,6203472073📧:mrkabatullah@gmail.com

👇Follow Me👇

https://twitter.com/mrkabatullah_

https://instagram.com/mrkabatullah

https://facebook.com/mrkabatullah

https://pinterest.com/mrkabatullah

https://linkedin.com/in/mrkabatullah

https://sharechat.com/mrkabatullah

https://vk.com/mrkabatullah

https://ask.fm/mrkabatullah

https://mrkabatullah.tumblr.com

http://mrkabatullah.blogspot.com
Python Zero to Hero - Ep.31 - Flask before new year
Tags: python, tutorial, webdev, beginners
Published: 2020-12-30 03:56:56

---
title: Python Zero to Hero - Ep.31 - Flask before new year
published: true
description: One last episode with Flask before the new year! We will continue the amazing tutorial that we follow last time and see what we learnt from it before the end of 2020.
tags: python, tutorial, webdev, beginner
---
One last episode with Flask before the new year! We will continue the amazing tutorial that we follow last time and see what we learnt from it before the end of 2020. If you have any questions or any suggestions about which Python topics to cover, please leave your comment at my [Twitch channel](https://www.twitch.tv/cheukting_ho)

You can get the slide deck [here](https://slides.com/cheukting_ho) and the example code and homework form [GitHub here](https://github.com/Cheukting/python02hero). Ask questions at my [Twitch channel](https://www.twitch.tv/cheukting_ho)
College is still better for coding
Tags: discuss, career, computerscience
Published: 2020-12-30 03:17:33

**WITH A LOT OF CAVEATS!!!** All I ask before posting comments is to read and think about the points that I plan to make to explain why I believe that going to college is still the best path for a career as a developer/software engineer. 
﻿
**WHO I AM:** I moved to the US when I was 12 years old from Colombia and went to public school in GA and then went to Georgia Tech, where I graduated with a Computational Media Degree in 2010. So I have been working for ten years now and more recently have been focusing on React. I am sharing this so that, as a reader, you can see what my experiences have been, and this opinion is based on my experiences. 
﻿
Supposing you are someone who has not had a career in the “Real” world and are trying to decide between college and coding camps as a way to start. College is the right place for you to learn the skills to help you with the rest of your life. In a coding camp, you will learn to build an app or a web page, but you won’t understand why things are done a certain way. Starting out, that may not be an issue, but as soon as you are no longer a junior dev, you will have to learn many of these fundamental CS concepts, or it will become harder and harder to progress in your career. These fundamentals don’t change from language to language, and as technology moves forward, it will be easier to move on to the next technology as I have had to do in the past ten years. And that is only on the purely technical side of the equation unless your family already are white-collar professionals with a network, no matter how brilliant a coder you are. Those starting jobs will probably first go to the recent grads of colleges. Access to those Alumni professional networks, especially as a PoC, is invaluable.  It’s a lot like climbing a mountain with and without a rope. You can do it, but it’s a lot more dangerous, while with the rope, even if you are not always perfect, missteps won’t set you back as much. 
﻿
Ultimately it is your life, and only you know what the right path for you should be.
Confluent: Developing a Streaming Microservices Application - Kafka
Tags: kafka, microservices, realtime, streaming
Published: 2020-12-30 03:46:06

## Background

We build services using a Streaming Platform, some will be stateless: simple functions that take an input, perform a business operation and produce an output. Some will be stateful, but read-only, as in when views need to be created so we can serve remote queries. Others will need to both read and write state, either entirely inside the Kafka ecosystem, or by calling out to other services or databases. Having all approaches available makes the Kafka’s Streams API a powerful tool for building event-driven services. 

https://www.confluent.io/blog/building-a-microservices-ecosystem-with-kafka-streams-and-ksql/

## Objectives

- Persist events into Kafka by producing records that represent customer orders
- Write a service that validates customer orders
- Write a service that joins streaming order information with streaming payment information and data from a customer database
- Define one set of criteria to filter records in a stream based on some criteria
- Create a session window to define five-minute windows for processing
- Create a state store for the Inventory Service
- Create one persistent query that enriches the orders stream with customer information using a stream-table join


Check out the steps [here](https://iamvigneshc.medium.com/confluent-developing-a-streaming-microservices-application-494680ce5e6)

Additional References:

https://docs.confluent.io/platform/current/streams/developer-guide/dsl-api.html

https://www.confluent.io/blog/distributed-real-time-joins-and-aggregations-on-user-activity-events-using-kafka-streams/

https://www.confluent.io/product/ksql/

https://github.com/confluentinc
Python: interpreted or compiled?
Tags: python, interpreted, compile, programming
Published: 2020-12-30 03:31:39

One most common question about python is that it is a compiled language or interpreted language or both? 

First, see what is terms compiled and interpreted means(in a simple world):
**Compiled Language:** The high-level Language whose code first converted into machine code by the compiler and then executed by the executor.

**Interpreted Language:**  The high-level language whose code executed by an interpreter on the go.

In various books on python programming, it is mention that Python is an Interpreted Language. And, also as per the above definitions Python is an Interpreted language.

But the world is not as simpler and limited. So that is half correct that Python is an Interpreted language. The Python program first compiled and then interpreted. This compilation part is hidden from programmers, so they think that it is an interpreted language. The compilation part is done when we execute our code and this will generate byte-code and internally this byte-code gets converted by python virtual machine according to the machine and operating system.

### The compiled part of the Python program:

![Sample Code](https://dev-to-uploads.s3.amazonaws.com/i/6xchffmtcorfldmxpgac.png)

now if we run this code using the command prompt or terminal, first save this file using `.py` extension. 
and run the following command :
``` 
python -m py_compile main.py 
```

As we press enter the compiled code will get generated and saved in a folder which is created inside the folder contain our python code.

There is one another way to compile python code by using `compile()` method. This function takes a string, byte-string, or AST as input and returns a python code object which is executed by using `eval()` method or `exec()` method.

Syntex of `compile()` : 
```
compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1)
```
**Parameters :-**
* __Source :__ String, byte-string, AST object
* __Filename :__ Filename from which code was read
* __mode :__ three mode 'exec', 'eval', and 'single'
* __Flags(optional)__ and __dont_inherit(optional)__ – Default value=0. It takes care that which future statements affect the compilation of the source.
* __Optimize(optional)__ – It tells optimization level of compiler. Default value -1.

###Sample Code:
```
srcCode = 'x = 10\ny = 20\nmul = x * y\nprint("mul =", mul)'
execCode = compile(srcCode, 'mulstring', 'exec') 
exec(execCode)
```

###Output:
```mul = 200```

Thanks for reading.
100 Days of Code ~ Day 6
Tags: 100daysofcode, javascript, webdev, challenge
Published: 2020-12-30 03:21:37

Have been a little busier than normal as started moving out of my apartment today, and while I couldn't get in a full hour, wanted to make sure I got some coding in.

I did manage to complete activity 7 of [JavaScript30](https://javascript30.com) which happened to be another one involving array methods, specifically some, every, find, findIndex, and splice. This time went ahead and challenged myself to actually work my own solutions as opposed to coding along with Wes Bos and was able to get them all on my own!