teleren/devto huggingface dataset:
Create a simple and free whatsapp bot: For Begineers
Tags: node, visualstudio, javascript, venom
Published: 2021-09-03 15:44:50

This whatsapp bot can be used to send an automated message to individuals or groups. We can extend this bot for further use such as sending image/video, location, contacts.


I will be using [venom-bot](https://www.npmjs.com/package/venom-bot) node module to create this whatsapp bot. Venom module is a high-performance system developed with JavaScript and it is contineously developing with new features and it is open source-project so totally free.

### Requirements:
     Development Environment (VS studio)
     Basics of JavaScript
     Basic Knowledge of Node Package Manager(NPM)

First, we need to create a folder(maybe with the name "wpbot") and go into the created folder.

### Steps:
1) open command/terminal in present folder
2) give command **npm init**
It will automatically create a file **package.json** in the current folder.
3) create an **index.js** file in the current folder.
4) Now it's time to install the required vemon node module, give command **npm i --save venom-bot**. It will install the required node module and it will automatically create a new file named **package-lock.json**, which contains the installed package list.

Time to do some coding....
Open the index.js file in the development environment and paste the below code into the index.js file, that's it for now.

```
// Supports ES6
// import { create, Whatsapp } from 'venom-bot';
const venom = require('venom-bot');

venom
  .create()
  .then((client) => start(client))
  .catch((erro) => {
    console.log(erro);
  });

function start(client) {
  client.onMessage((message) => {
    if (message.body === 'Hi' && message.isGroupMsg === false) {
      client
        .sendText(message.from, 'Hello Dear')
        .then((result) => {
          console.log('Result: ', result); //return object success
        })
        .catch((erro) => {
          console.error('Error when sending: ', erro); //return object error
        });
    }
  });
}
```
As you can see from the code, whenever you will get a **Hi** message from indivisual(not from group), bot will automatically reply **Hello Dear**.

5) To create/activate this bot, you need to open you command/terminal and give the **node index.js** command and it will open a QR code in the terminal/command. You need to scan the QR code and linked it. After this step, it will do the job.


That's all for today, I'm still developing the complex features like sending replies as GIF/image based on text analysis and many more. I'll update you in future. Till then, stay safe and connected.
Center Video HTML - [SOLVED]
Tags: html, css, video, beginners
Published: 2021-09-03 15:21:56

## TL;DR Summary

If you want to center a video in HTML then the simplest thing you can do is calculate the exact margins to position it in the center.

If you wanted to center the video horizontally then you just use ***margin-left*** property. 

If you set margin to be 50% of the full screen width then the left edge of the video will be exactly in the center of the screen.

What you want is to push it back left for half of a width of the video (in our case ***200px***) and that will make it perfectly centered.

The same goes for vertical center alignment.

```html
<style>
  body { background-color: salmon; }
  video {
    width: 400px; /* height is 225px */
    margin-left: calc(50vw - 200px); 
    margin-top: calc(50vh - 112px);
  }
</style>

<video controls>
  <source src="test_video.mp4" type="video/mp4">
</video>
```
And the result looks like this:

![center video html](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n37oqepaojbdeaxk8x85.png)

In short that is it. 
  
  
## More Details

To center video element in HTML we used values like ***vw*** and ***vh***. Those are ***viewport width*** and ***viewport height*** respectively.

Basically what it means is that ***100vw*** is the full screen width and ***100vh*** is the full screen height.

So ***50vw*** is exactly horizontal center of the screen and ***50vh*** is exactly vertical center of the screen.

Also remember that sometimes you won't have full screen available and the ***video*** element will be inside some other smaller element. In that case you might want to use ***50%*** instead of ***50vw***.

Something like this:
```css
margin-left: calc(50% - 200px);
```
And this is really all there is to centering video in HTML using simple ***margin-left*** and ***margin-top*** CSS properties.  

Until next time,

*Will*

*[Building an Algo-Trading Hedge Fund From Scratch](https://programmermoney.com/)*
Object Comparisons: “is” vs “==”
Tags: python, programming, productivity
Published: 2021-09-03 14:55:41

The **==** operator compares by checking for equality: if these Python objects we compared them with the == operator, we’d get **both objects are equal** as an answer.


The **is** operator, however, compares identities: if we compared our
objects with the is operator, we’d get **these are two different objects** as an answer.

let’s take a look at some real Python code.

```python
>>> a = [1, 2, 3]
>>> b = a
```

Let’s inspect these two variables. We can see that they point to
identical-looking lists:
```python
>>> a
[1, 2, 3]
>>> b
[1, 2, 3]
```

Because the two list objects look the same, we’ll get the expected result
when we compare them for equality by using the == operator:

```python
>>> a == b
True
```

However, that doesn’t tell us whether a and b are actually pointing to
the same object. Of course, we know they are because we assigned
them earlier, but suppose we didn’t know—how might we find out?

The answer is to compare both variables with the is operator. This
confirms that both variables are in fact pointing to one list object:

```python
>>> a is b
True
```

Let’s see what happens when we create an identical copy of our list
object. We can do that by calling list() on the existing list to create
a copy we’ll name c:

```python
>>> c = list(a)
```
Again you’ll see that the new list we just created looks identical to the
list object pointed to by a and b:
```python
>>> c
[1, 2, 3]
```

Now this is where it gets interesting. Let’s compare our list copy c with
the initial list a using the == operator. What answer do you expect to
see?

```python
>>> a == c
True
```

Okay, I hope this was what you expected. What this result tells us
is that c and a have the same contents. They’re considered equal by
Python. But are they actually pointing to the same object? Let’s find
out with the is operator:

```python
>>> a is c
False
```

This is where we get a different result. Python is telling us
that c and a are pointing to two different objects, even though their
contents might be the same.

## Conclusion:

- An "is" expression evaluates to True if two variables point to the same (identical) object.
- An "==" expression evaluates to True if the objects referred to by
the variables are equal (have the same contents).
Amazing Button Animation Using HTML & CSS
Tags: html, webdev, css, beginners
Published: 2021-09-03 14:55:33

Hello, today I created an Amazing button hover Using HTML & CSS. I hope you like this also comments about your thoughts.

For more content follow me on Instagram  [@developer_nikhil27](https://www.instagram.com/developer_nikhil27/).

Thank you!

{% codepen https://codepen.io/NikhilBobade/pen/GREqezW %}
ES6 - A beginners guide - Default Parameters
Tags: javascript, codenewbie, beginners, webdev
Published: 2021-09-03 14:52:57

Welcome, in this article we are going to talk about Default Parameters, a feature that has long existed in other languages but landed in JavaScript in ES6. Simply put, Default Parameters will help us to not only write less code, but to ensure that functions are less likely to throw an exception if someone forget to send a parameter in.
Let's jump straight to an example, as usual we'll show an ES5 snippet first. We'll go with a sample function to create an AJAX request
### The ES5 way
With ES5 we would need to check for the lack of a parameter value, if this was found we would give it a default value. This typicaly resulted in a quite unnecessary `if` statement.
```javascript
function makeAJAXRequest(url, method) {
    if(!method){
        method = "GET";
    };
    //Rest of the request
}
makeAJAXRequest("https://www.google.com"); // This will generate a GET request because our function will set it as a GET
makeAJAXRequest("https://www.google.com", "POST"); // This will generate a POST request
```
So, above, if we do not send the method parameter then line 3 of the function will step in and say "Hey! the method needs to be set to `GET`. If we do send a value then that will be used
### ES6 way
The ES5 way works, of course it does it's been around for a while, but its outdated, and its long, and we've come to like making things smaller (just look at what happened to mobile phones!). So ES6 came along and those who came upon the specification decided..."you know what, let's just give the option to set a default value", and that's what they did. Have a look at the example below:
```javascript
function makeAJAXRequest(url, method = "GET") {
    //Rest of the request
}
makeAJAXRequest("https://www.google.com"); // This will generate a GET request because our function will use the default parameter
makeAJAXRequest("https://www.google.com", "POST"); // This will generate a POST request
```
Isn't that much tidier? There is one thing to remember here, and that is that Default Parameters must be on the right-hand side of the parameter list. There is no way to skip over them when calling a function so the following would not work:
```javascript
function makeAJAXRequest(url = "https://www.google.com", method) {
    //Rest of the request
}
makeAJAXRequest("GET"); // This would call the function and url would be "GET" and there would be no method set and so we would likely hit an error
```
### Extra
Default Parameters can have a value generated from other parameters (supplied or defaulted) that have already been set, for example:
```javascript
function sumOfThree(a, b, c = a + b) {
    return a + b + c;
}
console.log(sumOfThree(1,2)) // Returns 6 in a console.log
console.log(sumOfThree(1,2,4)) // Returns 7 in a console.log
```
How to get date or datetime from string in java
Tags: java, codever, snippets
Published: 2021-09-03 14:43:59

To get the date or dateime from String since Java 8 you can use the `parse` method of both `LocalDate` and `LocalDateTime` which takes two parameters: the string and a `DateFormatter` which you can specify as in the following example:

```java
LocalDate date = LocalDate.parse("1969-12-31", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LocalDateTime dateTime = LocalDateTime.parse("1983-01-08 20:54", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
```

<hr>

> Shared with :heart: from [Codever](https://www.codever.dev/snippets/613233b901eca21ee13c17d6/details). :point_right:  &nbsp; use the [**copy to mine**](https://www.codever.dev/snippets/613233b901eca21ee13c17d6/details) functionality to add it to your personal snippets collection.
Project Euler #1 - Multiples of 3 and 5
Tags: programming, projecteuler, cpp
Published: 2021-09-03 14:37:47

> **_Question no. 1 :_**
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.

```
#include<iostream>
using namespace std;
int main(){
  int sum3=0;
  int sum5=0; 
  int sum15=0;
  for (int i=1;i<=333;i++){
       sum3= i + sum3;
  }
  for (int i=1;i<=199;i++){
       sum5= i + sum5;
  }
  for (int i=1;i<=66;i++){
       sum15= i + sum15;
  }
 int total = 3*sum3+5*sum5-15*sum15;
 cout<<"Sum of multiples of 3 or 5 : "<<total;

return 0;
}
```
      
```
 Output :
 Sum of multiples of 3 or 5 : 233168 
```
Operadores Lógicos (Parte 1)
Tags: javascript, algorithms
Published: 2021-09-03 14:34:14

## Definição

Operadores lógicos são utilizados com várias condições em uma mesma expressão. Usamos os operadores lógicos para comparar resultados lógicos (verdadeiro ou falso).

## `&&` (AND - E)

Esse operador devolve um resultado verdadeiro apenas se **TODAS** as afirmações fornecidas forem verdadeiras.

```javascript
true && true   // true
true && false  // false
false && true  // false
false && false // false
```

## `||` (OR - OU)

Esse operador devolve um resultado verdadeiro se **UMA** das afirmações fornecidas for verdadeira.

```javascript
true || true   // true
true || false  // true
false || true  // true
false || false // false
```

## `!` (NO - NÃO)
Devolve um valor invertido, ou seja, verdadeiro se converte em falso e vice-versa.

```javascript
!true  // false
!false // true
```

E aí? Gostaram? Até a próxima anotação! 😊
Side Project For Sale
Tags: sideprojects, flutter, dart, 100daysofcode
Published: 2021-09-03 14:28:53

Hello all, I'm here to wonder if anyone would be interested in buying a side project from me. I started this little project in September 2019 and from there I worked on it on and off during college and it's at it's final state of UI and functionality so where I just don't feel the same spark I once did when I started; probably because I have grown from a newbie.

The project itself is a Quote Generating App which features:
- Four (4) categories
- Adding to Favorites
- A live section for the users to add their own quote to the app
- Sharing feature

Although all features have not been implemented in this iteration the UI elements are all there at your disposal. Below is an image to display how the app looks, the app was built out using Flutter and Dart so that maybe useful to new comers or even juniors.

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

If interested please indicate below and we can come to some kind of agreement in which I will transfer the GitHub Repository ownership to you. 

Please share this around to anyone who you think would benefit from this.

###### Thank you for your interest, consider supporting me.

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Z8Z860Z55)
Regex: Parsing usernames from Twitter, Facebook, and Instagram
Tags: beginners, javascript, php, regex
Published: 2021-09-03 14:27:12

For a few of my recent projects, we've had to parse out usernames from various social media URLs. We usually do this on user settings pages to make it easy when filling out forms; you can either write in your handle or paste in a URL.


### In PHP

```php
<?php

$urls = [
    'https://www.twitter.com/mattkenefick',
    'http://www.twitter.com/mattkenefick',
    'www.twitter.com/mattkenefick',
    'twitter.com/mattkenefick',
    'https://www.instagram.com/tonightaliveofficial',
    'http://www.instagram.com/tonightaliveofficial',
    'www.instagram.com/tonightaliveofficial',
    'instagram.com/tonightaliveofficial',
    'vimeo.com/my-name-goes-here',
    'medium.com/@mattkenefick',
    'basic-name',
    '12345678',
    '',
];

/**
 * Parse username from social media URL
 *
 * @param string $url
 * @return string
 */
function parseUsername(string $url): string
{
    $output = $url;

    // Parse username
    preg_match('/(?:https?:\/\/)?(?:www.)?(?:twitter|medium|facebook|vimeo|instagram)(?:.com\/)?([@a-zA-Z0-9-_]+)/im', $url, $matches);

    // Set output
    $output = count($matches) ? $matches[1] : $output;

    return $output;
}

// Parse
foreach ($urls as $url) {
    $name = parseUsername($url);

    echo "Extacted: [$name] from $url \n";
}

// Extacted: [mattkenefick] from https://www.twitter.com/mattkenefick
// Extacted: [mattkenefick] from http://www.twitter.com/mattkenefick
// Extacted: [mattkenefick] from www.twitter.com/mattkenefick
// Extacted: [mattkenefick] from twitter.com/mattkenefick
// Extacted: [tonightaliveofficial] from https://www.instagram.com/tonightaliveofficial
// Extacted: [tonightaliveofficial] from http://www.instagram.com/tonightaliveofficial
// Extacted: [tonightaliveofficial] from www.instagram.com/tonightaliveofficial
// Extacted: [tonightaliveofficial] from instagram.com/tonightaliveofficial
// Extacted: [my-name-goes-here] from vimeo.com/my-name-goes-here
// Extacted: [@mattkenefick] from medium.com/@mattkenefick
// Extacted: [basic-name] from basic-name
// Extacted: [12345678] from 12345678
// Extacted: [] from
```

### In JavaScript

```javascript
// One-liner
(url.match(/(?:https?:\/\/)?(?:www.)?(?:twitter|medium|facebook|vimeo|instagram)(?:.com\/)?([@a-zA-Z0-9-_]+)/im) || [url])[1];

// Function
function parseUsername(url)
{
    let output = url;
    let matches;

    // Parse username
    matches = url.match(/(?:https?:\/\/)?(?:www.)?(?:twitter|medium|facebook|vimeo|instagram)(?:.com\/)?([@a-zA-Z0-9-_]+)/im);

    // Set output
    output = matches.length ? matches[1] : output;

    return output;
}
```

Here's a testable example. in JavaScript. https://jsfiddle.net/124ojfmp/
Count characters in your string JS-Codewars [ES]
Tags: javascript
Published: 2021-09-03 13:52:26

El enunciado del ejercicio dice:

La idea principal es contar todos los caracteres que aparecen en una cadena. Si tiene una cadena como aba, entonces el resultado debería ser {'a': 2, 'b': 1}.

¿Qué pasa si la cadena está vacía? Entonces el resultado debería ser un objeto literal vacío, {}.


Entonces tenemos definidas las posibles entradas:
cadena de caracteres como "aba"

Y las salidas:
un objeto como {'a':2, 'b':1}


Pensando en la entrada para poder hacer el conteo deberíamos poder recorrerla por lo cual si es un string podríamos convertirla en un array aquí tenemos varias opciones una usar el "operador spread" o "split" para usar todos lo métodos que javascript nos provee para recorrer o iterar pueden ser "map" o "forEach" bien hemos avanzado ya podemos recorrer los caracteres ahora pensemos en la salida debe ser un objeto por lo cual podemos declarar un objeto vacío donde introduciremos los caracteres y el conteo como hacemos esto? dentro de la iteración colocamos dentro del objeto el carácter y luego preguntamos si este ya existe o es nuevo y en base a este pregunta decidimos si inicializar en contador en 1 o sumamos +1 de nuevo esto lo podemos hacer de dos formas usando un "operador ternario" o el "operador cortocircuito".

A continuación el ejercicio


```javascript
function count (string){

let obj = {} ;
let arr = [...string] ;

arr.map(item => {
obj[item] = obj[item] + 1 || 1 ;
})

return obj;


}
```

Segunda opción de solución - usando las alternativas planteadas

```javascript
function count (string){
const obj = {};

string.split('').forEach( item =>{

obj[item] = obj[item] ? obj[item] + 1 : 1 ;

});

return obj;

}
```
Sending a RabbitMQ message with JSON payload using curl
Tags: firstpost, rabbitmq, curl
Published: 2021-09-03 13:51:05

If you are working with RabbitMQ in a deployed environment you will often not have access to the RabbitMQ web UI which allows you to send test messages to try things out. Here is an example curl you can use adapting it to your needs to send a JSON payload message via RabbitMQ.

Things to replace:
 * **USERNAME**: The RabbitMQ user's username
 * **USERPASSWORD**: The RabbitMQ user's password
 * **QUEUE_NAME**: The queue to publish to
 * **ENCODED_JSON_PAYLOAD**: The JSON payload. Make sure this is stringified (I just do a quick javascript console: `JSON.stringify({"my_json": "payload"})` that does the trick)


```sh
curl -s -u USERNAME:USERPASSWORD -H "Accept: application/json" -H "Content-Type:application/json" -X POST -d'{
	"vhost": "/",
	"name": "amq.direct",
	"properties": {
		"delivery_mode": 2,
		"headers": {}
	},
	"routing_key": "QUEUE_NAME",
	"delivery_mode": "1",
	"payload":"ENCODED_JSON_PAYLOAD",
	"headers": {},
	"props": {},
	"payload_encoding": "string"
}' http://localhost:15672/api/exchanges/%2F/amq.direct/publish


```
Why having a portfolio website is not necessary for getting hired in 2021
Tags: career, webdev, javascript, beginners
Published: 2021-09-03 13:46:04

Many years ago having a portfolio website used to be essential for finding work. In my opinion this is no longer the case and this is the reason why. Having a GitHub account is significantly more important these days. Every company expects you to have a GitHub and experience using GIT and version control. These have become the standards for programming now. On GitHub you can showcase your projects and I would argue that this is more important than having a portfolio website.

## GitHub is required

When you consider that GitHub is the preferred way to view a candidates work, a portfolio website might seem much less relevant. In fact I'm sure that many developers choose to use an external link that goes to their GitHub profile anyway. Let's not forget that GitHub have also introduced profile README pages for everyone so you could essentially use that as your portfolio page.

## The significance of blogging

Blogs give people a better insight into your personality and skills and I believe that it is even more relevant at the moment. In terms of updates, generally people choose to be more active with their blogging compared to a portfolio website which might not get updated as regularly. So if you wanted to see a developers latest work or thoughts then it is better to just read their blog.

## Social Media's importance

Social Media is a great way to show what you are doing and working on and it can also be a way to gauge culture fit as you can see what a persons interests are. Having a strong social media presence showed how good I was at self learning and it definitely helped me to get hired.

## Using a Hybrid model

Don't get me wrong having a portfolio website can still be useful. It is still one of the best ways to find you in searches and that makes it super simple to get in touch. However I feel like a hybrid model that integrates a few different platforms could be a good  solution. So essentially using your portfolio website like a portal to your other profiles basically like [linktree](https://linktr.ee/) or [carrd](https://carrd.co/) while integrating different platforms.

You could use the GitHub API and the API for a blog website to display all of the content on your portfolio without having to create a custom solution from scratch. And if you could find a way to integrate your social media accounts into this system then you could have a great portal for showcasing all of your accounts and the content that you have for them.

## Final Thoughts

I really hope that you enjoyed reading this article and learned something from it. As a content creator and technical writer I am passionate about sharing my knowledge and helping other people reach their goals. Let's connect across social media you can find all of my social media profiles and blogs on [linktree](https://linktr.ee/andrewbaisden).

Peace ✌️