teleren/devto huggingface dataset:
Chained middlewares in Express.js
Tags: express, node, backend, beginners
Published: 2023-08-17 21:22:57

[GitHub link to the article](https://github.com/sanjar-notes/nodejs/blob/925a86d740ed42ff378d4635561a8913238b8471/home/4_resource_itineraries/2_Node_js_complete_guide_academind/5_Express_js/63_Chain_of_middlewares.md)

## Situation
Suppose I need to run multiple middlewares for the exact same method, route, router or maybe with `.use()` itself.

Let's try with the `.use()` one, should be simple, I just write them one below the other. 

But what if the number of middlewares are not known, or I'm lazy. Can I use a for loop?
No. Since all `.use(callback)` are callbacks, we never run them until we get a request - so it's *not possible* with a for loop.


## Solution - how
Since looping is not possible.
Express supports comma separated syntax or an array of middlewares passed to `.use` (and other functions).
The syntax is very flexible - everything is linearized.


## Solution - syntax
Here's the syntax:
```js
app.use(myMiddleware); // already familiar


// 1. Comma-separated works fine too (all will be run in order)
app.use(myMiddleware1, myMiddleware2, myMiddleware3);

// 2. Array also works 
app.use([myMiddleware1, myMiddleware2, myMiddleware3]);

// 3. can use both - it still works
app.use(myMiddleware1, [myMiddleware2, myMiddleware3], myMiddleware4);

// 4. btw, nested arrays work too, Express just flattens them
app.use(myMiddleware1, [myMiddleware2, [myMiddleware3]], myMiddleware4);
```

Works with `.router()`, `method('', )` too.


## Doubt (ignorable)
Q: Could it work with this notation of comma, or array if we can write a wrapper with a loop?
A: It would work, but not properly or for call cases:
1. For middleware that don't respond. 
	1. It would *seem* to work. Since each middleware in the loop would call `next()`, but the first iteration would end the wrapper (which is a middleware itself). So the others in the loop would run (but not in the queue - they will run independently). **Doesn't work**
2. If they respond - **won't work**, see why: 
	- If the first one is a non-responding middleware, point 1 happens (out of order exec) - not acceptable.
	- If we ignore out of order/independent execution. Let's see what happens, the responding middleware runs... fine, no. When the next middleware (be it responding or non-responding), we would get headers set error - since it would reach the 404.

I know, we can update `res.locals` and catch that in 404, but the out of exec order is till not solved.

## Conclusion

Construct of arrays/comma separated middleware is a REQUIRED feature.

It makes it easy to develop Express apps.
Apache Airflow on EC2 with RDS
Published: 2023-08-17 21:13:40

```zsh
sudo apt update && sudo apt upgrade -y
```

```zsh
sudo apt install python3-pip python3-psycopg2 default-libmysqlclient-dev
```

```zsh
python3 -m pip install --upgrade pip
```

```zsh
pip install --user apache-airflow[amazon] apache-airflow[postgres] apache-airflow[celery] psycopg2-binary apache-airflow-providers-mysql Redis
```

```zsh
echo "export AIRFLOW_HOME=${HOME}/airflow" >> .zshrc
```

```zsh
airflow db init
```

`airflow.cfg`

```
[core]
executor = CeleryExecutor
load_examples = False

[database]
sql_alchemy_conn = postgresql://myuser:mypassword@my-rds-instance.abc123.us-west-2.rds.amazonaws.com:5432/mydatabase`

[celery]
broker_url = redis://localhost:6379/0
result_backend = redis://localhost:6379/1
```

Celery Executor: https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/executor/celery.html

```zsh
airflow db init
```

```zsh
airflow users create --username admin --firstname FirstName --lastname LastName --role Admin --email email@example.com
```

`/etc/systemd/system`

```zsh
sudo systemctl enable airflow-webserver.service

sudo systemctl enable airflow-scheduler.service

sudo systemctl enable airflow-celery-flower.service

sudo systemctl enable airflow-celery-worker.service

sudo systemctl start airflow-webserver

sudo systemctl start airflow-scheduler

sudo systemctl start airflow-celery-flower

sudo systemctl start airflow-celery-worker
```
Broken pinky... any suggestions for voice to text apps? 🤙
Tags: discuss, productivity
Published: 2023-08-17 21:12:44

Hey folks!

I broke my 5th metacarpal (aka pinky) in what is commonly referred to as a [boxer's fracture](https://www.webmd.com/a-to-z-guides/boxers-fracture). 🥊

In short, I slipped up in the shower and clumsily threw my hand out, whacking my fist super hard against the tile wall. The tile basically looks untouched, but my hand took a beating. Cool story, huh? 🤦

Anyway, I have a Mac and started to use [Dictation](https://apps.apple.com/us/app/dictation-speech-to-text/id1124772331) as a speech-to-text app to help get around one-handed typing, but I wonder if there's something better... anybody have any suggestions for a speech-to-text app? Would be particularly cool if it could easily output to Markdown...
GROUP BY clause in PostgreSQL
Tags: tutorial, postgressql, database, sql
Published: 2023-08-17 21:09:17

In this tutorial we will learn about the use of `GROUP BY` clause.
So, let's get started...
It is used to divide the rows in groups that are return from the `SELECT` statement. You can then apply aggregate functions such as 'SUM()' or 'COUNT()' to each group to find sum or number of items in the groups.

**Syntax**

```
SELECT 
   column_1, 
   column_2,
   ...,
   aggregate_function(column_3)
FROM 
   table_name
GROUP BY 
   column_1,
   column_2,
   ...;
```
The above statement shows the syntax of the 'GROUP BY' clause.
In this syntax, first select the columns that you want to group and apply the aggregate function such as here we can see I have used 'column_1', 'column_2' in the above syntax.
Second list all the columns in the 'GROUP BY' that you want to group.

PostgreSQL evaluates the 'GROUP BY' after the 'FROM' and 'WHERE' clauses but it is evaluated before 'HAVING', 'SELECT', 'DISTINCT', 'ORDER BY' and 'LIMIT' clauses.
This can be seen through the following image:

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

**Examples**
**1) GROUP BY without an aggregate function:**
We can also use the 'GROUP BY' without using any aggregate function. Let's see an example:

```
SELECT
   customer_id
FROM
   payment
GROUP BY
   customer_id;
```
In the above code it gets the data from the 'payment' table and group them by the customer id. Here it acts like distinct and removes all the duplicate results from the set.

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

**2) GROUP BY with SUM() function:**

```
SELECT
	customer_id,
	SUM (amount)
FROM
	payment
GROUP BY
	customer_id;
```
To calculate and select the total amount each customer has paid, we can use the 'GROUP BY' clause to first divide the rows in groups in the 'payment' table and then for each group sum the total amount.

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

**Conclusion:**
In this article we learned about 'GROUP BY' clause.
Unveiling the Benefits of Open Source Involvement: An In-Depth Manual for Engaging with Apache AGE
Tags: apacheage, postgressql, database, opensource
Published: 2023-08-17 21:06:58

Participating in open-source projects not only promotes professional growth and networking, but also enables you to have a significant impact on initiatives that are important to you. Such contributions benefit greatly from the open-source Apache AGE extension for PostgreSQL, which adds graph database capabilities to it. In this post, we'll examine the advantages of contributing to Apache AGE's development and offer a step-by-step manual for getting started.

**Welcome to Apache AGE!**
A distributed query engine specifically designed to manage enormous amounts of graph data is known as Apache AGE. The in-memory columnar data format Apache Arrow serves as its core, and it adds support for well-known graph query languages like Cypher and PGQL. Users can run complicated graph queries using Apache AGE on huge datasets, which offers excellent performance and scalability.

**Holding an Apache AGE:**
Learn about Apache AGE and its ecosystem to get started on your journey. Investigate the project website, GitHub repository, and authorized documentation. This will give a thorough grasp of its goals, attributes, and the fundamental graph database ideas it adopts.

**Identifying Possibilities to Contribute:**

**Find ways to support Apache AGE:**

- In order to find open bug complaints, search the GitHub issue tracker. Choose a topic that fits your interests and areas of competence.
- Feature Enhancement: Examine current feature requests and interact with the community to come up with ideas for advancements.
- Enrich the documentation by adding new parts or improving the existing ones to help users utilize Apache AGE more efficiently.

**Code Contributing:**
To contribute to Apache AGE, take the following actions:

- Understanding Contribution Guidelines: Become familiar with the project's contribution policies, coding requirements, and code review procedure.
- Issue Selection: Select a problem you want to address, and inform the neighborhood about your plans to prevent duplication of effort.
- Development and testing of the code: Create the necessary code alterations to handle the found problem. To verify your modifications and guard against potential regressions, create unit tests.
- Submission of a pull request: Create a special branch for your modifications, fork the Apache AGE repository, and then send a pull request. Explain the changes made in detail and make reference to the relevant problem.

**Conlusion:**
Participating in Apache AGE's open-source project has many advantages, including the chance to advance one's career and influence the development of graph database systems. You can start your open-source experience with Apache AGE by following this manual, leaving a positive legacy and becoming a part of a vibrant developer community. Take advantage of this opportunity to educate yourself, work with others, and advance Apache AGE as well as the greater field of graph databases.
MQTT Performance Benchmark Testing: EMQX Single Node Supports 5M Connections
Published: 2023-08-17 21:04:30

In this post, we provide the benchmarking result of EMQX connection - a single node EMQX processes 5M concurrent connections.

## Test Scenario

This benchmark testing simulates 5,000,000 MQTT clients connecting to EMQX, with a connection rate of 5,000 per second.

* Concurrent connections: 5,000,000
* Connection rate: 5000/s
* Authentication: no
* Keep alive: 300s
* Clean session: true

## Testbed

The test environment is configured on Alibaba Cloud, and all virtual machines are within a VPC (virtual private cloud) subnet.

Machine Details:

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

## Test Tool

[**XMeter**](https://www.emqx.com/en/products/xmeter) is used in this benchmark test to simulate MQTT clients. XMeter is built on top of JMeter but with enhanced scalability and more capabilities. It provides comprehensive and real-time test reports during the test. Additionally, its built-in monitoring tools are used to track the resource usage of the EMQX machines.

XMeter provides a private deployment version (on-premise) and a public cloud SaaS version. A private XMeter is deployed in the same VPC as the EMQX in this testing.


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



## System Tuning

Please refer to [**EMQX Doc**](https://www.emqx.io/docs/en/v5.0/performance/tune.html) for the Linux Kernel tuning.

## Benchmark Results

EMQX dashboard illustrates that over 5M concurrent connections are achieved, and the connection is rather stable throughout the 30-minute’s test.

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

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

### Metrics


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



## Wrapping up

This benchmark report demonstrates the robust concurrent connectivity performance of EMQX in a single-node deployment. It shows that EMQX can help users build larger scale IoT applications while using fewer machines, helping to reduce your total cost of ownership.

Originally published at [www.emqx.com](https://www.emqx.com/en/blog/emqx-single-node-supports-5m-connections)
How to update your .gitignore file
Tags: git, programming
Published: 2023-08-17 20:41:55

## Problem

I do not know if you have faced this problem before, but if you are in a team maybe some of your colleagues or even you, had uploaded a file into the repository that should not be there, and then we found ourselves asking "What can we do to remove this file?".

First, we had to have put this file or file folder in our .gitignore file so that no one can upload it, not even by mistake. But don't worry we can fix it right away, just follow this simple steps.

## Solution

#### 1. Add the file or folder to ignore in your .gitignore file
(This is an example of a change in a .gitignore file)
```javascript
## ADDING LOG FOLDER TO IGNORE AND ALL ITS FILES (Example)
log*
```

#### 2. Make a commit with the change of your .gitignore file
```git
git add .
git commit -m ".gitignore updated"
```

#### 3. Remove the cache in your repository (this command is doing the job we wanted, it will remove all the files uploaded that should have been ignored)
```git
git rm -r --cached .
```

#### 4. Make a new commit to save the changes in your repository
```git
git add .
git commit -m "Files removed from .gitignore"
```

And that is all, now you are able of updating any .gitignore file.
Finding Your Why
Tags: webdev, motivation
Published: 2023-08-17 20:41:01

Someone once said that nothing in life that's worth doing is ever easy. Coding is no different.

I'm just getting back into coding after taking a long hiatus to deal with family issues, having taken countless tutorials and even a coding bootcamp before. It's nice to get the coding cobwebs off though and surprisingly, I've retained a lot of the theory behind it.

But at a certain point, I also know that impostor syndrome will rear it's ugly head, and I'll have those days where even getting a single line of code in will feel like a miracle. That's where "finding your why" comes in.

The first time someone told me that, it was my coding bootcamp instructor. My why is two things: finding a suitable career that I can be proud of and build a family with, and to be able to afford things I would like to be able to do, like be able to attend more soccer games. 

For others, their why may be to just get some extra skills in, or to be able to provide for their family better and are stuck in a job with no end in sight it seems. And those reasons are totally understandable.

When those days come that even getting a single line of code in is an accomplishment, step away from the computer for a bit, get connected to something else, whether it's mindless TV or a nice bike ride, then remember your why and regroup.
Aprendiendo de cero con w3schools
Tags: beginners, writing, spanish
Published: 2023-08-17 20:28:57

¿Estas pensando en aprender a programar💻?, pero realmente no sabes por donde empezar bueno, pues la página de w3schools es una excelente forma.
https://w3schools.com

![w3schools página](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vj6med3iryk5ejeynltn.png)

Acá una gran cantidad de contenido gratuito y por donde puede dar tus primeros pasos. Tiene muchos lenguajes de programación disponibles, desde el buen JavaScript a Go! pasando por Ciberseguridad y bases de datos como PostgreSQL.

Vale mucho la pena revisar el contenido para aprender y además como referencia la documentación hay ejemplos y puedes ejecutar directamente el código que estas viendo para ver cual es su funcionamiento.

Deja tus recursos o páginas favoritos para que mas conozcamos donde te nutres y aprendes de programación.
UPDATE statement in PostgreSQL
Tags: tutorial, postgressql, programming, database
Published: 2023-08-17 20:28:14

In this tutorial, We will be exploring how to update the data in an existing table.
Let's get started...

The `UPDATE` statement is used to modify the data in an existing table.

**Syntax**

```
UPDATE table_name
SET column1 = value1,
    column2 = value2,
    ...
WHERE condition;
```
In the above syntax, we can see that first we have specify the table name with the `UPDATE` keyword.
Second, we have to specify the columns that we want to update and their updated values after 'SET' keyword. Also note that those columns that do not appear in the 'SET' clause won't be modified. 
Third, we have to write the conditions which rows to be updated in the table after the 'WHERE' clause.

If you want to return the row that is/are just modified use the following code in the end:

```
RETURNING *;
```


**EXAMPLE**
Let's look at the example and practice it.
Suppose we have the following table which shows all the courses and description:

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


**1) Update one row from table**
The following query will modify one row from the table  that has `id`=2 and sets it `published_date` to `2020-07-01`.

```
UPDATE courses
SET published_date = '2020-07-01'
WHERE course_id = 2
RETURNING *;
```

**OUTPUT**


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



**Conclusion**

In this article we learnt about the 'UPDATE' statement and it's example.
Meet the New Blackbox Code Generator!
Tags: programming, tutorial, productivity, ai
Published: 2023-08-17 20:26:44

Introduction
If you have programmed for a while now, you may have found yourself on a bad day where you don’t have the creativity to code, to complete it or perhaps you found a bug and you didn’t know how to solve it. If that’s the case, meet the new feature from Blackbox, an AI that can help as a coding companion for your projects. This feature is called “Blackbox Generate Code”, and will help you out when you are stuck and out of ideas. In this article, we will talk about how it works and what it does. Keep reading to find out more!

Table of Contents
How It Works
Why Use It?

How It Works
This feature works in a very simple manner: first, you should install the Blackbox extension on VSCode. Once you’ve done that, simply start coding in any file or project you have. Whenever you want to, write a comment explaining what should the following lines have, a function, a data structure, anything. When you’re done, right click on the line below and click on “Blackbox Generate Code” and let the AI do its work. It will generate tons of lines of code in just a few seconds like it's magic!

Why Use It
This feature can save your time thinking on what to write next, rewrite it if it doesn’t work, or maybe just delete the whole code to start over again. It doesn’t only make the code you want, it actually completes the whole program by itself in a few seconds, which could be hours for you! You won’t waste your time again with this.

Work Better and Faster
Blackbox AI can save you lots of time with this and its many other features that it has, speeding up your code, minimizing the bugs of your code, and doing all the hard work for you! Use Blackbox today and change the way you work for the better.

Join the AI Community today!
The AIs are clearly the present and the future ahead waiting for us, and we should follow this path to improve in our work as Devs. Join the AI Community today by reading my list of articles talking about lots of topics on this subject, and sharing tips for you so you can learn about the human - AI partnership and use it to your advantage! Don’t waste time and start today.
¡Conoce al Nuevo Generador de Código de Blackbox!
Tags: programming, tutorial, ai, productivity
Published: 2023-08-17 20:21:43

Introducción

Si has estado programando durante un tiempo, es posible que hayas tenido un mal día en el que no tengas la creatividad para codificar, completarlo o tal vez hayas encontrado un error y no sepas cómo resolverlo. Si ese es el caso, conoce la nueva función de Blackbox, una IA que puede servir como compañera de codificación para tus proyectos. Esta función se llama "Generador de Código Blackbox" y te ayudará cuando te quedes atascado y sin ideas. En este artículo, hablaremos sobre cómo funciona y qué hace. ¡Sigue leyendo para obtener más información!


Tabla de Contenidos

Cómo Funciona

Por Qué Usarlo


Cómo Funciona

Esta función opera de manera muy sencilla: primero, debes instalar la extensión de Blackbox en VSCode. Una vez hecho esto, simplemente comienza a codificar en cualquier archivo o proyecto que tengas. Cuando lo desees, escribe un comentario explicando qué deben tener las líneas siguientes, ya sea una función, una estructura de datos, cualquier cosa. Cuando hayas terminado, haz clic derecho en la línea de abajo y selecciona "Generar Código Blackbox" y deja que la IA haga su trabajo. ¡Generará toneladas de líneas de código en cuestión de segundos, como por arte de magia!


![GIF showing how the feature works](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0bn76r0h7v1gwwh0s0p4.gif)

Por Qué Usarlo

Esta función puede ahorrarte tiempo al pensar en qué escribir a continuación, reescribirlo si no funciona o simplemente eliminar todo el código para comenzar de nuevo. No solo genera el código que deseas, sino que completa todo el programa por sí misma en cuestión de segundos, ¡lo que podría llevarte horas a ti! No perderás tiempo nuevamente con esto.


Trabaja Mejor y Más Rápido

La IA de Blackbox puede ahorrarte mucho tiempo con esta y muchas otras funciones que tiene, acelerando tu código, minimizando los errores y haciendo todo el trabajo pesado por ti. ¡Usa Blackbox hoy y cambia la forma en que trabajas para mejor!


¡Únete a la Comunidad de IA hoy mismo!

Las IA son claramente el presente y el futuro que nos espera, y debemos seguir este camino para mejorar en nuestro trabajo como desarrolladores. Únete a la Comunidad de IA hoy mismo leyendo mi lista de artículos que hablan sobre diversos temas en este campo y compartiendo consejos para que puedas aprender sobre la colaboración humano-IA y aprovecharla en tu beneficio. ¡No pierdas tiempo y comienza hoy mismo!
Does imposter syndrome ever get better?: CodeNewbie Podcast
Tags: beginners, codenewbie, podcast, career
Published: 2023-08-17 20:19:57

[Marley Anthony](https://twitter.com/marleyanth0ny), Software Engineer at Bench Accounting, came on the podcast yesterday to discuss the importance of maintaining a strong coding foundation, navigating performance improvement plans, and quelling imposter syndrome. We really couldn't have chosen a better way to start Season 25!

On the podcast, Marley shared that "Imposter syndrome [is always] going to be there. It’s just understanding how to deal with it better and understanding that it’s going to be part of your experience... nobody knows everything."

Needless to say, imposter syndrome is a super common difficulty when navigating any career, let alone in tech. Since everyone's approaches are super different in responding to imposter syndrome, we would love to know your thoughts! 

- What are your biggest tips for handling imposter syndrome? 

- Does imposter syndrome ever get better?

- How can we stop giving imposter syndrome all the power?


---

_ICYMI— find that episode below or wherever you get your podcasts_:

{% embed https://dev.to/codenewbieteam/pivoting-to-tech-from-biomedical-science-codenewbie-podcast-s25e1-khn %}

---

_Send us your thoughts below and don't forget to give it a listen here or wherever you listen to your podcasts!_ 💜