teleren/devto huggingface dataset:
Ordenar un array en JavaScript basado en el valor de un subarray
Tags: javascript, webdev, programming, spanish
Published: 2023-04-05 16:00:00

Anteriormente hablamos de [cómo obtener el valor mínimo y máximo de un array de arrays en JavaScript](https://asjordi.dev/blog/obtener-el-valor-minimo-y-maximo-de-un-array-de-arrays-en-javascript/), en este artículo vamos a ver cómo ordenar un array en JavaScript basado en el valor de un subarray.

Para esto utilizaremos el siguiente array de usuarios:

```js
const usuarios = [
  ['Nate', 31],
  ['Carlos', 33],
  ['Jazmin', 2],
  ['Susan', 29]
]
```

Este array de usuarios contiene 4 sub-arrays, cada uno con el nombre y la edad de un usuario.

## Ordenar un array por el valor de un subarray

Para lograr ordenar el array, se utilizará el método `sort()`. En su forma más simple, al llamarlo dentro de un array, intentará ordenar los elementos de acuerdo a su contenido, por ejemplo, si el array contiene `strings`, los ordenará alfabéticamente, si contiene `números`, los ordenará de menor a mayor, etc.

```js
console.log(['b', 'c', 'a'].sort())

// ['a', 'b', 'c']
```

Pero para nuestro objetivo es un poco más complicado ya que se tiene un array de arrays. Utilizar el método `sort()` tomaría el primer elemento del array como su método de clasificación, por lo que se ordenaría por el primer elemento de cada sub-array, en este caso, el **nombre**.

```js
console.log(usuarios.sort())

// [['Carlos', 33], ['Jazmin', 2], ['Nate', 31], ['Susan', 29]]
```

Esto funciona si se desea ordenar el array por el primer elemento de cada sub-array, pero en nuestro caso, queremos ordenar el array por el segundo elemento de cada sub-array, en este caso, la **edad**.

Para esto se utilizan los parámetros de la función de comparación que se le pasa al método `sort()`.

```js
usuarios.sort((a, b) => {
  // TODO
})
```

Esta es la sintaxis de la función de comparación que se le pasa al método `sort()`. Esta función recibe dos parámetros, `a` y `b`, que son los elementos que se están comparando en cada iteración.

```js
usuarios.sort((a, b) => {
  return a[1] - b[1]
})
```

De esta manera se obtendria el siguiente resultado:

```js
console.log(usuarios)

// [['Jazmin', 2], ['Susan', 29], ['Nate', 31], ['Carlos', 33]]
```

A su vez, también se puede cambiar el orden de la comparación, para que ordene de mayor a menor, simplemente cambiando el orden de los parámetros de la función de comparación.

```js
usuarios.sort((a, b) => {
	return b[1] - a[1]
})
```

Similar al ejemplo anterior, esto se traduce en el siguiente resultado:

```js
console.log(usuarios)

// [['Carlos', 33], ['Nate', 31], ['Susan', 29], ['Jazmin', 2]]
```

Incluso, esto se puede hacer en una sola línea:

```js
usuarios.sort((a, b) => a[1] - b[1])

console.log(usuarios)

// [['Jazmin', 2], ['Susan', 29], ['Nate', 31], ['Carlos', 33]]
```

Y de esta manera es posible ordenar un array de acuerdo con el valor de un subarray, de una manera muy sencilla y sin necesidad de escribir código adicional.
Prove Developer's Guide: Prove's Approach to Batch APIs
Tags: prove, developer, batch, sftp
Published: 2023-04-05 16:00:00

Batch APIs, also known as batch processing APIs, can be a helpful way to perform large-scale operations on a system by sending a batch of requests in a single call rather than making individual requests for each operation. This can be a more efficient and cost-effective way to handle lots of data.

## Asynchronous vs. Synchronous

There are a few different ways to implement batch APIs, depending on the needs of your system and the type of operations you're performing. For example, you can use asynchronous batch processing, which lets you send the batch of requests and then continue with other tasks while they're being processed in the background. You can also check on the status of the batch and retrieve the results when they're ready. Or, you might use synchronous batch processing, which processes the batch of requests in real time and returns the results to you as soon as they're available. Finally, you can use scheduled batch processing, which lets you specify a schedule for the batch to be processed, allowing you to set up recurring or routine operations without manually initiating them each time.

## SFTP File Transmission

At Prove, we implement asynchronous batch processing when a client can send us a properly formatted CSV file which we run through our batch processing tool and then return the file using a secure SFTP server. The number of files submitted and the frequency is directly related to how long it will take to process the data.


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

It's essential to think about the needs of your system and the type of operations you're performing when deciding which batch processing method to use. For example, asynchronous batch processing may be more efficient for large-scale operations that don't need immediate feedback while synchronous batch processing might be necessary for immediate feedback operations.

## Batch APIs vs. One-Off Requests

Overall, batch APIs can be a great way to improve the efficiency and scalability of your system, especially when you're dealing with lots of data. By allowing you to perform large-scale operations in a single call, batch APIs can save you time and resources, making them a valuable tool for any system that needs to process a lot of data.

Prove offers batch processes for Identity Manager (Fonebook Enroll, Update, and Disenrollment), Trust, Verify (as well as Verify & Trust combined), Contact Enrichment, and the Fraud Network.
Discover to Sponsor Global Accessibility Awareness Day Hackathon
Tags: hackathon, design, a11y, fintech
Published: 2023-04-05 15:56:31

Discover Financial Services will serve as Gold sponsor for the Global Accessibility Awareness Day Hackathon April 24-May 18.

Deadline to register for the event is April 21. For more information and to register, visit https://www.finos.org/hosted-events/2023-05-18-gaad-hackathon
A Better Way to Develop and Debug Applications
Tags: programming, productivity, webdev, visualstudio
Published: 2023-04-05 15:42:44

## New Dev Tunnels in Visual Studio

Visual Studio is a popular integrated development environment (IDE) used by many developers to write and debug code. It has a wide range of features that can help streamline the development process, including a new feature called Dev Tunnels.

**What are Dev Tunnels?**

Dev Tunnels is a new feature in Visual Studio that enables developers to access their local development environment from remote devices, such as smartphones, tablets, or other computers. It creates a secure tunnel between the local machine and the remote device, allowing developers to test their applications in real-time without the need for additional hardware or software. Dev Tunnels work by using the ngrok service, which provides secure introspected tunnels to localhost.

Dev Tunnels allow developers to easily expose a local development web server to the internet without deploying the code to a remote server. This can be useful for testing web applications or sharing a development site with others.

**How do Dev Tunnels work?**

Here's how you can use the new Dev Tunnels feature in Visual Studio:

Open Visual Studio and create a new web application project or open an existing one.

Start the web application project by clicking the "Run" button or pressing "F5" on your keyboard.

Once the web application is running, go to the "Debug" menu and select "Start New Dev Tunnel".

In the "Start New Dev Tunnel" dialog box, select the web application project you want to expose and choose a port number to use.

Click the "Start" button to create the tunnel.

The Dev Tunnel will now be active, and you can access the local development server from any device with an internet connection by using the provided URL.

For example, if you chose port 5000 and the provided URL is "https://random-word-12345.loca.lt", you can access your local development server by typing "https://random-word-12345.loca.lt:5000" into your web browser.

Using Dev Tunnels can save you time and hassle by allowing you to test and share your web application without deploying it to a remote server. Give it a try and see how it can help streamline your development process!

In conclusion, Dev Tunnels is a new feature in Visual Studio that can help developers expose a local development web server to the internet without deploying the code to a remote server. It can be useful for testing web applications or sharing a development site with others. By following the steps above, you can easily use this new feature and improve your development workflow.
Stocks Visualizing and Forecasting of Real Time Data
Tags: datascience, deeplearning, python, github
Published: 2023-04-05 15:19:34

To create a single-page web application and some machine-learning models which will show company information (logo, registered name and description) and stock plots based on the stock code given by the user. Also, the ML model will enable the user to get predicted stock prices for the data inputted by the user.
Increasing Perl’s Visibility, Redux
Tags: perl, html, http
Published: 2023-04-05 15:33:15

---
title: Increasing Perl’s Visibility, Redux
published: true
date: 2023-04-05 15:19:28 UTC
tags: Perl,HTML,HTTP,perl
canonical_url: https://toby.ink/blog/2023/04/05/increasing-perls-visibility-redux/
---

Quite a while ago, [I blogged about how Perl projects should have websites](https://toby.ink/blog/2020/02/07/increasing-perls-visibility/) to increase not only their visibility, but the visibility of Perl as a whole.

Perl has had the CPAN and awesome websites like MetaCPAN and its predecessor search.cpan.org for a long time, so unlike how things happen in other programming language ecosystems, many Perl projects have felt no need to start their own websites for documentation, package downloads, and community — all these things were already provided.

However, I do feel that this centralization keeps Perl content on the Internet very isolated and makes Perl less visible than other programming languages.

I’ve recently released [Web::PerlDistSite](https://metacpan.org/dist/Web-PerlDistSite) to provide an easy way to generate a modern-looking website for your project based mainly on its existing pod. You can then publish your site on github.io or your own hosting.

I used it to create [this website for Exporter-Tiny](https://exportertiny.github.io/) and also to revamp the existing [website for Type-Tiny](https://typetiny.toby.ink/).

If you’ve got a CPAN distribution and want to create a website for it, Web::PerlDistSite could be a quick way to get started. The documentation is pretty limited right now, but you can [open an issue](https://github.com/tobyink/p5-web-perldistsite/issues) if you need help.
Nuevo curso de Python con Django
Tags: python, spanish, programming, beginners
Published: 2023-04-05 15:17:31

En primer lugar, quiero pedir disculpas a mis fieles seguidores por mi cuota de asuencia en estas tierras DEVtoneanas. La razón de tal crimen imperdonable, es mi dedicación intensa a un nuevo curso que les traerá luz al camino del desarrollo web en Python.

# Amor por Django
Como ya había mencionado en algún artículo, iba a viajar por los confines del universo pythonista para traerles contenido que no solo les resultara interesante y entretenido, sino también les pudiera dar una salida laboral.

Hacer un curso de análisis, ingeniería o ciencia de datos era peligroso: mis conocimientos no son todavía suficientes, y no puedo darme el lujo de cometer un error que luego ustedes tengan que desaprender.

Mi apuesta segura era el desarrollo web: Ya había trabajado con Django para algunos clientes en el pasado, y vengo estudiando y realizando investigaciones en Python hace un tiempo, pero eso ya lo saben.

Por lo tanto, me interné en la teoría de Django, reviviendo algunos momentos del pasado, con un par de "ajá momments", y en cuestión de dos semanas, estaba preparando el temario.

# El temario
En el momento de escribir este artículo, el curso consta de 160 clases, videos en su gran mayoría. Escribir el temario completo en este artículo sería un despropósito, por lo cual déjenme denotar los tópicos más importantes:
- Fundamentos en Python (variables y tipos de datos)
- Condicionales
- Listas
- Bucles
- Funciones
- Manipulacion de Archivos
- Excepciones
- Programacion Orientada a Objetos
- Fundamentos en Django y Django Rest Framework

Luego está la parte práctica, la cual dediqué un especial enfoque porque sostengo la idea de "aprender haciendo":
- Calculadora
- Calculadora de Propinas
- Dice Rolling Simulator
- Random Password Generator
- Juego de Rol
- Gestion de empleados
- Hero Game
- Hero Game API con Django Rest Framework

# Udemy, tu hora ha llegado
Por supuesto, mi ecosistema de cursos está en Udemy, plataforma que no me ha descepcionado en todos mis años con ella. Pueden encontrar el curso utilizando [este link](https://www.udemy.com/course/desarrollo-de-sitios-web-con-python-3-con-django/?referralCode=A491B0944C634BFAA48C).

Intenten usar este y no otro, dado que Udemy se lleva una comisión de venta por cada curso mío que vendan por otros lados: la publicidad no se paga sola, señor Maxi.

# Y nosotros, tus fieles seguidores?
Para ustedes van a salir ofertas especiales, y por supuesto, muchos más artículos en materia de Python y las librerías que se me crucen en el camino.

Por lo tanto, los espero en el curso, y no se preocupen, el diario de Python sigue vivo y lo voy a actualizar muy pronto!
Welcome Thread - v219
Tags: welcome
Published: 2023-04-05 15:06:41

---
title: Welcome Thread - v219
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
canonical_url: 
---
![The word "HEY" in bold flashing colors on a bright blue background](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zuhpmqq5lks2gcqf6og7.gif)

---

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
console.log is slow
Tags: tip, javascript
Published: 2023-04-05 14:42:29

Im not kidding, your code might not actually be slow, take out your console logs and never benchmark with them inside the code exec, its staggeringly slow.

*Edit:* kudos DeChamp for this high level reporting although you should run your own tests there are plenty of ideas in the comments, enjoy!
{% comment https://dev.to/dechamp/comment/25p5o %}
python -u
Published: 2023-04-05 14:34:16

Hello, i am sitting now for 2 hours in a cafe, trying to solve the problem.
The interpreter keeps typing python -u as default, while i am trying to run my python code. Somehow it isnt working, except i type python3 -u manually. 
I tried uninstalling python so python3 is beeing used as default.
I also tried a lot of other solutions like reinstalling it but it still doesnt work. 
Can some smarter guy than me please help me how i can run python3 -u as default when i press "run code"?
Thank you very much
Important commands used in terminal
Published: 2023-04-05 14:32:51

Here we are going to discuss about some important and frequently used some commands in ubuntu terminal.

## CD Command
      cd command is akso called as **chdir** that means change directory.
      Its is used to chabge a current location of one directory to another location.
Ex:         cd my\songs

## LS Command
      ls command is used to list the files and directories that are available in your system.
      There are many types of ls command available,that are

1.ls -a
    this  command is used to display the hidden files or directory

2.ls -l
    this command is used to display the complete information about the files

3.ls -f
    this command is used to classify the files with special charecters for example (@,$,*) that are ens with the sumbols.

## MKDIR Command
         It allows the user to make new directories.
         this command is used to create the new directories.
Ex: Crete the simple directory on current location.

```
mkdir book_title
```
o/p book_title

## MV Command
      To move a file from one loaction to another location we use the mv command

```
mv filename destinationfile
```
How to install chrome using terminal in UBUNTU
Published: 2023-04-05 14:32:21

Chrome is a web browser that was developed  by the Google

## Step 1
      to intall chrome, we need to update our terminal that is

```
sudo apt update
```

## Step 2
      Next step is to check the version

```
wget --version
```
if it is not coming then try another way

```
sudo apt insatall wget
```

## Step 3
     installation process

```
wget https:dl.google.com/linux/direcct/google.chrome.stable_current_amd64.deb
```

```
ls
sudo dpkg .i google.chrome.stable_current_amd64.deb

```

## Step 4
       To run the chrome enter the command as

```
google-chrome
```
How creating stacks can change the way that you work, as a Developer.
Tags: devops, cloud, aws
Published: 2023-04-05 14:28:42


In my carrer, as a DevOps Intern, I learned a lot of technologies and tools. Every tool can save so much time of coding, or mental energy — if you are a lazy person — . However, there was a specific one tool, that could help and change the way I could work.


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



> “CloudFormation is an Amazon Web Services (AWS) service that allows you to create, manage, and provision infrastructure resources in the cloud in an automated manner. Stacks are one of the key features of CloudFormation, allowing you to define and provision resources together, creating a consistent and reproducible infrastructure environment. For a developer, CloudFormation stacks can significantly change the way they work, making the process of deploying and managing infrastructure resources more efficient and agile.”


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



Let’s check 3 motives to learn more about this Service:

**1 . Infrastructure Automation**

With CloudFormation stacks, it is possible to define and provision infrastructure resources in an automated and consistent way. This means that a developer can create and deploy complete infrastructure environments with just a few commands, without the need to manually configure each resource.

**2. Team Collaboration**

CloudFormation stacks allow multiple people to work together in defining and provisioning infrastructure resources. This means that a developer can collaborate with other team members, sharing resource definitions and facilitating collaboration on large-scale projects.

**3. Error Reduction**

By defining infrastructure resources in a stack, it is possible to ensure that the dependencies and configurations of each resource are consistently defined. This reduces the possibility of configuration errors and dependency failures, ensuring a more stable and reliable infrastructure environment.


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



What about now ?
Interested to learn and create something in Cloudformation ?

Alright, let’s do this !
Here’s a tutorial about how you can start understanding more:


{% embed https://youtu.be/Omppm_YUG2g
 %}


That’s it for today! See ya soon !
Unique ID in Javascript
Tags: javascript
Published: 2023-04-05 14:15:58

Probably you also had cases where you needed a unique ID, and using [uuid](https://www.npmjs.com/package/uuid) was not practical. 

So What can be used as an alternative to this? Let's look at some cases.

## **Math.random**

As we know, the [Math.random](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) function generates random numbers. 

When you try to assign a unique ID using Math.random immediately begs the question. 

Is there any chance the generated number can be repeated and you will not get a unique ID? 
The chance is small but still there.

Can I use it?
Yes you can, but not worth it.


What should we do in such a case? 
Use the options below.

## **Date.now**

**What is Date.now?**

The [Date.now](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now) static method returns the number of milliseconds elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC.

This means that the returned numbers cannot be repeated. (_unless of course, you have a secret method to go back in time_)

The only case where the Date.now method can return the same digit is, when you call Date.now() function before a 

> few (_depends on the execution environment_)
 milliseconds have passed.

**When can this happen?**

For example, you need to have a list of ids with unique ids.
The first thing that comes to mind is to write a for loop.

---

**WRONG APPROACH**

```javascript
const idList = [];
for (let i = 0; i < 10; i++) {
  idList[i] = Date.now();
}
```
Most likely you will get the same ids.

---

**RIGHT APPROACH**

```javascript
const idList = [];
const ms = 10; // depends on the execution environment
const interval = setInterval(() => {
  idList.push(Date.now());
  if (idList.length === 10) {
    clearInterval(interval);
  }
}, ms);
```
This way you can get unique list of ids.

---


But that's not all, there are even more advanced options.

## Crypto.randomUUID

The [self.crypto.randomUUID](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID) method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.

```javascript
const idList = [];

for (let i = 0; i < 10; i++) {
    const uuid = self.crypto.randomUUID();
    idList[i] = uuid;
}
```

But you must be sure that the runtime supports [Crypto](https://developer.mozilla.org/en-US/docs/Web/API/Crypto).

It all depends on what problem you are solving.
...https://coderolls.com/uuid-in-java/
How to open and play NSV files on Mac?
Tags: nsv, mac, software, files
Published: 2023-04-05 14:05:56

NSV  is a digital container format developed by the creators of Winamp Media Player. As the name suggests, it is designed to stream videos over the Internet. NSV belongs to old formats and is not compatible with most players. A special media player is required to view such files.
Let's take a look at one of the best players for opening NSV files.

Elmedia Player is an all-in-one player for Mac that supports a variety of formats, providing the best compatibility and functionality. It is a simple-to-use yet powerful program. One of the main features of the player is its wide format support. With Elmedia, you can effortlessly open NSV videos and any other type of content in your library.
After reading this article, you will learn a lot of interesting and useful things https://www.elmedia-video-player.com/blog/how-to-open-nsv-file-on-mac/
Fully Interactive PS5 UI Concept [INTERFACES]
Tags: codepen
Published: 2023-04-05 14:05:47

<p>Concept by Joshua Oluwagbemiga on Dribbble: <a href="https://dribbble.com/shots/11897442-PlayStation-5-Concept-UI-InVision-Studio" target="_blank">https://dribbble.com/shots/11897442-PlayStation-5-Concept-UI-InVision-Studio</a></p>

{% codepen https://codepen.io/nasedit/pen/wvYwNZw %}
Keep your WordPress CMS websites up-to-date with wp-cli and wp-cli-updater
Published: 2023-04-05 14:03:42

Consider using https://github.com/podlom/wp-cli-updater if you have some amount of WordPress CMS websites you need to periodically update.

Installation:
`git clone https://github.com/podlom/c.git`

`cd https://github.com/podlom/wp-cli-updater.git`

`cp -fvp config/environments.sample.php config/environments.php`

Edit config/environments.php and define your WordPress CMS environments.

Usage:

Update WordPress CMS core for environment #1
`php8.1 update-core.php 1`

Update WordPress CMS plugins for environment #1
`php8.1 update-plugins.php 1`

Update WordPress CMS themes for environment #1
`php8.1 update-plugins.php 1`