teleren/devto huggingface dataset:
JavaScript match values in two arrays
Tags: javascript
Published: 2020-12-01 05:31:39

I don't know about you, but quite often I need a simple piece of code that can find the equals in two arrays.

Or for that matter, find the non-equals.

What this basically means is that we need to compare two arrays and get an output stating which elements match.

For this specific purpose, we are going to use the [Array `filter()` method](https://daily-dev-tips.com/posts/javascript-filter-function/).

The end result will behave as follows:

![JavaScript match values in two arrays](https://cdn.hashnode.com/res/hashnode/image/upload/v1606372948652/zm6suBpIO.gif)

## JavaScript finding match values in two arrays

So let's start by making our two arrays.

```js
const array1 = [1, 2, 3, 4, 5, 6];
const array2 = [1, 2, 3, 4, 5, 6, 7, 8, 9];
```

As you can see we have matching numbers stating from 1-6 the second array has three extra numbers 7,8,9.

Our end goal here is to get an array back stating the numbers 1-6.

In this case we can make excellent use of the Array filter method.

```js
const output = array2.filter(function(obj) {
  return array1.indexOf(obj) !== -1;
});
console.log(output);
```

What we do here is define a new output that will get a brand new array.
We then specifically want to filter the second array, inside the filter function we check if this item is part of the first array.

In this case, the indexOf will return either a position or -1 if it's not found.

The output:

```js
[1, 2, 3, 4, 5, 6];
```

Tadaa 🥳 We found matches between two arrays.

## JavaScript finding non-matching values in two arrays

But, what if we need to find the values that are only in one of the arrays?

This case is slightly different because it will only work one way.

What we will do is revert the check, so instead of checking if the indexOf is NOT -1, we want those values of -1.

The code will look like this.

```js
const array1 = [1, 2, 3, 4, 5, 6];
const array2 = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const output = array2.filter(function(obj) {
  return array1.indexOf(obj) === -1;
});
console.log(output);
```

And in this case, the output will be:

```js
[7, 8, 9];
```

As mentioned, this only works one-way.
So if you add a non-matching number in array1 that won't be returned with this method.

I do hope you found this array matching useful. It comes back more often than you would think.

## Making it smaller

As always we can use the shorthand version for the filter method.

```js
const output = array2.filter(obj => array1.indexOf(obj) !== -1);
```

We can omit the actual function part and do not need to specify the return values.

I tend to write out the full functions because it's easier for beginners to understand what happens.

### 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)
Top 3 Sticker Makers for WhatsApp
Tags: stickermakerforwhatsapp
Published: 2020-12-01 05:23:27

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gfm74yng8udopljsp42f.jpg "Logo Title Text1")

WhatsApp is one of my favorite text messaging apps that I use in messaging with my friends and family. And I always love to use stickers whenever I send them messages because they add emotion to the words that you want to convey. So I tried to find these top 3 sticker maker apps for WhatsApp that will help you make your personalized stickers.

**Apowersoft Background Eraser**
To be more creative in making your own sticker maker for WhatsApp, Apowersoft Background Eraser is the best app for you. This tool is originally a background remover app, yet it has the ability to make customized funny stickers with your and your friend’s pictures. This app will provide you some basic photo editing features that you may use to beautify your sticker. What is more interesting about this app is that you don’t need to have photo editing skills to create a sticker for your WhatsApp.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ghjlwin1tb535vx53zi4.png "Logo Title Text2")

Pros:
Seamless photo editor app.
Shows an accurate cutout of the sticker.
Maintain the quality of an image even after processing.
Does not require any photo editing skills.
No ads.

Cons:
Paid app.

**Sticker Maker**
Another app that can be your WhatsApp sticker maker is the Sticker Maker app that you may use on your Android phone. This app will let you make unlimited customized stickers that you may use on your WhatsApp. You just need to make your own pack and then you may collect all your stickers in that folder. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/zgqpq9ye7ds0z1ksukk9.png "Logo Title Text3")

Pros:
Create your own sticker packs.
Cut out sticker precisely.
Add text to stickers.

Cons:
Paid app

**Easy Sticker**
Create WhatsApp stickers with this iOS app called Easy Sticker. Make your personalized stickers with your own picture or friends' picture with this app. With its ability to add text, shapes or applying cartoon art filters Easy Sticker is the best one for you. This app also consists of a variety of original stickers that you may use right away. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/syuady317tihk7hxj1vs.png "Logo Title Text4")

Pro:
It has automatic and manual selection tools.
Offers different sticker shapes.
Create your own packs.

Cons:
It only offers a 3-day free trial.
React Js Introduction
Tags: javascript, react
Published: 2020-12-01 05:11:44

## Apa Itu React ?

Beberapa orang berpikir bahwa react itu framework javascript, faktanya react js itu bukan framework tetapi library JavaScript untuk membangun user interface ( antarmuka pengguna ) yang di kembangkan oleh facebook.

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

_screenshot dari website react https://reactjs.org_

## Kenapa Menggunakan React ?

1. Memudahkan untuk membuat web application
2. Mudah dipelajari dan digunakan
3. Learn Once, Write Anywhere (belajar satu untuk semua)
4  dan banyak lagi
Code Smell 39 - new Date()
Tags: oop, codenewbie, tutorial, globals
Published: 2020-12-01 05:02:49

*70s first tutorial: getCurrentDate(). Piece of Cake. We are in the 20s Time is global no more.*

# Problems

- Coupling

- Fragile Tests

- Timezone Problems

# Solutions

1. Use Dependency injection to decouple time source.

# Sample Code

## Wrong

{% gist https://gist.github.com/mcsee/272ba8ead8cb11037d97f6a0cd473ef2 %}

## Right

{% gist https://gist.github.com/mcsee/51f09b9c56f077aa2954745c1f43da2c %}

# Detection

We should forbid global functions policies. We need to couple to accidental and pluggable time sources.

# Conclusion

```Date.today() , Time.now()```,  and other global system calls are coupling smell. 

Since **tests must be in full environmental control**. We should easily set up time, moved it back and forth etc.

**Date** and **Time** classes should only create immutable instances. It is not their responsibility to give the actual time. This violates Single Responsibility Principle.

The passage of time is always scorned by programmers. This makes objects mutable and designs poor and coupled.

# Relations

{% post https://dev.to/mcsee/code-smell-18-static-functions-fpj %}

# More info

[Evil Mutants](https://maximilianocontieri.com/the-evil-powers-of-mutants)

# Tags

- Globals

* * *

> In programming, the hard part isn't solving problems, but deciding what problems to solve.

_Paul Graham_
Front/Back, API, DESKTOP, MOBILE, DATA, which is the most stable? Or, dosnt have that many changes? 
Tags: react, python, programming, database
Published: 2020-12-01 04:40:45

React, Vue, Python, Django, GraphQL, MongoBD, Pandas, Numpy, Machine Learning, Datascience.... they all interest me. BUT....
 I don’t like styling. 

So, which one, that may have more steps, is best with “getting something done” but, isn’t repetitive with including something... somewhere else, that you have to keep in mind as your going through code.

Django... seems to make a quick access to objects to loop through them, in fewer steps, especially, when you “ADD” something, it’s just a “submit” vs, how react or vue is.
DEV's HELP!.
Tags: help, beginners
Published: 2020-10-25 17:47:18

Hey people, I know this may sound weird post.
BUT PLEASE DON'T IGNORE MY POST.

I'm a final year student doing his bachelor's in I.T. with a good knowledge of linux, and some front end web dev.
Currently learning Core Java.

My basic aim is to become a SDE and Dev's I need your Help! Please.

It's been 10 months I was confused what domain to choose, but somewhere I was just in fantasy world to do the latest trends such as cybersec(which I was pretty much overexcited) and deep inside know I love vanilla-JS.

So, I need your mentorship, Please don't say on linkedin  to find people, they're rude there, I tried for 5 months, damn! with crisp and everything.

So can anyone provide me a good roadmap and a mentorship,PLEASE?.
I'm ready to devote the time all!. All I just need is guidance, I pretty much adapt languages fast, but my main master language is not fixed YET, Like Java or python, I love both, but will decide soon.

Apart, my maths is getting good now, taking some YT playlists of Khan Acad.

So any Dev willing to help or AT THE MOST OR AT THE LEAST provide some resources?.


Will be grateful forever.
Mastering promises: JS
Tags: javascript, webdev, 100daysofcode, codenewbie
Published: 2020-12-01 03:55:37

Ladies and Gentleman, In this post we will understand and master Promises in JavaScript. 

### What's a Promise? 🧐

A **Promise** object represents the eventual completion or failure of an asynchronous operation. In simple language, a Promise is data returned by asynchronous functions. 

```javascript
let promise = new Promise((resolve, reject) => {
  // Do something...
});
```

### Promise States 🤔

A promise can have one of these states: 
- Pending: This is the initial state
- Fulfilled: Operation completed successfully
- Rejected: Operation failed 

### Resolve / Reject
The Promise constructor takes in one argument: a callback with two parameters-resolve and reject. 

- **resolve **when the Promise was fulfilles
- **reject **when something didn't work (e.g. an error ocurred)

## General Structure 😳
Take a look at how a Promise is generally structured:

```javascript
let promise = new Promise((resolve, reject) => {
  // Do something...
     
    if(/* Everything went fine */) {
      resolve("Task successful!");
    } else {
        // Well... something went wrong
         reject("Something went wrong!");
     }
});
   
```
NOW, LET'S RUN THE PROMISE FROM THE ABOVE CODE 😐

```javascript
promise
  .then((message) => {
     // Print out the message if the
     // promise is fulfilled
     console.log(message);
    })
    .catch((error) => {
       // Catch error is one occurred
       console.log(error); 
     });
```

<hr>

### Here is a simple example of using Promise 

```javascript
let promiseToWashDishes = new Promise((resolve, reject) => {
  // whether the dishes are clean or not
  let clean = true; 

   if(clean) { 
      // Resolve promise if the dishes are clean
      resolve("The dishes are clean!");
     } else {
        // Reject the promise if the dishes are dirty
        reject("The dishes are still dirty!"); 
      }
});
```
Let's run our example Promise:

```javascript
promiseToWashDishes
   .then((result) => {
     console.log(`Great! ${result}`);
      // Great! The dishes are clean !
   })
   .catch((result) => {
    console.log(`Oh no! ${result}`);
       // Oh no! The Dishes are still dirty!
    });
```

<hr>

# Real World Example 🤩

Chances are, you have already worked with the **Fetch API**! It uses Promises, too:

```javascript
fetch("https://example.com/")
   .then((response) => response.json())
   .then((data) => {
   // Do something with the data...
   })
   .catch((error) => {
     // Something went wrong during the request!
    });
```

<hr>
## Need Help
Need help in raising fund to buy a Mechanical Keyboard. This pandemic has affected my family badly so can't ask my DAD for it. Please Help Me. 

<a href="https://www.buymeacoffee.com/rahxuls">
![1.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1606540958103/otN4S9TK8.png)
</a>

<hr>
😁Thanks For Reading | Happy Coding ⚡
Master web designing in just 10 minutes! - part 1
Tags: devops, webdev, html, codenewbie
Published: 2020-12-01 03:24:08

Let's learn web desinging in just 5 minutes in this part 1 of our series.

Step by step we will explore the web designing core concepts.

# Content

Content is the king, bet me it is.

The purpose of design is to enhance the presentation of the content it's applied to. It might sound obvious, but content being the primary element of a website, it should not be established as an afterthought.

Written content, like the paragraph you're currently reading, makes up for more than 90% of the Web. Styling this textual content will go a long way.

Let's assume you've already finalised the content you want to publish and just created an empty style.css file, what is the first rule you can write?

This series has been devided into 2 parts , this is part 1 of the series.


#Centering

Long lines of text can be hard to parse, and thus hard to read. Setting a limit of characters per line greatly enhances the readability and appeal of a wall of text.

```css
body {
  margin: 0 auto;
  max-width: 50em;
}
After styling the text blocks, what about styling the text itself?
```

The best of JavaScript, HTML and CSS 

JavaScript Cheat Seet contains useful code examples on a single page.

Font family
The browser's font defaults to "Times", which can look unappealing (mostly because it is the "unstyled" font). Switching to a sans-serif font like "Helvetica" or "Arial" can vastly improve the look of your page.

```css
body {
  font-family: "Helvetica", "Arial", sans-serif;
}
```


If you want to stick with a serif font, try "Georgia".

While this makes the text more appealing, let's also make it more readable.

Spacing
When a page looks "broken" to a user, it's usually a spacing issue. Providing space both around and within your content can increase the appeal of your page.

```css
body {
  line-height: 1.5;
  padding: 4em 1em;
}

h2 {
  margin-top: 1em;
  padding-top: 1em;
}
```


While the layout has greatly improved so far, let's apply more subtle changes.

# Color & contrast

Black text on a white background can be harsh on the eyes. Opting for a softer shade of black for body text makes the page more comfortable to read.

```css
body {
  color: #555;
}
And in order to keep a decent level of contrast, let's pick a darker shade for important words

h1,
h2,
strong {
  color: #333;
}
```


While most of the page has been improved visually, some elements (like the code snippets) still seem out of place.

The next part will be released soon!
#HELP:Flutter Learning Resources
Tags: flutter, discuss, help, tutorial
Published: 2020-12-01 03:21:22

Hello Devs,

I'm looking for some good fluttur learning resources.

it'll be a greate help if you can suggest articles, YT videos, course or anything worth looking at .

I guess devs here don't use flutter 😅😅. Very less posts & no updates.

Thank you
S3E2 Learn JMeter Series - Uniform Random Timer
Tags: performance, testing, tutorial, webperf
Published: 2020-12-01 03:19:33

Welcome to Learn JMeter Series!

In this Season 3, Episode 2, you will learn following:

🔹 Uniform Random Timer

{% youtube mqGl98yYJ1U %}

{% github QAInsights/Learn-JMeter-Series%}

☑ Buy me a tea 🍵 : https://www.buymeacoffee.com/qainsights
☑ [My Blog](https://qainsights.com)
☑ [My Udemy Course](https://www.udemy.com/course/performance-testing-using-truweb)
Beautiful and pixel perfect React Icon Library
Tags: react, icon, library, javascript
Published: 2020-12-01 02:55:07

**React Iconly** - Based on  [Iconly](https://ui8.net/piqodesign/products/iconly-essential-icons)  v2 icons

One of the phases in which we invest more time when we are developing or designing a web or mobile application is in choosing the **icon pack** that best suits the brand and what we want to convey, even creating our own **set** of icons if none of them fits or we want it to be unique and identify your brand.

 [Iconly](https://ui8.net/piqodesign/products/iconly-essential-icons?spm=a2c6h.14275010.0.0.541d5debaFCnO5)  is one of the options that is being used by designers and developers today, so I decided to create a library for React / Next.js / Gatsby that facilitates its use and that also allows us to customize any icon according to our needs.

On the [Website](https://react-iconly.jrgarciadev.com), you can find all the icons sorted by sets
 

Integrating into your project is quite simple just by following these steps:

### Installation
```
yarn add react-iconly 
``` 
or

```
npm install react-iconly
``` 

### Usage
```jsx
import React from 'react';
import { Home } from 'react-iconly';

const App = () => {
  return <Home />
};

export default App;
```

You can also wrap your app inside an `IconlyProvider` component, this will make all the icons that are within the context use the Provider properties

If you set specific props for each Icon the Provider properties will be overwritten

```jsx
import React from 'react';
import { IconlyProvider, Home, Notification } from 'react-iconly';

const App = () => {
  return (
    <IconlyProvider set="bulk" primaryColor="blueviolet" secondaryColor="blue" stroke="bold" size="xlarge">
      <Home />
      <Notification primaryColor="yellow" />
    </IconlyProvider>
  )
};

export default App;
```

Icons can be configured with inline props:
```jsx
<Home set="two-tone" primaryColor="blueviolet" secondaryColor="blue" stroke="bold" size="xlarge"/>
```
You can also include the whole icon pack:

```jsx
import React from 'react';
import * as Iconly from 'react-iconly';

const App = () => {
  return <Iconly.Home set="bulk" primaryColor="blueviolet" secondaryColor="blue" stroke="bold" size="xlarge"/>
};

export default App;
```

Custom style example

```jsx
import React from 'react';
import { Send } from 'react-iconly';

const App = () => {
  return <Send style={{ transform: 'rotate(45deg)' }} primaryColor="red" stroke="bold" size="xlarge"/>
};

export default App;

```

For more instructions visit:

[Github repository](https://github.com/jrgarciadev/react-iconly) 

Thanks for reading!
Back to coding. But....
Tags: laravel, php, 100daysofcode, codenewbie
Published: 2020-12-01 02:43:41

It's been a while since I have written anything about code. Honestly, my mind has been making it look like a very tedious thing to do and to be frank, I dropped coding for a while, didn't look like I was making any progress. But my head is back in, still on PHP though and now working with the Laravel framework.

Honestly, I really feel like giving up cause I don't see progress, still on building a simple Todo app for about 3 weeks and counting. And oh did I mention that my frontend skills are whack, I haven't done anything frontend in a long while. 

But right now I'm currently having issues with the "DELETE" method in Laravel. For some reason, method spoofing seems not to be working. Done all I think I know how to do but no results. 

Also reading documentations are important but I find that boring. But I guess I just have to go beyond that. I'm sorry if you came here hoping to learn something, I don't think I have learnt enough to do that. Not to be self-deprecating, but what could you possibly learn from me? 

Okay I think that's it. I haven't written in a while so I thought I would pick that back up and just felt like ranting. Byyee!
Asynchronous code: callback functions
Tags: javascript, beginners, codenewbie, functions
Published: 2020-12-01 02:42:07

Functions in JavaScript are not as in other languages are. In JavaScript, functions are first-class citizens. Therefore, a function can be passed as an argument, can be used as a variable value, and so on.

A callback function is a subroutine, It's a piece of code which can be executed immediately or later in run-time. As asynchronous callbacks, these functions are used to notify or alert when an event happens. Normally, these functions are specified as arguments to another one that start executing some code in the background, when the background code finishes running, it calls the callback function to let know the work is done or to tell you that something has happened.

```
function callback() {
    console.log("Process finished!");   
}

function run(callback) {
    for (let index = 0; index < 10000; index++) {
        console.log("Processing...");
    }
    callback();
}


run(callback);
```

In simple words, an asynchronous callback is a function that can be invoked when you need to notify something happened or the work is done. Even the callbacks are old-fashioned, it's very important to know about them since a high number of APIs still use them.
Quick Introduction to Apache NLPCraft
Tags: nlp, java, scala, machinelearning
Published: 2020-12-01 02:38:29

In this short article I would like to introduce [Apache NLPCraft](https://nlpcraft.apache.org) - an open source library for adding Natural Language Interface to any application. The goal of this project from its inception in 2017 was and still is unambiguously straightforward - provide an efficient & highly productive API to develop advanced NLP-based interfaces for modern applications...

https://nlpcraft.apache.org/blogs/quick_intro_apache_nlpcraft.html