teleren/devto huggingface dataset:
Mettre en place l'authentification sur Nginx
Tags: sre, devops, webdev
Published: 2023-03-13 14:50:00

Quand on utilise Nginx, il se peut que l'on veut restreindre l'accès à certaines URL ou chemins. Pour cela, on peut mettre en place une authentification, et c'est ce que l'on va voir aujourd'hui.

---

## Fichier htpasswd
Afin de permettre aux utilisateurs de se connecter, Nginx doit avoir le fichier `htpasswd` qui va contenir la liste des noms d'utilisateurs et leurs mot de passes avec le format suivant : 

```
user1:password1
user2:password2
...
```
Les noms des utilisateurs sont en clairs, mais les mots de passe doivent être encryptés avec **BCrypt**. 

Le plus simple pour pouvoir générer ce fichier et d'encoder les mots de passe est de le faire avec l'utilitaire `htpasswd`.

### Installer htpasswd
Cet utilitaire se trouve dans le package `apache2-utils`, que vous pouvez installer avec les commandes suivantes : 

```bash
sudo apt-get update
sudo apt-get install apache2-utils
```

### Utiliser htpasswd
La commande se présente sous le format suivant :
```bash
htpasswd [option] [chemin fichier] [nom utilisateur]
```
L'option utile à connaître est `-c` pour permettre de créer le fichier.

En suite, il ne vous reste qu'à définir chacun des utilisateurs/mot de passe et le tour est joué!

*Exemple*
```bash
# Créer le fichier et ajouter l'utilisateur toto
htpasswd -c /etc/nginx/htpasswd toto

# Ajouter un autre utilisateur
htpasswd /etc/nginx/htpasswd titi
```
---
## Configurer Nginx
Dans votre configuration Nginx, il vous suffira d'ajouter `auth_basic` & `auth_basic_user_file` comme dans l'exemple suivant et votre Nginx est prêt!

```
server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    server_name localhost;

    location / {
        try_files $uri $uri/ =404;
        auth_basic "Restricted Content";
        auth_basic_user_file /etc/nginx/.htpasswd;
    }
}
```

---

J'espère que ça vous aidera! 🍺

---

<center><h3>Vous voulez me supporter?</h3></center>
<a href="https://www.buymeacoffee.com/mxguilbert7" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
CheatGPT - The Ultimate Cheat Engine Powered by OpenAI
Tags: chatgpt, ai, svelte, saas
Published: 2023-03-05 19:59:51

Are you tired of studying for hours and still not being able to ace your tests? Look no further, because **CheatGPT** is here to save the day!

**CheatGPT** is a SaaS project that uses the power of AI to help you cheat your way to success. Simply submit your question, whether it's in text or image form, and CheatGPT will provide you with the perfect answer. No more wasting time studying or worrying about failing, CheatGPT has got you covered.

But wait, you may be thinking, isn't cheating unethical? We hear you, and that's why CheatGPT is all in good fun. We believe that if the technology exists, why not have a little fun with it? Plus, think of all the time you'll save!

The project is being developed using the latest technologies, including [SvelteKit](https://kit.svelte.dev/), [Supabase](https://supabase.com/), [Vercel](http://vercel.com/) and [OpenAI](https://openai.com/). The source code is available on [GitHub](https://github.com/epavanello/cheatgpt.app) for anyone to contribute to and improve. We welcome all developers to join us in creating the ultimate cheat engine powered by AI.

If you're interested in staying up to date on the development of **CheatGPT**, make sure to subscribe to our newsletter. You'll be the first to know when the service is officially available and ready for use.

So what are you waiting for? Join us in creating the ultimate cheat engine and let's have some fun with AI!

⭐ [Github Repo](https://github.com/epavanello/cheatgpt.app)
🐦 [Twitter account](https://twitter.com/e_pavanello)
💻 [Website](http://cheatgpt.app/)
NodeList vs Array
Tags: javascript, webdev, programming, frontend
Published: 2023-03-06 04:35:47

Cuando usamos una misma clase para múltiples elementos de HTML, podemos acceder a todos estos nodos mediante la propiedad `document.querySelectorAll('.class-name')`. Esto nos mostrará un tipo de dato llamado ***NodeList*** el cual, a su vez, pese a mostrar todos los elementos que coinciden con la clase enviado a `querySelectorAll` como un array, no es lo mismo que un array “tradicional” como el que conocemos de toda la vida…

Esta diferencia se basa en que ***NodeList*** aunque podría iterarse sobre él usando `forEach`, no es compatible con todos los métodos con los que podría usarse en un array común. Por ejemplo, con ***NodeList*** no podríamos usar métodos como `reduce`, `map`, `filter`, `some`, etc. 

Siempre que usemos `querySelectorAll` para iterar sobre varios nodos que manejan una clase en común, podemos convertir a ***NodeList*** en un array tradicional usando la propiedad Spread Operator que ofrece ES6. De hecho, siempre que se trabaje con ***NodeList*** es recomendable pasarlo a un array tradicional. Esto se debe a que los motores de JS en el navegador, principalmente V8 de Chrome, están optimizados para trabajar con arrays.

Accediendo a múltiples nodos con `querySelectorAll`:

```js
const nodeList = document.querySelectorAll('div')
```

Resultado de ejemplo:

```js
> NodeList(5) [div.container, div.input-group, div.form, div.invalid, div.feedback]
```

Convertir NodeList a un array tradicional:

```js
const nodeListAsArray = [...nodeList]
```

---

Si te gustó el post o tienes algún comentario, cuéntame en [Twitter](https://twitter.com/ramez_cesar). 😀
Difference between git rebase and git pull
Tags: git, pull, programming, beginners
Published: 2023-03-06 05:43:06

`git pull` and `git rebase` are both Git commands that are used to integrate changes from one branch into another. However, they work differently and have different effects on your Git repository's history.

`git pull` is used to update your local branch with changes from a remote branch. It combines the git fetch command (which downloads the changes from the remote repository) with the git merge command (which integrates the changes into your local branch). This means that when you use git pull, you are effectively creating a new merge commit in your local branch, which records the fact that you merged the remote changes.

`git rebase`, on the other hand, is used to integrate changes from one branch into another by moving the entire branch to a new base commit. In other words, instead of creating a new merge commit, git rebase replays the changes from one branch on top of another branch, creating a linear history without any merge commits.

### To summarize:

`git pull` combines changes from a remote branch with your local branch, creating a merge commit.
`git rebase` integrates changes from one branch into another by replaying the changes on top of another branch, creating a linear history.
So, if you want to keep a clean and linear Git history, git rebase is generally preferred over git pull. However, if you are working on a team and collaborating with others, you may need to use git pull to keep your local branch in sync with the remote branch.
An alternative to docker for php development?
Tags: webdev, opensource, docker, php
Published: 2023-03-06 08:49:00

Hi everyone!
I start a opensource project, created for PHP and Web engineers using MacOS systems for development, to provide a more simple and useful tool to manage the local server environment.
For myself, I now use this tool for php development, as a replacement for mamp pro
I'm not sure if this tool is useful for other people, but it seems that people talk more about docker
I'll post the project address, hope it helps
github: [https://github.com/xpf0000/PhpWebStudy](https://github.com/xpf0000/PhpWebStudy)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2d1q61wlmfqnn82vbfb6.png)
Minesweeper
Tags: beginners, python
Published: 2023-03-06 09:13:28

I created my first full game in python and it's minesweeper!

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

This project was assigned by Codecadamy in my Learn to Python course as final project.

I was creating it only with skills learn in course.

It takes player input and every round it print for player the current visual grid.

Github:

[https://github.com/jehrl/minesweeper]
Catch up on JavaScript 2: Easepick, magic-regexp, Token CSS, and more
Tags: webdev, javascript, beginners, react
Published: 2023-03-06 14:26:59

![Photo by Windows on Unsplash](https://cdn-images-1.medium.com/max/12000/0*pU6YNdAqkHinHnKz)

## [Easepick](https://github.com/easepick/easepick/)

Adding a date picker to an application is always a pain. Recently I found this library and its react wrapper — it’s amazing. Easy to use and customize also have an excellent design out of the box.

![https://github.com/easepick/easepick](https://cdn-images-1.medium.com/max/2660/0*WdzMMLNJasxdPm9F)

## [React-Transition-State](https://github.com/szhsin/react-transition-state)

react-transition-group is a known library to add enter/exit transitions to components. Today’s library wants to give you similar functionality. It’s tiny and gives you to granularly control the state of transition.

![https://github.com/szhsin/react-transition-state](https://cdn-images-1.medium.com/max/2400/0*1ul22ANv6Tdx_t7n)

## [🦄 magic-regexp](https://github.com/danielroe/magic-regexp)

Create regexp in a more functional style. magic-regexp supports grouping and has excellent typing that lets you preview the final expression.

![https://github.com/danielroe/magic-regexp](https://cdn-images-1.medium.com/max/2400/0*px7pB9mjkromYxwU)

## [Token CSS](https://github.com/tokencss/tokencss)

Generate tokens based on the config you define and then use them in your CSS. These tokens then will be replaced by PostCSS and replaced with defined values. Stay in sync with the defined project design.

![https://github.com/tokencss/tokencss](https://cdn-images-1.medium.com/max/2400/0*u9Sn-uBmcyLQvg0W)

## [Bling](https://github.com/TanStack/bling/)

Create RPC functions from inside your client-side code.

![https://github.com/TanStack/bling/](https://cdn-images-1.medium.com/max/2400/0*6-ynYirMMO6RVCFL)

Want to read more about RPC? I made a short [post about RPC and what the fuss is about it](https://dev.to/marcin_codes/what-the-fuss-is-about-rpc-1j5m-temp-slug-1924101). Covered [Solid Start](https://start.solidjs.com/getting-started/what-is-solidstart)’s RPC, [Qwik](https://qwik.builder.io/)’s version, and what they are doing.

Please react to this post or leave a comment and let me know what you think. Check [my Twitter](https://twitter.com/marcin_codes) where I post these libraries daily.

## Stay up to date with my writing

You can stay up to date by following me in one of these ways:

- Follow me on [Medium](https://medium.com/@marcin-codes)

- Follow me on [Twitter](https://twitter.com/marcin_codes)

- Follow me on [Dev.to](https://dev.to/marcin_codes)

- Follow me on [Mastodon](https://mas.to/@marcin_codes)

- Add [my blog](https://marcin.page/) to the [RSS feed](https://marcin.page/feed.xml) reader
python: use multiple patch decorators to mock functions
Tags: python, testing, mock
Published: 2023-03-07 05:43:06

I wrote how to mock in the [previous article](https://dev.to/kenakamu/python-unit-test-with-mock-functions-from-different-modules-cla). This time, I mock multiple functions in the test to see how I can handle them.

## Structures and code

This is almost same as before, just adding one more function in util.py.

```shell
src/
    ├── my.py  
    ├── my_modules/
    │   ├── __init__.py
    │   └── util.py
    └── tests/
        ├── __init__.py
        ├── test_my.py
        └── test_unit.py
```
my.py
```python
from my_modules.util import util, get_data

def main():
    data = get_data()
    return util(data)

if __name__ == '__main__':
    main()
```
util.py
```python
from datetime import datetime

def util(input: str) -> str:
    input = add_time(input)
    return f"util: {input}"

def add_time(input: str) -> str:
    return f"{datetime.now()}: {input}"

def get_data() -> str:
    return "Return some data"
```

## Add a unit test for main function

To test the ``main`` method in the ``my.py``, I need to mock both ``util`` and ``get_data`` method. Let's do it.

Firstly, I added another ``patch`` and specify ``return_value``. It doesn't change the test body though.

```python
@patch("my.util", Mock(return_value="dummy"))
@patch("my.get_data", Mock(return_value="some data"))
def test_main():
    result = main()
    assert result =='dummy'
```

Let's receive the mock objects as the arguments.

```python
@patch("my.util")
@patch("my.get_data")
def test_main_util_called_with_expected_parameter(get_data_mock, util_mock):
    get_data_mock.return_value = 'some data'
    util_mock.return_value = 'dummy'
    result = main()
    assert result =='dummy'
    util_mock.assert_any_call('some data')
```
The interesting part is the order of argument. As you see, I can get the mock from bottom up order of the ``patch`` decorators. I firstly though I can receive the mocks in the same order as the decorators, but I was wrong.

Finally, let's try ``with`` statement.

```python
def test_main_util_called_with_expected_parameter_with():
    with patch("my.util") as util_mock:
        util_mock.return_value = 'dummy'
        with patch("my.get_data") as get_data_mock:
            get_data_mock.return_value = 'some data'
            result = main()
    assert result =='dummy'
    util_mock.assert_any_call('some data')
```

I am not 100% sure if this is the correct way to implement, but it works as expected anyway.

I just added one more example. This time, I specify the Mock object in the first decorator only. In this case, I can receive just one mock object as an argument.

```python
@patch("my.util", Mock(return_value="dummy"))
@patch("my.get_data")
def test_main_get_data_called(get_data_mock):
    get_data_mock.return_value = 'some data'
    result = main()
    assert result =='dummy'
    assert get_data_mock.called
```

I check if ``get_data`` function is called.

## Summary

I understand when I get the mock object as the arguments. It's a bit confusing but once I understand, it's very useful.
openGauss Adding or Deleting a Standby Node
Published: 2023-03-07 09:04:30

## Availability
This feature is available since openGauss 2.0.0.

## Introduction
Standby nodes can be added and deleted.

## Benefits
If the read pressure of the primary node is high or you want to improve the disaster recovery capability of the database, you need to add a standby node. If some standby nodes in a cluster are faulty and cannot be recovered within a short period of time, you can delete the faulty nodes to ensure that the cluster is running properly.

## Description
openGauss can be scaled out from a single node or one primary and multiple standbys to one primary and eight standbys. Cascaded standby nodes can be added. Standby nodes can be added when a faulty standby node exists in the cluster. One primary and multiple standbys can be scaled in to a single node. A faulty standby node can be deleted.

Standby nodes can be added or deleted online without affecting the primary node.

## Enhancements
None.

## Constraints
For adding a standby node:

Ensure that the openGauss image package exists on the primary node.

Ensure that the same users and user groups as those on the primary node have been created on the new standby node.

Ensure that the mutual trust of user root and the database management user has been established between the existing database nodes and the new nodes.

Ensure that the XML file has been properly configured and information about the standby node to be scaled has been added to the installed database configuration file.

Ensure that only user root is authorized to run the scale-out command.

Do not run the gs_dropnode command on the primary node to delete other standby nodes at the same time.

Ensure that the environment variables of the primary node have been imported before the scale-out command is run.

Ensure that the operating system of the new standby node is the same as that of the primary node.

Do not perform an primary/standby switchover or failover on other standby nodes at the same time.

For deleting a standby node:

Delete the standby node only on the primary node.
Do not perform an primary/standby switchover or failover on other standby nodes at the same time.
Do not run the gs_expansion command on the primary node for scale-out at the same time.
Do not run the gs_dropnode command twice at the same time.
Before deletion, ensure that the database management user trust relationship has been established between the primary and standby nodes.
Run this command as a database administrator.
Before running commands, run the source command to import environment variables of the primary node.
Dependencies
None.
File Privacy
Tags: security, privacy, encryption
Published: 2023-03-07 13:10:18

3DES is one of the most prominent forms of encryption and has a symmetric-key block cipher algorithm. File Privacy uses Triple DES (3DES or TDES).
You encrypt your files using the key file. The key file is created within the program. First you select the file you want to encrypt and then the folder where the output file will be saved.
File Privacy has following features:
- File decryption/encryption (3DES)
- Create random key hex string and save as file
- Hex string based decryption/encryption

Usage is very easy and a manual also included in application.

{% embed https://www.youtube.com/watch?v=yJlumXN_Cx4 %}

[Get](https://www.microsoft.com/store/apps/9nr3f6t9g53z)
Conor McGregor's Net Worth: How He Built His Fortune
Published: 2023-03-07 13:36:07

[Articlesworlds.com](https://www.articlesworlds.com/) is a platform where everyone can read or search for any kind of article and also can share their ideas with us in the comment section. Today our topic is [Conor McGregor's Net Worth](https://www.articlesworlds.com/2023/03/conor-mcgregors-net-worth-how-he-built.html). 

**Read About ⇒ [Real Estate Investment Trust UK (REIT): Everything You Need to Know to Start Investing Today](https://www.articlesworlds.com/2023/03/real-estate-investment-trust-uk-reit.html)**

[Conor McGregor](https://www.articlesworlds.com/2023/03/conor-mcgregors-net-worth-how-he-built.html) is a call synonymous with the game of blended martial arts (MMA). He has become one of the most popular and successful athletes of the modern era, amassing a fortune that most people can only dream of. But how did he build his fortune? In this article, we will take a closer look at Conor McGregor's net worth and the key factors that have contributed to his financial success.

## Introduction of Conor McGregor's
[Conor McGregor](https://www.articlesworlds.com/2023/03/conor-mcgregors-net-worth-how-he-built.html) was born in Dublin, Ireland, in 1988. He started his combat sports journey at a young age, training in boxing and then transitioning to MMA in his early twenties. 
McGregor made his professional debut in 2008 and quickly rose to prominence with his unique fighting style and trash-talking ability. He signed with the Ultimate Fighting Championship (UFC) in 2013 and became the first fighter in the promotion's history to hold titles in two weight classes simultaneously.

## Early Life and Career

McGregor grew up in Dublin, where he developed a passion for combat sports. He started boxing at the age of 12 and quickly became proficient in the sport. McGregor eventually transitioned to MMA, where he found even more success. He made his professional debut in 2008 and quickly built a reputation as a talented fighter with a charismatic personality.

## UFC Career
McGregor signed with the UFC in 2013 and quickly made an impact. He won his first fight in the promotion with a first-round knockout, and then went on to win his next four fights. McGregor's trash-talking ability and unique fighting style quickly made him a fan favorite, and he became one of the UFC's biggest draws. [Read More](https://www.articlesworlds.com/2023/03/conor-mcgregors-net-worth-how-he-built.html).
Today's Fun Joke For Developers - Daily Developer Jokes
Tags: jokes, dailydeveloperjokes
Published: 2023-03-08 08:00:03

---
title: "Today's Fun Joke For Developers - Daily Developer Jokes"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1259620ca4d.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ Where does the pirate stash all of their digital treasures?

___A:___ RAR
 -->
Tiny Container Images With Distroless Containers
Tags: docker, rust, go, node
Published: 2023-03-08 08:18:10

---
title: Tiny Container Images With Distroless Containers
published: true
date: 2021-10-16 00:00:00 UTC
tags: Docker,Rust,Go,nodejs
canonical_url: https://blog.jonstodle.com/tiny-container-images-with-distroless-containers/
---

When deploying applications using containers, it's usually a goal to minimize the size of the container image.

Achieving a small container size varies a lot between different languages and technologies. There is no _single_ solution that will work for everyone, as usual, but there’s a pretty interesting alternative if you’re deploying Rust, D, Go, Java or node.js applications.

Google maintains a repo of what they call _distroless containers_. These are container base images that contain as little as possible. They’ve stripped away pretty much everything until you’re basically left with _libc_ and not much more. There isn’t even a shell included!

Another nice benefit of the distroless images, apart from the size consideration, is the security. With so few tools and executables inside the container it increases the difficulty of being able to do much if you manage to get access to it. Less code, means less bugs and vulnerabilities.

To start using one is pretty simple. Build your application and copy the final binary into the image based on one of the distroless images:

```

FROM golang:1.13-buster as build

WORKDIR /src

COPY . /src

RUN go get -d -v ./...

RUN go build -o /go/bin/app

FROM gcr.io/distroless/base-debian10

COPY --from=build /go/bin/app /

CMD ["/app"]

```

It’s important to note that you have to use the for `[“/app”]` when defining a `CMD` or `ENTRYPOINT` command in the docker file. If you use the “bare” form, e.g. `CMD “/app”` , Docker will prepend the command with a shell which will not work, as there’s not shell inside the distroless container.

And that’s it!

Check out their [repo on Github](https://github.com/GoogleContainerTools/distroless) for more information.

* * *

Happy coding!