teleren/devto huggingface dataset:
The Joy of Sharing: Why Developers Should Geek Out More
Tags: webdev, discuss, devjournal
Published: 2023-04-11 20:48:59

## Hi, I'm Lou,
I've been coding for a while now, creating an assortment of projects from animations to landing pages, games, and responsive design. As a developer, one of the things that excites me the most is the satisfaction of creating something new and exciting.

However, one of the more mentally challenging things that I face is the lack of enthusiasm from others when I share my projects or just want to geek out about something coding related. 
While I can talk about these things with my colleagues, friends, and family, most of the time, I’m returned with blank stares as they either don't quite understand or simply, don’t care. 

It’s not seeking validation from others but more wanting to share the passion and excitement I feel. I think that it's great to celebrate our accomplishments ourselves but also when you see something so slick that you or someone else has made or you’ve seen online and it makes you go 🤩👀 then you look around and there’s no one you can show it to! 😓
Do you remember as a child, the thrill of bringing home a handmade project and showing it off to your parents. The same feeling of joy still exists in me today when I build something new and exciting. 

By celebrating our accomplishments and sharing our passion with others, we can inspire and motivate each other to keep pushing ourselves to new heights, and let's not forget to celebrate our hard work and success along the way.

In conclusion, being a developer is challenging, but by focusing on the joy of creating and sharing our passion with others, we can overcome the challenges and continue to grow and learn in our field 🙏🏻

**What have you built or learnt recently that you’ve been excited to talk about?**
Diario de Python | #11. Color Choice: Flujo de la API
Tags: django, devjournal, spanish, python
Published: 2023-04-11 20:45:19

Ahora que tenemos las rutas y ViewSets armados, vamos a entender el flujo de la API.

## El flujo
Un usuario cualquiera debería poder entrar a un sitio, una app mobile o incluso una aplicación desktop, y elegir un color de una lista.

> Para facilitar el asunto, vamos a asumir que siempre sea el usuario admin, el primero que tenemos en nuestra BD.

Esta elección de colores implica un GET a **/api/colors**.

Luego ese usuario debe seleccionar un color y emitir su voto. Aquí ocurren dos cosas: En principio, debemos hacer un GET a **/api/votes/1** para validar que este voto ya exista. En caso negativo, vamos a permitirle votar; y en caso positivo, solo vamos a permitir que pueda ver los resultados de las votaciones, que por cierto es un GET a **api/votes**.

Si le permitimos votar, al apretar el botón será un POST a **api/votes** con un JSON que contendrá el contenido de un voto:

```json
{
  "user": 1,
  "color": 1
}
```

Por supuesto, user y color tienen una clave foreanea a User y Color, por lo cual tenemos que pasarles el identificador, osea el ID de cada entidad.

Si no conoces DRF, es probable que pienses que estos métodos hay que armarlos. Nada más alejado de la realidad: como definimos los ViewSet y los asociamos al route, tenemos los siguientes endpoints pre-creados:

- GET api/votes: obtiene todos los votos.
- GET api/votes/<id>: obtiene un voto según el id.
- POST api/votes/: crea un voto.
- PUT/PATCH api/votes/: modifica un voto entero o parcialmente.
- DELETE api/votes/<id>: elimina un voto según el id.

Los mismos métodos tenemos para los colores, pero con "api/colors".

En una API más sencilla, mi trabajo habría terminado: ya tengo votos que se pueden emitir en base a colores, fin del asunto.

El problema radica en que tenemos algunos fallos en el flujo actual:
- No podemos buscar quien emitió el voto, porque "GET api/votes/<id>" busca por el **id del voto**, no por el id del user.
- Se puede votar en nombre de cualquier usuario, porque "POST api/votes/" nos permite enviar el user que queramos.
- Se puede editar o borrar cualquier voto, por las mismas razones de arriba.
- Podemos borrar todos los colores y romper los votos. Como tenemos un CASCADE, si elimino el Azul por ejemplo, y habían 50 entradas de votos, se van a **eliminar**. Un problema serio.

## Las soluciones
Por suerte, los ViewSets nos permiten modificar los comportamientos que vienen por defecto, pensemos que estamos trabajando con herencia y polimorfismo a la hora de heredar de ModelViewSet.

Hay que pararse en el medio y condicionar estos endpoints, pero previamente hay que armar un sistema de autenticación por tokens para crear una sesión y notificarle a la API con quién esta hablando.

Y eso lo veremos, querid@s amig@s, en el próximo artículo.
CDK ASL Definition Extractor
Tags: cdk, aws, typescript, node
Published: 2023-04-11 19:58:50

I've been working a good bit lately to push testing down when using Step Functions and building some patterns with [AWS State Machines Locally](https://docs.aws.amazon.com/step-functions/latest/dg/sfn-local.html). In that same spirit, I'm wanting to be able to create the State Machine in my local container and that comes from the ASL. However, when using CDK and the builder libraries you don't have an ASL file to work from. So I built this program to extract the ASL Definition from a CDK synth'd CloudFormation file.

I've written a good bit about CDK so if you are looking for some [intro](https://www.binaryheap.com/intro-to-cdk/) this article is a good place to start. But if you've moved passed that and are looking to further build upon some more advanced patterns, I'll have a follow-up article on how to use the Local Step Functions container in conjunction with this program.

### CDK ASL Definition Extractor Usage

If you just want to jump straight to the README or the NPM package you can do that here:

-   [GitHub Repository](https://github.com/benbpyle/cdk-state-machine-extractor)
-   [NPM](https://www.npmjs.com/package/cdk-asl-definition-extractor)

This is a simple command line utility that takes the CDK Template output and parses through to extract out the `AWS::StepFunctions::StateMachine` resources and then outputs them to the STDOUT so that you can do something with that definition.

#### For usage

**Preview Options**

```bash
❯ cdk-asl-definition-extractor -h
Usage: cdk-asl-definition-extractor [options]

Extract AWS State Machine definitions from CDK generated ASL

Options:
  -V, --version            output the version number
  -f, --file-name <value>  CloudFormation JSON File
  -h, --help               display help for command
```

**Extract ASL**

```bash
cdk-asl-definition-extractor  -f </path/to/the/template.json>
```

**The Output**
```javascript
    [
        {
            "identifier": "<StackResourceName>",
            "definition": "<ASL Definition>"
        }
    ]
```

### Wrap Up

Plenty more to come on this and I'll be working to extend/expand its capabilities.
+160 Prompts for Artists and Content Creator
Published: 2023-04-11 19:43:13

I just released more than 160+ prompts for image generative AI on Gumroad 🔥🔥🔥

https://codingwithadi.gumroad.com/l/owtep


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/17c6at3wxlytjzp546ew.png)
Sybil Attack in Blockchain: Understanding the Dangers and Preventing Them with Blockchain Technology
Tags: blockchain, web3, ethereum, webdev
Published: 2023-04-11 19:38:50

🔐💻🌐👥💥🚫💸

## Sybil Attack: Understanding the Dangers of False Identities in Blockchain

🤔 **What is a Sybil Attack?**

A Sybil attack is a type of attack in which a single person or entity creates multiple false identities, called Sybils, in order to gain control or manipulate a network. In the world of blockchain, this is a serious threat to the security of the network.

💥 **The Dangers of a Sybil Attack**

The goal of a Sybil attack is to control the network or gain access to sensitive information. By creating multiple identities, an attacker can influence the network by controlling a large portion of the network's nodes. This can lead to several dangerous scenarios, including:

Double-spending: An attacker can spend the same cryptocurrency twice by controlling a large number of nodes.

Network manipulation: An attacker can manipulate the network by creating fake transactions or blocking legitimate transactions.

Information theft: An attacker can gain access to sensitive information by controlling nodes that have access to that information.

🚫 **Preventing Sybil Attacks**

Preventing Sybil attacks is crucial to maintaining the security of the blockchain network. Here are some ways to prevent Sybil attacks:

Proof-of-Work (PoW): PoW requires a lot of computing power to create new blocks on the network, making it difficult for an attacker to control a large number of nodes.

Proof-of-Stake (PoS): PoS requires users to stake a certain amount of cryptocurrency to become a node on the network. This makes it difficult for an attacker to control a large number of nodes.

Reputation systems: Reputation systems can be used to identify and blacklist Sybil nodes, making it more difficult for an attacker to gain control of the network.

💻 **How Blockchain Technology Can Help**

Blockchain technology can help prevent Sybil attacks by providing a decentralized and transparent system that is difficult to manipulate. By using a distributed ledger, blockchain ensures that all transactions are verified and recorded, making it difficult for an attacker to manipulate the network.

👥 **Conclusion**

Sybil attacks are a serious threat to the security of blockchain networks. By creating multiple false identities, attackers can manipulate the network and gain access to sensitive information. Preventing Sybil attacks is crucial to maintaining the security of the network, and blockchain technology provides several solutions to help prevent them. By using a combination of PoW, PoS, and reputation systems, blockchain networks can ensure that only legitimate nodes are able to participate in the network, making it difficult for an attacker to gain control.
Web Development Challenges and Cost-Effective Solutions
Tags: sso, auth, webdev, devops
Published: 2023-04-11 19:05:25

Starting a new web development project is an exciting venture, but it can also present many challenges. 

- One of the most crucial aspects of web development is **managing the database**. Ensuring that your database structure supports your application's needs requires careful planning and execution.

-  Additionally, **server infrastructure management** is crucial to ensure that your server is available, performing well, and secure.

- Lastly, designing a **secure login and access control system** that only allows authorized users to access sensitive data is a must.

**However, there are several cost-effective solutions available that can help you overcome these challenges.** 

Open-source database management systems such as **MySQL and PostgreSQL** can provide an affordable and reliable solution for managing your database. 

Meanwhile, cloud-based solutions like **Amazon Web Services and Microsoft Azure** offer scalable and cost-effective hosting solutions for your web applications.

When it comes to login and access control systems, **Logify** is an excellent solution. It offers advanced features for free, allowing you to focus on the core functionality of your project. With Logify, you won't have to worry about access management, nor will you need to worry about the financial implications of using a login service. As your project grows, Logify's advanced access management features will keep up with your evolving needs.

In summary, web development is an exciting field, but it comes with its fair share of challenges. Managing your database, server infrastructure, and login and access control system are essential components that require careful planning and execution. However, by utilizing cost-effective solutions like Logify and open-source database management systems, you can overcome these challenges and complete your web development project successfully and within budget.
Project-Level Security: Leveraging Local Git Config and Dedicated SSH Keys for Multiple Repositories
Published: 2023-04-11 18:58:47


Developing multiple projects often requires the use of different Git repositories. As a developer, you might have access to various repositories, each with different access levels and security requirements. In such cases, it's essential to maintain a secure and organized development environment. One way to achieve this is by using a separate SSH private key for each repository and configuring local Git config files accordingly.

When each repository has its dedicated SSH key, it becomes easier to manage access rights. Revoking or granting access to a specific repository can be achieved by simply managing the corresponding SSH key.


Configuring Local Git Config for Each Repository:

To set up a dedicated SSH key for each repository, you need to create and configure the local Git config file for each project. The local Git config file, located at `.git/config` within the repository, contains repository-specific settings. Here's how to configure the local Git config file to use a separate SSH private key for each repository:

Generate a new SSH key pair for each repository you want to secure:

```
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f /path/to/your/private_key
```

Add the generated public key to the corresponding repository's SSH settings.

Configure the local Git config file for each project by adding the following lines to the .git/config file:


```
[core]
  sshCommand = "ssh -i /path/to/your/private_key"
```

You can also set the core.sshCommand configuration for a specific repository via the terminal using the following command:

```
git config core.sshCommand "ssh -i /path/to/your/private_key"
```

The sshCommand directive specifies the path to the private key associated with the repository. Replace `/path/to/your/private_key` with the actual path to the private key you generated in step 1.

Save the changes to the local Git config file.
Now, when you interact with the repository (e.g., git pull, git push), Git will use the specified private key for authentication, ensuring that each repository has its dedicated SSH key.

Conclusion:

By using dedicated SSH keys for each Git repository and configuring the local Git config file accordingly, you can improve your development environment's security and organization. This approach simplifies access management and makes it easier to troubleshoot authentication issues. As a result, you can focus on your development tasks with confidence, knowing that your repositories are secure and well-organized.
Azure Nested Virtualization - Internet Connection
Tags: azure, networking
Published: 2023-04-11 18:57:06

Building a lab environment to simulate certain scenarios or get hands-on experience with technology can be really useful.  

Years ago we used to invest in physical lab environments for home use, but these days you can use Azure as that lab environment.  And with nested virtualization capabilities building a Hyper-V lab is feasible.

Below I walk you through the process of setting up the networking within your Azure virtual machine for that nested virtualisation scenario.

## Requirements:

- Windows Server 2022 build 20348 or later
- Enabled Hyper-V Role
- PowerShell

## Setup Hyper-V NAT Switch

The first step is to create a new Hyper-V virtual switch. The virtual switch allows virtual machines created on Hyper-V hosts to communicate with other computers.  The following PowerShell command will create the virtual switch.

<!--kg-card-begin: markdown-->
```
New-VMSwitch –SwitchName “NATSwitch” –SwitchType Internal

```
<!--kg-card-end: markdown-->

Now we have the virtual switch set up we need to configure the virtual network adapter.  The virtual network adapter enables communications between virtual machines through the virtual switch.  The following PowerShell command will set up the virtual network adapter.

<!--kg-card-begin: markdown-->
```
New-NetIPAddress –IPAddress 192.168.0.1 -PrefixLength 24 -InterfaceAlias "vEthernet (NATSwitch)"

```
<!--kg-card-end: markdown-->

The next step is to create the Network Address Translation (NAT) on our switch. The NAT translates an internal network address to an external network address.  Allowing the networking inside our Hyper-V setup to communicate with the external world.  We use the following PowerShell command to create the NAT:

<!--kg-card-begin: markdown-->
```
New-NetNat –Name NATNetwork –InternalIPInterfaceAddressPrefix 192.168.0.0/24

```
<!--kg-card-end: markdown-->
## Configure virtual machines

Now that you have the networking set up with your host machine you can configure the networking inside your virtual machines.

You can set your virtual machines with an address in the range 192.168.0.1-192.168.0.254.

Here is an example of what one of my virtual machines IP configuration looks like:

![Azure Nested Virtualization - Internet Connection](https://lh6.googleusercontent.com/YmhhsCYdDDGHoW_tIOZ2OY6T-I4LcTRSW91IN5qgtMYkJxqQYDX0c6zPZ2VYAezup_tszYZIb9Li2nuN28Y4bwesx3NAkfRv3NSBnGMSpuZeYlVl3IOmhGfASc015G01IMl_ZNCrIiLNAp4FUhS1TA)
_IP configuration example_

For the DNS servers, depending on what my virtual machines are doing I either use the Google DNS servers or I use the Active Directory DNS server I have set up for the lab.

If you are looking for a “ready made” lab you can deploy within Azure, please do check out my ["Deploy a lab inside an Azure VM"](https://www.techielass.com/lab-deployment-in-azure/) blog post.
Create an advanced AWS VPC to host a fully functioning cloud native application
Tags: aws, cloud, awscommunity, 100daysofcloud
Published: 2023-04-11 18:28:35

[100/100] #100DaysOfCloud Today, I created an advanced AWS VPC to host a fully functioning cloud native application that lets you vote your favorite programming language from a list.

The VPC will span 2 AZs, and have both public and private subnets. An internet gateway and NAT gateway will be deployed into it. Public and private route tables will be established. An application load balancer (ALB) will be installed which will load balance traffic across an auto scaling group (ASG) of Nginx web servers installed with the cloud native application frontend and API. A database instance running MongoDB will be installed in the private zone. Security groups will be created and deployed to secure all network traffic between the various components.
For demonstration purposes only - both the frontend and the API will be deployed to the same set of ASG instances - to reduce running costs.
The ALB will configured with a single listener (port 80). 2 target groups will be established. The frontend target group points to the Nginx web server (port 80). The API target group points to the custom API service (port 8080). The Web Application is a Programming Language Vote App where you can vote or your favorite language from a list.

You can try do it by yourself by following the steps from the link below: [GitHub](https://github.com/aaditunni/100DaysOfCloud/blob/main/Journey/100/Readme.md)
AWS security dashboard with Securityhub & Prowler integration
Published: 2023-04-11 18:11:19


AWS Security Hub is a cloud security posture management service which delivers security best practice checks, aggregates alerts, and enables automated remediation with AWS config


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

When you enable Security Hub for the first time, your AWS account is automatically enrolled in a 30-day Security Hub free trial.

Security Hub are available for free trial, you are only charged for usage of other services that Security Hub interacts with, such as AWS Config items, Guard duty etc.. You are not charged for AWS Config rules that are enabled by Security Hub security standards.

There are lot findings available in Security hub dashboard based on integration of different AWS services as well third party modules.


![Securityhub1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/er8motyoyu4kj1s1za1w.png)



Prowler is an Open Source security tool to perform AWS checks related to security best practices, hardening and continuous monitoring. Includes all CIS controls plus more than 100 additional checks.


![integration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b9adolmpzlatqfhyso14.png)

We can then create a quick sight dashboard to visualize the findings with different parameters such as severity category
![quicksight1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i22vk5wv2exixvxtz0k8.png)

We can also create dashboard based on check-id of different category
![quicksight2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r9lr36zvcacfj50b81hd.png)

We can also create dashboard based on different resources affected by severity

![quicksight-full](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u34xb3ikjhgsp7uxykzf.png)

Will comeback with more with Prowler & Security hub
Write bash script to append the file with 100 more similar records.
Tags: bash, devops, programming
Published: 2023-04-11 18:06:54

Given the file records.txt:

```
One | 1 | 2021-01-01 01:01:01 
Two | 2 | 2022-02-02 02:02:02
Three | 3 | 2023-03-03 03:03:03
Four | 4 | 2024-04-04 04:04:04
Five | 5 | 2025-05-05 05:05:05
```

Here's an example bash script to append 100 more records in the same format as the given file:

```
#!/bin/bash

for (( i=6; i<=105; i++ ))
do
    # Generate random number between 1-5
    num=$(( RANDOM % 5 + 1 ))
    
    # Generate random date between 2026-01-01 to 2030-12-31
    d=$(shuf -i 17897-19100 -n 1)
    date=$(date -d "1900-01-01 + $d days" "+%Y-%m-%d")
    
    # Generate random time between 00:00:00 to 23:59:59
    time=$(date -d@$(( RANDOM % 86400 )) -u "+%T")

    # Append record to file
    echo "Record$i | $num | $date $time" >> records.txt
done
```

This script generates 100 new records in the same format as the given file, with the record number starting from 6 and increasing up to 105. The script uses the shuf command to generate a random number of days between 17897 and 19100 (which correspond to the dates between 2026-01-01 and 2030-12-31) and then formats it as a date using the date command. It also generates a random time between 00:00:00 to 23:59:59 using the date command. Finally, the script appends the new record to the end of the file records.txt.

```
dmi@dmi-laptop:~$ cat records.txt 
One | 1 | 2021-01-01 01:01:01 
Two | 2 | 2022-02-02 02:02:02
Three | 3 | 2023-03-03 03:03:03
Four | 4 | 2024-04-04 04:04:04
Five | 5 | 2025-05-05 05:05:05
Record6 | 3 | 1949-06-24 02:19:06
Record7 | 4 | 1951-09-06 08:01:10
Record8 | 3 | 1950-09-17 07:20:10
...
Record103 | 4 | 1950-06-04 03:28:20
Record104 | 4 | 1950-12-23 07:16:30
Record105 | 1 | 1949-04-18 05:15:32
dmi@dmi-laptop:~$
```