teleren/devto huggingface dataset:
What are the three dots (...) or spread operator in Javascript?
Tags: javascript, webdev, tutorial
Published: 2022-09-04 18:39:50

The **spread operator**, **spread syntax** or **3 dots** (...), is a type of syntax in Javascript which is used by both function calls and in arrays/objects. It has a multitude of different uses, so let's take a look at how we use the spread syntax in real Javascript code.</p>

## In function calls
We can use the 3 dots in Javascript function calls to convert an array into a set of arguments for a function. Let's look at an example. Below, our array is converted into the values for `x`, `y`, `z`, and `a`.
```javascript
let numbers = [ 1, 2, 3, 4 ];

let myFunction = function(x, y, z, a) {
    return x + y + z + a;
}

// Returns 10
myFunction(...numbers);
```
**This can be combined with other values**, so the following is also valid, using the same function as before:
```javascript
let numbers = [ 1, 2 ];

// Returns 15 (i.e. 5 + 7 + 1 + 2)
myFunction(5, 7, ...numbers);
```
This can also be used when calling a constructor with `new`, for example:
```javascript
let numbers = [ 1999, 26, 3 ];

let thisDate = new Date(...number);
```

## Merging Arrays
Another useful way to use the spread syntax is to merge arrays. For example, we can merge two separate arrays into a new one using two spread syntaxes:
```javascript
let x = [ 1, 2, 3 ];
let y = [ 4, 5, 6 ];

// Returns [ 1, 2, 3, 4, 5, 6 ]
let newArray = [ ...x, ...y ];
```
Similar to before, we can combine this with other values and still get the same outcome:
```javascript
let x = [ 1, 2 ];

// Returns [] 4, 5, 1, 2 ]
let newArray = [ 4, 5, ...x ];
```

## Merge Objects
Finally, we can use the spread syntax to **merge objects**. In the below example, we merge two objects with key/value pairs into one object:

```javascript
let obj1 = { name: "John" };
let obj2 = { age: 114 };

// Returns { name: "John", age: 114 }
let newObj = { ...obj1, ...obj2 };
```

**If we try to merge two objects and there is a duplicate key**, the second object will take precedence and overwrite the first one, as shown below:
```javascript
let obj1 = { name: "John" };
let obj2 = { name: "Jake" };

// Returns { name: "Jake" }
let newObj = { ...obj1, ...obj2 };
```

**And that's how spread syntax work** - they let us run functions with arrays easily, and are good for merging objects and arrays. You can find more Javascript tutorials at the bottom of this page.
Plus Minus problem
Tags: beginners, javascript, programming
Published: 2022-09-04 18:37:33

**Plus Minus problem** is a part of _1 month of interview prep_ on _HackerRank_. 
[I joined it today](https://www.hackerrank.com/s_vibhor).

It was the first of the lot hence it was seemingly easy but requires an important concept - **floating point precision**.
I used **Javascript** to solve it but you can also use any language which you want to use. 
In Javascript, there is a function - [**toFixed()**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) 

The problem asks the solver to take the _input as an array of integers_ and _output the ratio of positives, negatives and zeroes_; i.e. if an array [1,2,3,-4,-5,-6,0,0] is provided to you, you have to output the ratio of positives(array[i]) to length of array {in this case, it would be positives_ratio = 3/8 = 0.375} and same for negatives and zeroes.

Approach

- _<u>Initialize few variables</u>_ to count number of positives, negatives and zeroes {input is provided as an aray of integers};

`let pos_count=0, neg_count=0, zero_count=0;`

- _<u>Use for loop</u>_ {for of loop in Javascript} for traversal in the array and search for positive num, negative num and zeroes and increment their counts;

```
for(let i of array) {
    if(i<0) 
        neg_count += 1;
    else if(i>0) 
        pos_count += 1;
    else 
        zero_count += 1;
}
```

- _<u>Print the count_ratios</u>_ on the console(or prompt screens) by _<u>dividing each count by length of array and use the toFixed()</u>_ method to set the precision to 6 decimal places;

`console.log((pos_count/array.length).toFixed(6));`

_<u>Do same for negative count and zero count.</u>_

The problem is easy and suitable for beginners but requires the knowledge of **floating point precision**.
Feature Flags: What and Why?
Tags: featureflags, features, experimentation
Published: 2022-09-04 18:26:48

## What are feature flags?

Feature flags are ways to control how new features or code changes are rolled out. They're used in various scenarios:

### Gradual Rollouts

Once an engineering team gets to a certain size, it becomes extremely likely for bugs to surface during deployments, causing the site or application to fail for almost every user -- hence requiring rollbacks and post-mortems. Imagine you have 10s or 100s of engineers checking in code every day. It's just a matter of time before rollbacks start creeping in due to a particular code change requiring the entire release to be rolled back. 

One way to address this is by controlling the blast radius of code changes by doing something as follows in your business logic:

```python
if is_on('NEW_FEATURE'):
  # new logic
else:
  # existing logic
```

The main advantage here is that we can control the percentage of users for whom new logic will run and can ramp that up over time. Usually, you would start with 0%, ramp up the rollout, and monitor the impact of the change by looking at relevant dashboards. The moment you observe new exceptions, performance degradation, or error increase, you would then turn off the feature and continue business as usual. Without a feature flag system, you would be forced to rollback the change. You can have canary to minimize impact, but you don't have much control. There could be many code changes being rolled out and sometimes it's hard to know what change caused what.

### Gating Features

It's quite common to enable or disable features based on some attribute associated with the user, company, location...etc. For example, a new feature is rolled out to a selected set of beta-test users, internal users, or some other set of IDs. Instead of adding an attribute on the user per feature to be included/excluded, this can be delegated to a feature flag system where that mapping is dynamic and can be updated on the fly (i.e., new beta test users).


### Kill Switch

In case of emergencies, it's sometimes better to have a degraded user experience than a full site outage. So, it's useful to turn off certain features to reduce load on the backend. For example, imagine a scenario where the database is overloaded. The load is coming from unoptimized queries that are associated with a particular feature (i.e., search). It's better to turn off search temporarily to fix the issue as opposed to rendering the entire website unusable. Assuming the search feature code is gated by a feature flag, this can be easily done. In fact, it could be even ramped down and not necessarily turned off immediately.

## Try it yourself
Trying [FeatureGuards](https://www.featureguards.com) is free and doesn't require any credit card. Check out our [documentation](https://docs.featureguards.com) too if you're interested in learning more.
Once you start using feature flags, you will never look back. Would love to learn your thoughts in the comments below.
Koala Engine Core Alpha
Tags: gamedev, typescript, programming
Published: 2022-09-04 17:54:33

## News!
Today I published koala-engine-core on npm!
To get started clone the [demo](https://github.com/lorenzo774/koala-engine-demo)

## Help!
This project needs your contribution!
We need documentation, project structure and an editor.

----

github: https://github.com/lorenzo774/koala-engine
twitter: https://twitter.com/774Lorenzo
KALI LINUX: Common Commands that you should know : PART 2
Tags: linux, kali, kernel, devops
Published: 2022-09-04 17:44:47

##**Commands to know**
1. PART 1[](https://dev.to/msaghu/kali-linux-common-commands-that-you-should-know-1bjh)
2. PART 2[](url)

- 
There are 2 types of users:
1. Normal users - denoted by $ in the terminal
2. Root user - denoted by # in the terminal

#**Add users using:**

**kali >useradd** - adds new users BUT gives shell as _sh_ instead _bash_ , doesnt prompt for details/info about the user, doesn't create a home directory for the new user
**kali >adduser** - DOES ALL OF THE ABOVE for a new user


#**List users using:**

**kali >cat /etc/passwd**- lists users, their unique id, group id(gid), home directory, shell
**kali >cat /etc/shadow**-


#**Modify users using:**

**kali >usermod ironman --shell /bin/bash**- changes the users' shell to bash
**kali >usermod -l tonystark ironman**- changes user from ironman to tonystark


#**Switch users using:**

**kali >su - ironman**


#**Delete users using:**

**kali >userdel evans**-
**kali >deluser evans**-


#**Create/add group using:**

**kali >groupadd theavengers**-


#**List groups using:**

**kali >cat /etc/group**-
**kali >groups**- lists what groups the current user is in


#**Add user to a group using:**

**kali >usermod -aG theavengers evans**- appends the user evans to the group theavengers


#**Removes user from a group using:**

**kali >gpasswd -d evans theavengers**- 


#**Delete a group using:**

**kali >groupdel theavengers**












rm -rf/* (force remove of a directory and all contents in it recursively)
Quickly share your clipboard text between all your devices
Tags: webdev, devtools, programming, showdev
Published: 2022-09-04 17:32:53

Hey 👋

I’m Juan, creator of **[webclipboard.io](https://webclipboard.io)**.

🕵 **About the project**
webclipboard is an online free web app to share the clipboard text of all your devices in an easy, fast and really simple way. Most of us use telegram, whatsapp or emails to share text between devices. I think this will provide a faster way to do this.

🧩 **How does it works?**
First, when you join the page, you will see the link that you must enter from the other device with which you want to share the clipboard. Once done, a green alert saying "Devices synced" will be shown. Done! You can paste down in the field the text that you want to share.

🤔 **But.. why? This already exists!**
Well.. yes. This is not a brand new revolutionary feature, but it is a clean one. Everytime in the past when I needed to use an already existing app of this kind, it turned out being so difficult. This was due to a really poor functioning or a poor design just exploited with tons of ads, making the usage and the experience really awful. So.. I decided to make a new, prettier (or at least tried to 😋) and faster one. With a clean UI/UX.

🔒 **Is it secure?**
webclipboard.io uses **E2E encryption**. All the data sent and received is purely encrypted through AES and **is not stored in our servers**.

🚀 **Are any other features in mind?**
The answer is yes. And they are really cool.

I hope you find this tool useful!
Expressões Regulares II - classes de caracteres
Tags: regex, beginners, expressoesregulares, pcre
Published: 2022-09-04 17:24:17

No último artigo iniciamos no mundo das expressões regulares. Neste presente, continuaremos a expandir nossas ferramentas para aumentar as possibilidades de _match_ falando sobre _classes de caracteres_.

## Classes de caracteres

Classes de caracteres são usadas para podermos identificar diversos caracteres diferentes numa determinada posição. Vamos de exemplo novamente que é sempre mais fácil de explicar:

`Paul[ao]`

Essa expressão regular descreve tanto `Paula` quanto `Paulo`. Isso é feito com a sintaxe `[]`.

Quando uma determinada posição pode conter mais de um caracter, usar uma classe de caracteres é a solução. Também são suportados intervalos de dígitos e caracteres, dessa maneira:

* `[0-5]` => representa os dígitos de 0 a 5.
* `[f-j]` => representa os caracteres de _f_ a _j_.
* `[A-Fa-f0-9]` => representa os caracteres de _a_ a _f_, de _A_ a _F_ (regex é case sensitive, então maiúsculas e minúsculas são tratadas de maneira diferente) e os dígitos de 0 a 9. Basicamente, qualquer dígito hexadecimal.

Classes de caracteres também podem incluir caracteres não-alfanuméricos. No entanto, sua utilização muda. Os únicos caracteres entendidos como especiais dentro de uma classe de caracteres são o `]`, pois significa o fim da classe, `^` no começo da classe, pois significa negação (mais informações à frente) e `-`, pois indica que estamos falando de um intervalo. Dessa maneira, qualquer caracter que não os citados anteriormente é entendido como literal dentro de classes de caracteres.

* `Abc[*+]` => identifica os textos Abc* e Abc+

Para usar os outros três caracteres (`]`, `^` e `-`), é necessário escapá-los.

* `[a-f]` => identifica os caracteres de _a_ a _f_
* `[a\-f]` => identifica os caracteres _a_, _-_ e _f_

Se você desejar que a classe de caracteres represente caracteres que *não* podem ser identificados, utilize o caracter `^` no começo da classe.

* `[^abc]` => identifica qualquer caracter que não os caracteres _a_, _b_ e _c_
* `[^0-9]` => identifica qualquer caracter que não seja um dígito

## Cautela
É importante ressaltar que classes de caracteres negados ainda assim precisam dar match num caracter. A regex `a[^f]` não quer dizer "Letra 'a' não seguida da letra 'f'", mas fim "Letra 'a' seguida por um caracter que não seja a letra 'f'". E qual é a diferença?

A regex `a[^f]` dá match na letra 'a' em `Teresa.`, porque o caracter '.' não é 'f', mas não dá match na letra a em `Teresa`, pois não há nenhum caracter depois do 'a'.

## Conclusão

Sem conclusão dessa vez ^^. Até a próxima parte
Introduction to Data Engineering
Tags: python
Published: 2022-09-04 16:36:26

Data Engineering is a discipline that entails collecting, translating and validating data for analysis. A good data engineer makes quality data available for analysis and data-driven decision making.There are four disciplines a data engineer should be well aversed with:
Data. There are different types of data file formats for example csv,tsv,json.
Data stores and repository. This include relational and non-relational databases, data lakes and data warehouses 
Data pipelines. Entails collecting and gathering data from different sources 
Analytics and data driven decision making.
Python language is the preferred programming language for data engineering as it has a wide variety of packages which are easy to import and enhance performance in data wrangling, ETL(Extract, Transform, Load), Feature engineering.
Bringing HydePHP to the Cloud - Week One
Tags: webdev, laravel, hydephp, php
Published: 2022-09-04 16:18:22

## Introduction

Hey there! My name is Caen, I'm the creator of [HydePHP](https://hydephp.com) - a free and open source static site generator. As the software is nearing the initial 1.0 release I am working on a secondary side-project, bringing HydePHP to the Cloud. In this series of posts I will share my weekly progress as I'm #codinginpublic!

## This week's progress

### About up the app

So, this week I started a new Laravel app for the HydeCloud platform as I'm calling it. I'm building with the TALL stack using FilamentPHP. Using Filament means I can build faster than ever. Here are some screenshots of what I made this week!

### Auth Pages

#### Sign up and login pages

![The sign up and login pages](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/biu6vkvebt37dbcjlfdp.png)

#### Onboarding page

![Onboarding page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q518z1mbdl5mrb1ckefp.png)

#### Account settings page

![Account settings page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6bzqlgwthi7q33r9ojx5.png)

### Dashboard

#### Main dashboard

![Main dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y0xsu9r9acetu0fjq1d1.png)

#### Project management

![Project management](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/srxcu9nrf7m4g9bugv1y.png)

![Create project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q4kdsnjrub6mucydx7uk.png)

#### File browser

![File browser](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a1r1gasokcb0ef9j4nwo.png)

#### File viewer

![File viewer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zu90i2wz4ff32o1i2ywt.png)

### And finally, the landing page

![Landing page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qk9h0dzgmt6e2na3t4wd.png)

What do you think of my progress this week? What have you done yourself? Share in the comments!
Dead Tuples in PostgreSQL.
Tags: postgres, deadtuples, vacuum
Published: 2022-09-04 15:13:36

Today we are going to learn about Dead Tuples in PostgreSQL. As we know PostgreSQL is based on MVCC Architecture.

> MVCC is a `Multi Version Concurrency Control` basically "A single rows has multiple versions." 
E.g, If a user insert a record of a Person whose AGE is 21. Now, he update the record with AGE 22, so what PostgreSQL does here, PostgreSQL stored those two records with the different versions.
`Old version: Age = 21`
`New version: Age = 22`
By default user can only select the new version of the record, and old version marked as an `unused` record. 
That types of record called `Dead Tuple` or `Dead Row`. 

How to find Live Tuples or Dead Tuples using `pg_stat_user_tables`. 

```
select n_live_tup, n_dead_tup, relname from pg_stat_user_tables;
```
Find tuples from a specific table.
```
SELECT n_live_tup, n_dead_tup, relname FROM
pg_stat_user_tables where relname = 'users';
```

using Alias 
```
SELECT relname AS Table_Name, n_live_tup AS Live_Tuples,
n_dead_tup AS Dead_Tuples FROM
pg_stat_user_tables where relname = 'users';
```
SQL Result:
![Dead Tuples](https://res.cloudinary.com/sandeepkumardev/image/upload/v1662293261/dead_tuples.png)

> How to avoid to create Dead Tuple while Inserting the duplicate data.

If a table have some unique constraint and a user trying to Insert the same data again, PostgreSQL will return an error > 
`Uniqueness violation. duplicate key value violates unique constraint`. We can avoid this by using `ON CONFLICT DO NOTHING` clause. 
```
INSERT INTO users VALUES ('name', 'email@gmail.com')
ON CONFLICT DO NOTHING;
```

It'll return `INSERT 0 0` indicates that nothing was inserted in the table, the query didn't error out. In the case of `ON CONFLICT DO NOTHING` no dead tuples are generated because of the pre-check.

How to delete Dead Tuples using VACUUM - 
```
VACUUM users;
```
It'll free up the space within the users table and only users table can use this space. If you want to use this free space by system then this command should be run. 
```
VACUUM FULL users;
```

[Read More](https://www.postgresql.org/docs/current/sql-vacuum.html#:~:text=VACUUM%20reclaims%20storage%20occupied%20by,especially%20on%20frequently%2Dupdated%20tables.) about VACUUM.

Thank you <👨‍💻/>
Azure Back to School 2022 – Saving Customer Relationships with Azure Cognitive Services
Tags: conferences, development, azure, azurebacktoschool
Published: 2022-09-07 12:27:15

---
title: Azure Back to School 2022 – Saving Customer Relationships with Azure Cognitive Services
published: true
date: 2022-09-04 14:57:39 UTC
tags: Conferences,Development,Azure,AzureBacktoSchool
canonical_url: https://barretblake.dev/2022/09/azure-back-to-school-2022-saving-customer-relationships-with-azure-cognitive-services/?utm_source=rss&utm_medium=rss&utm_campaign=azure-back-to-school-2022-saving-customer-relationships-with-azure-cognitive-services
---

For those of you who missed it yesterday, you can catch one of my two Azure Back to School sessions below.

<iframe title="Azure Back To School 2022 - Saving Customer Relationships With Azure Cognitive Services" width="1200" height="675" src="https://www.youtube.com/embed/pUL7Iuac3bI?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

The post [Azure Back to School 2022 – Saving Customer Relationships with Azure Cognitive Services](https://barretblake.dev/2022/09/azure-back-to-school-2022-saving-customer-relationships-with-azure-cognitive-services/) first appeared on [Barret Codes](https://barretblake.dev).
Calculate the Volume of a Cube in Java
Tags: java, beginners, tutorial, programming
Published: 2022-09-04 14:44:17

The volume of a cube with side `s` is: `s x s x s` or `s` to the 3rd power.

In Java, the `Math.pow(x,y)` function raises `x` to the power `y`. Both variables are double values, and the function returns a double result.

Let’s write a Java program to calculate the volume of a cube. The first three lines import the `Scanner` class (needed for user input), declare the Java program class, and declare the main method:

```java
import java.util.Scanner;
public class Volume {
  public static void main(String[] args) {
```

Declare two variables in the main method to store the side of the cube and the volume:

```java
double s;  // side
double v;  // volume
```

Create a Scanner object that scans standard input. Store the object in the variable in:

```java
Scanner in = new Scanner(System.in);
```

Ask the user to input a value for the side:

```java
System.out.println("Please enter the side of the cube: ");
```

Use the `nextDouble()` method of the Scanner object to accept the side from the user and store it in the variable `s`. Note that the program will wait on this line until the user presses the _Enter_ key to input a value:

```java
s = in.nextDouble();
```

Use the `Math.pow()` function to raise `s` to the power `3`. Store the result in the variable `v`:

```java
v = Math.pow(s,3);
```

Output the result:

```java
System.out.println("The volume of cube with side " + s + " is " + v + ".");
```

Finally, close the main method and Java program:

```java
  }
}
```
Here is the complete program:

```java
import java.util.Scanner;
public class Volume {
  public static void main(String[] args) {
    double s;  // side
    double v;  // volume
    Scanner in = new Scanner(System.in);
    System.out.println("Please enter the side of the cube: ");
    s = in.nextDouble();
    v = Math.pow(s,3);
    System.out.println("The volume of cube with side " + s + " is " + v + ".");
  }
}
```

Thanks for reading. 😃

*Follow me on Twitter [`@realEdwinTorres`](https://twitter.com/realEdwinTorres) for more programming tips and help.*
Weekly Challenge 180
Tags: perl, python, theweeklychallenge
Published: 2022-09-04 14:31:07

[Challenge](https://theweeklychallenge.org/blog/perl-weekly-challenge-180/), [My solution](https://github.com/manwar/perlweeklychallenge-club/tree/master/challenge-180/sgreen)

## Task 1: First Unique Character

### Task

You are given a string, `$s`.

Write a script to find out the first unique character in the given string and print its index (0-based).

## My solution

This is relatively straight forward task. Loop through the index from 0 to 2 less than the length of string. If that character occurs later in the string, print the index.

## Examples

```bash
$ ./ch-1.py "The Weekly Challenge"
0

$ ./ch-1.py "Long Live Python"
3
```

## Task 2: Trim List

### Task

You are given list of numbers, `@n` and an integer `$i`.

Write a script to trim the given list where element is less than or equal to the given integer.

## My solution

This is also straight forward. I start by `pop`ing the last value from the list. I then use the for if function ([grep](https://perldoc.perl.org/functions/grep) for Perl) to get items in the list that are greater than that number.

## Examples

```bash
 $ ./ch-2.py 1 4 2 3 5 3
4, 5

$ ./ch-2.py 9 0 6 2 3 8 5 4
9, 6, 8, 5
```