teleren/devto huggingface dataset:
How to calculate the difference of days between two dates in JavaScript
Tags: javascript
Published: 2022-05-14 09:26:16

Have you ever tried calculating the number of days between two dates in JavaScript without a library? Well, here's how

## Short answer:

```js
const firstDate = new Date("05/10/2022") // 10th May, 2022
const secondDate = new Date() // today, 14th May, 2022

const millisecondsDiff = secondDate.getTime() - firstDate.getTime()

const daysDiff = Math.round(
  millisecondsDiff / (24 * 60 * 60 * 60)
)
```

## Long answer

To find the difference between two dates, you first need to get the time value in milliseconds. You get this using the [`getTime`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime) method on the `Date` instance:

```js
const firstDate = new Date("05/10/2022") // 10th May, 2022
const secondDate = new Date() // today, 14th May, 2022

const firstDateInMs = firstDate.getTime()
const secondDateInMs = secondDate.getTime()
```

The millisecond value is a number on which you can then perform arithmetic operations like subtractions.

The next step is finding the difference between both dates:

```js
const differenceBtwDates = secondDateInMs - firstDateInMs

console.log(differenceBtwDates)
// 351628869
```

Now, you have the difference in milliseconds between both dates. This is where you convert the milliseconds to days. How to do that?

First, you get the equivalence of 1 day (24 hours) in milliseconds. Here's how:

```js
const aDayInMs = 24 * 60 * 60 * 1000

console.log(aDayInMs)
// 86400000
```

* 24 stands for 24 hours
* 60 stands for 60 minutes, which makes an hour, thereby converting 24 hours to minutes
* the next 60 stands for 60 seconds, which makes a minute
* and 1000 stands for 1000 milliseconds, which makes a second

Now that you have the milliseconds value for a day, you can use it to determine how many days the difference between the dates are.

If `86400000` (`aDayInMs`) milliseconds makes a day, then, `351628869` (`differenceBtwDates`) milliseconds makes:

```js
const daysDiff = differenceBtwDates / aDayInMs

console.log(daysDiff)
// 4.0782153125
```

As it returns a floating number, you can round it up with `Math.round()`:

```js
const daysDiff = Math.round(differenceBtwDates / aDayInMs)

console.log(daysDiff)
// 4
```

Comparing May 10th and May 14th, it is a 4-day difference.

Here's the full code:

```js
const firstDate = new Date("05/10/2022") // 10th May, 2022
const secondDate = new Date() // today, 14th May, 2022

const firstDateInMs = firstDate.getTime()
const secondDateInMs = secondDate.getTime()

const differenceBtwDates = secondDateInMs - firstDateInMs

const aDayInMs = 24 * 60 * 60 * 1000

const daysDiff = Math.round(differenceBtwDates / aDayInMs)

console.log(daysDiff)
// 4
```

`firstDate` and `secondDate` can be any dates at all. I used May 10th and 14th for explanation purposes.
A NETFLIX clone build using react js and tmdb API
Tags: javascript, webdev, css, react
Published: 2022-05-14 09:11:22



## **NETFLIX**

 A react js frontend clone project using TMDB API

API endpoints used are :
`Originals: /discover/tv?api_key=${API_KEY}&language=en-US`,
  `Trending: /trending/all/week?api_key=${API_KEY}&language=en-US`,
  `TopRated: /movie/top_rated?api_key=${API_KEY}&language=en-US`,
  `Action: /discover/movie?api_key=${API_KEY}&with_genres=28`,
  `Comedy: /discover/movie?api_key=${API_KEY}&with_genres=35`,
  `Horror: /discover/movie?api_key=${API_KEY}&with_genres=27`,
  `Romance: /discover/movie?api_key=${API_KEY}&with_genres=10749`,
  `Documentaries: /discover/movie?api_key=${API_KEY}&with_genres=99`



> For more information and code ...

checkout my github repo [Netflix Clone](https://github.com/prajyu/Netflix-Clone)
12 Cool Coding Challenges Sites for Programmers
Tags: programming, challenge, beginners, career
Published: 2022-05-14 08:55:34

Learn how to be or deepen your knowledge as a programmer with these wonderful website containing coding challenges:


## CodeChef 
https://www.codechef.com

## CodeFight 
https://codefight.in

## CodinGame 
https://www.codingame.com

## CodeForces 
https://codeforces.com

## LeetCode 
https://leetcode.com

## GeeksforGeeks 
https://www.geeksforgeeks.org

## Codewars 
https://www.codewars.com

## EdaBit 
https://edabit.com


----

Photo by Florian Schmetz on Unsplash
Today's Fun Joke For Developers - Daily Developer Jokes
Tags: jokes, dailydeveloperjokes
Published: 2022-05-14 08:00:02

---
title: "Today's Fun Joke For Developers - Daily Developer Jokes"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1259b02befe.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q___: Why did the functional programmer finally move out of their house?

___A___: For(e) closure
 -->
This week’s newsletter is out! (14-05-2022) - Culture Smash
Tags: javascript, tech, webdev, discuss
Published: 2022-05-14 07:52:27

---
title: This week’s newsletter is out! (14-05-2022) - Culture Smash
published: true
description: Another week of great javascript, tech and web development links.
tags: javascript, tech, webdev, discuss
---

Culture Smash

https://markjgsmith.substack.com/p/mark-smiths-newsletter-14-05-2022?s=w

Would love to hear any comments and feedback you have.

[@markjgsmith](https://twitter.com/markjgsmith)
Networking tips and commands
Tags: devops, webdev, beginners, programm
Published: 2022-05-14 07:49:14

Hello folks, this post is going to focus on common day to day shell commands that can be helpful.

---

##### ipconfig

> `ipconfig`: A command line utility that is used to display and manage the IP address assigned to the machine. It displays all current TCP/IP network configuration values and refreshes Dynamic Host Configuration Protocol (DHCP) and Domain Name System (DNS) settings. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ye8hmhhf7xbg627v4bzh.PNG)

---

#### Ping test
> The PING test checks if a web host or IP address is reachable across the Internet by sending multiple ICMP packets and listening for the replies.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ks7vmz0ycdfmstdfkb24.PNG)

---

#### Public address of websites
`nslookup google.com`
> The nslookup command queries internet domain name servers in two modes. Interactive mode allows you to query name servers for information about various hosts and domains, or to print a list of the hosts in a domain.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/thvs2hvnibzf5b27tqjv.PNG)
 

---

#### Host name
> Hostname is a domain name assigned to a host computer or a network node (like your router).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z55c6y2ufz865qt80qha.PNG)
 
---

#### Whois
>  `Whois` finds out the information about a domain, such as the owner of the domain, the owner's contact information, and the name servers that the domain is using.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ta5rm0wyy3w57q166gva.PNG)

---

#### Curl
> A tool for transferring data from or to a server  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/043vcuvfj250gh5uh3k6.PNG)

---

#### dig
> `dig` command stands for Domain Information Groper. It is used for retrieving information about DNS name servers. It is basically used by network administrators. It is used for verifying and troubleshooting DNS problems and to perform DNS lookups.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pzsleg9ecoygsp1g1vcc.PNG)

---
 
#### Conclusion
Share useful network tips and commands here in the comment section below. Thanks for reading.
How I want to get from a11y minded to a11y expert
Tags: a11y, ux, motivation, career
Published: 2022-05-14 07:47:47

From the beginning of my self-taught front-end developer journey, I was interested in how to create apps and websites with accessibility in mind. I used semantic HTML and used Lighthouse on every project and felt really good about how accessible my websites were. 


![Perfect Lighthouse Score](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vx9eaynlq6e14c2ggok9.png)

Little did I know that this is just the tip of the iceberg and there is so much more to it. There are many great tools and guidelines you can use to check how accessible your website is and how you can improve it.

I would like to gain the knowledge in these guidelines as well as learn how to use the different testing tools.

**How I want to structure my journey**. 

1. I will write and publish this article (✅) and make it a series.
2. I will write about accessibility in general to give the community an overview of a11y in web development.
3. I will start updating my existing projects, analyzing them in an accessible way and updating them as needed, starting with my [personal portfolio](https://julia-undeutsch.netlify.app/).
4. I will make my personal brand (colors, font, ..) accessible.
5. I will update my second project [SOS Animals](https://github.com/YuriDevAT/sos-animals).

**In the meantime**

- I will write about a11y in terms of specific elements such as navigation bars, headers, buttons, etc. and save examples as gist files.
- I will write about a11y beyond components, more specific things like a11y in `<head>`, keyboard usage, and more.
- I'm going to take the Google UX Design Certificate to learn about accessibility from a different perspective. Because a11y is not only developer's job, it concerns all of us.

**Aspiration**
My goal would be to be known for my accessibility skills and be responsible for a11y at work 😇


---
![Thank you](https://docs.google.com/uc?export=download&id=166Ecq6uBl61U14OUlkHOHIBv2ArKoumJ)

_Thanks for your reading and time. I really appreciate it!_
Goal settings
Published: 2022-05-14 07:21:33

I realized that there are just too many things/studies I want to do and I have to do. That only triggers my anxiety and pressuring me to do a lot of useless multi-tasking - tapping this and that and this and that...

So it's time for me to re-think about my goals, priorities, and practical plans. 

**Long-term goal** 
I want to work as a 'creative technologist' abroad. For example, this would be one of my dream jobs. 
[Creative Technologist at Apple](https://jobs.apple.com/ko-kr/details/200344923/creative-technologist-marcom)

Few of my friends are currently living and working in London, and this makes me want to go to UK even more. 

The qualification list is quite... jaw-dropping... but okay. 
```
- 7+ years of experience working in creative/R&D/agency environments.
- A portfolio demonstrating experience with design/development fields (AR/VR, native iOS/MacOS applications, installations, motion graphics, 3D, creative coding).
- Ability to craft and communicate thoughtful user experiences.
- Experience with Unity/Unreal and AR/VR development.
- Experience with native iOS/MacOS development skills (Obj-C, Swift, C++, etc).
- Experience with Computer Graphics (Metal/OpenGL/WebGL).
- Experience with Adobe Creative Suite.
- Motion graphics and 3D software (After Effects, Maya, Blender) skills a plus.
- Strong commitment to explore and learn new technologies, and unafraid to be out of your comfort zone.
- You are able to collaborate, multitask, and work within designated timeframes. You thrive in a creative and dynamic work environment.
```
So that's at least unity/unreal, ios, swift, webgl, 2d and 3d creative coding, blender, adobe programs ... cool.

**Short-term priorities**
- Study more algorithms both for coding interview and for my own better understanding. 
- Threejs toy projects
- WebGL & WebVR toy projects
- Daily creative coding sketches (hopefully to prepare NFT projects)

**Practical plans** 
I'm trying to set better routines. Just small tasks everyday or at least every other days.

Also, I am coming up with a small topic for toy projects and intentionally avoiding a grandiose and ambitious one.

I will update the progress if it settles down!
Look Ma, no Neovim plugin manager!
Tags: neovim, bash, vim
Published: 2022-05-15 11:30:34

---
title: Look Ma, no Neovim plugin manager!
published: true
date: 2022-05-14 06:47:32 UTC
tags: neovim, bash, vim
canonical_url: https://www.preciouschicken.com/blog/posts/neovim-plugins-handsfree/
---

## Handsfree

To manually install a [Neovim](https://neovim.io/) plugin, for example [Tim Pope's Commentary](https://github.com/tpope/vim-commentary), without using a plug-in manager then at the terminal :

```bash
mkdir -p ~/.local/share/nvim/site/pack/tpope/start/commentary
git clone https://tpope.io/vim/commentary.git ~/.local/share/nvim/site/pack/tpope/start/commentary
```

The install path always follows the pattern of _~/.local/share/nvim/site/pack/foo/start/bar_, where the variables _foo_ and _bar_ can be whatever makes sense to you.  Commonly _foo_ is the name of the author (e.g. tpope) and _bar_ is the name of the plugin (e.g. commentary).

## Automation

Which is great, but from time to time your plugins will get updated and you will need to pull fresh versions.  This can easily be achieved on Linux systems with a small script.  Create a file named _~/.local/bin/vimpluginupdate_ and paste the following:

```bash
#!/bin/sh
NVMPTH="$HOME/.local/share/nvim/site/pack"
git -C $NVMPTH/tpope/start/commentary pull || git clone --depth 1 https://tpope.io/vim/commentary.git $NVMPTH/tpope/start/commentary
```

The rather long git line pulls the repository if it already exists, and if it does not exist (i.e. you haven't done the first step) then it clones a fresh one (using the _depth_ option to just get the latest version and not previous changes).

Now make the file executable:

```bash
chmod u+x ~/.local/bin/vimpluginupdate
```

And whenever you want to update your plugins run[^1]:

[^1]: Interestingly the _~/.local/bin/_ directory is not added to your _PATH_ [on a fresh install](https://askubuntu.com/a/1144235), so if the command does not work at first, log out then in again.

```bash
vimpluginupdate
```

As you install more updates simply add new lines.

## Helptags

To load any help documentation associated with the plugin then run `:helptags ALL` within Neovim when the plugin is active.  So for instance the vim-commentary plugin will be active when Neovim has open any file recognised as a programming language (i.e. any file with an extension _.js_, _.py_, etc).  In vim-commentary's case the help docs can then be accessed with `:help commentary`.


## But I use vim?

All I've really done here is amended the [vim-commentary install section](https://github.com/tpope/vim-commentary#installation), so check that out for standard vim (NB - the main difference is the directory used).

## I demand an authoritative source 

See [:help packages](https://neovim.io/doc/user/repeat.html#packages) and [:help add-package](https://neovim.io/doc/user/usr_05.html#05.4).

## Version control

This was tested corrected on Ubuntu Linux 22.04 LTS and Neovim v0.6.1.
How to setmeta - Set metadata on already uploaded objects,multiple Objects -GCS
Tags: javascript, gcp, cloud, webdev
Published: 2022-05-14 06:30:53


The gsutil setmeta command allows you to set or remove the metadata on one or more objects. It takes one or more header arguments followed by one or more URLs, where each header argument is in one of two forms:
```
gsutil setmeta -h [header:value|header] ... url...
```

setmeta to a object If you want to set cache-control to "public" then execute in Cloud Shell:
```
gsutil setmeta -h "Cache-Control:public" gs://<YOUR-BUCKET-NAME>/objectName
```

setmeta to multiple object If you want to set cache-control to "public" then execute in Cloud Shell:
```
gsutil setmeta -h "Cache-Control:public" gs://<YOUR-BUCKET-NAME>/*.*
```
`*.*` will add add the files inside the directory


Be a Opensource [Contributor](https://github.com/premshetty/cli)
Beginner's guide to @app.route() decorator in Flask
Tags: python, flask, http
Published: 2022-05-14 06:27:53

In this video, we'll see how to define and configure routes in Flask. Also, how to access HTTP Methods, Path param, Query param, Headers and Body of the Request and Response. 

{% youtube dl8UJnuGVjg %}

Source Code: https://github.com/CodePossibility/flask-route
15+ Python Advanced Concepts You Must Know- Codexashish
Tags: python, programming, machinelearning, deeplearning
Published: 2022-05-14 06:22:42

Python is an object-oriented and high-level programming language and getting more popular nowadays because of its dynamic nature, versatility, and ease to learn. Python is the second most preferred programming language after JavaScript and it can be used in any field like Artificial Intelligence, Machine learning, Deep learning, and Web Development.

In this article, we are going to see 15+ advanced python concepts that you must know if you are a python developer. If you want to learn python programming or you are a python developer then you must know these python advanced concepts. So let's start this article without wasting any time:
Table Of Contents

# 1. lambda Function
A lambda is a small anonymous function that can take any number of arguments but can only have one expression. A general python function is defined using the style of def function_name(), but with the lambda function, we don't give it a name. The Lambda function is very important because the purpose of this function is to perform some kind of simple and operational expression without the need for fully defining a function.

**The Syntax of Lambda Function:**

_lambda arguments : expression_

# 2. Map Function
Python programming has a built-in function called map() which returns a map object(which is an iterator) of the results after applying the given function to each item of a given iterable(tuple, list or dict, etc.). The map function is most importantly a readable way to perform such an operation.

**The syntax for Map Function:**

_map(function, iterable)_

# 3. Filtering
The filter is also a python built-in function which is quite similar to the Map function. The main difference between map() and filter() is that the filter function only returns the filtered elements as True from a given sequence. 

**The Syntax of Filter Function:**

_filter(function, itertools)_

# 4. Generator
A generator function is used to allow you to declare a function that behaves like an iterator and it also allows programmers to make an iterator in an easy and fast way. A generator is a special type of function in python programming which does not return a single value instead it returns an iterable generator object. In the generator, the function yield statement is used rather than the return statement. 

## 
[Click Here to read more](https://www.codexashish.com/2022/05/15-python-advanced-concepts-you-must-know.html)

**Thankyou 
Codexashish**
"Hello World!" in different languages
Tags: programming, beginners, discuss, opensource
Published: 2022-05-14 05:50:17

Every one start to learn programming languages from a simple "hello world!"

And most hello-world programs are not runnable, but this project shows you runnable "hello-world" programs with how to build a proper enviroment with linux.

And you can add your languages easily.

Please visit : https://github.com/calidion/helloworld
for more detailed info.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lo6yms9114g1yxkthtx1.gif)
Python Conditional statement
Tags: beginners, tutorial, python, programming
Published: 2022-05-14 05:46:20

 Most of us are familiar with making real-life condition statements like "if I have enough money, I will buy a ball" which gives the condition that if you have enough money you will purchase the item but if not you won't.
Python, like all programming languages, also has a way of writing conditional statements like this, with the use of "if….." Statement
An example is a code
![image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/681zefkr9rvj4x7bxj51.png)
When run

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6zm5fv6oomgip16ptv5j.png)
The program won't do anything when it's less than the amount but if it's greater:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ug4an4svr5oz3xsxhir.png)

If the condition is fulfilled the operation is carried out, but if not it would be carried out. 
In addition, in the if statement it's possible you want the program to run when the condition is not fulfilled here you use the "else" statement.
The else is designed so if the condition under the if statement isn't fulfilled it will be 
Example 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r2tghwmaz8usrd9rltga.png)
When run

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l3nf3y1r4e0bcakim35l.png)
Or

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ul9fjqpr37wzzjtd4m21.png)

So if the money is greater than 500 it will send a message saying bought ball but if not it will send a message saying not enough funds.

Hope you enjoyed this short lesson, more on this will be uploaded next week, read, like, comment