teleren/devto huggingface dataset:
Como realizar scan do SonarQube utilizando maven
Tags: java, programming, testing
Published: 2023-04-11 01:18:59

Para reunir a varredura remota e local do servidor no SonarQube, você precisa seguir os seguintes passos:

Passo 1: Configure o servidor SonarQube local.

Se você ainda não tiver configurado o servidor SonarQube local, siga as etapas descritas na documentação oficial do SonarQube.

Passo 2: Adicione as configurações do plugin SonarQube Maven no arquivo pom.xml do seu projeto.

```
<build>
    <plugins>
        <plugin>
            <groupId>org.sonarsource.scanner.maven</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>3.9.0.2155</version>
        </plugin>
    </plugins>
</build>
```
Passo 3: Configure as propriedades do SonarQube no arquivo pom.xml.

```
<properties>
    <!-- Informações do servidor SonarQube local -->
    <sonar.host.url>http://localhost:9000</sonar.host.url>
    <sonar.login>SEU_TOKEN_AQUI</sonar.login>
    <!-- Informações do servidor SonarQube remoto -->
    <sonar.remote.enabled>true</sonar.remote.enabled>
    <sonar.remote.url>http://seu-servidor-sonarqube-remoto:9000</sonar.remote.url>
    <sonar.remote.branch>nome-do-branch-remoto</sonar.remote.branch>
    <sonar.remote.login>SEU_TOKEN_AQUI</sonar.remote.login>
</properties>
```

Substitua http://seu-servidor-sonarqube-remoto:9000 pela URL do servidor SonarQube remoto que você deseja usar. Defina nome-do-branch-remoto com o nome do branch remoto que você deseja analisar e substitua SEU_TOKEN_AQUI pelo token de acesso.

Passo 4: Execute o comando Maven para analisar seu projeto com o SonarQube.

```
mvn sonar:sonar
```

Isso fará com que o Maven analise o código-fonte do seu projeto local e remoto e envie os resultados para o servidor SonarQube local.

Passo 5: Visualize o relatório de análise do SonarQube.

Acesse a interface do usuário do SonarQube em seu navegador da web e navegue até o projeto que deseja visualizar. Você pode ver informações sobre a análise do código-fonte local e remoto no mesmo relatório.

Com essas informações, você pode tomar decisões informadas sobre como melhorar a qualidade do seu código.
O que é Rate Limiting e qual sua importância para seu projeto?
Published: 2023-04-11 01:16:05

Rate Limiting é uma técnica de controle de acesso que impõe limites na quantidade de solicitações que uma aplicação pode receber de um determinado usuário ou endereço IP em um determinado período. O objetivo é evitar sobrecarga do servidor, mitigar ataques de negação de serviço (DoS) e prevenir abusos ou explorações maliciosas da aplicação.

Para entender a importância do Rate Limiting, imagine uma aplicação que permite o upload de arquivos. Se não houver um limite de solicitações, um usuário malicioso poderia enviar muitos arquivos em sequência, ocupando todo o espaço de armazenamento disponível e deixando a aplicação inutilizável para outros usuários legítimos. Além disso, um ataque DoS pode ser realizado enviando muitas solicitações simultâneas, sobrecarregando o servidor e tornando a aplicação inacessível para todos os usuários.

Ao impor limites na quantidade de solicitações que um usuário pode fazer em um determinado tempo, o Rate Limiting pode ajudar a prevenir esses tipos de ataques. Além disso, o Rate Limiting pode ajudar a prevenir abusos, como a criação de várias contas falsas para obter mais recursos ou privilégios.

Existem vários métodos de implementação do Rate Limiting, como limitar o número de solicitações por segundo, por minuto, por hora ou por dia. Também é possível aplicar diferentes limites para diferentes tipos de solicitações, dependendo da sua complexidade ou custo computacional.

No entanto, é importante lembrar que o Rate Limiting pode afetar negativamente a experiência do usuário se os limites forem muito restritivos. Portanto, é importante encontrar um equilíbrio entre segurança e usabilidade ao implementar o Rate Limiting em uma aplicação.

Resumindo, o Rate Limiting é uma técnica importante para proteger uma aplicação contra sobrecarga, ataques e abusos maliciosos. É importante encontrar um equilíbrio entre segurança e usabilidade ao implementar o Rate Limiting para garantir que os usuários legítimos possam acessar a aplicação sem serem afetados negativamente.
Kubernetes Fundamentals
Tags: kubernetes, cka, containers, containerapps
Published: 2023-04-11 00:53:00

Kubernetes is a powerful platform used for automating the deployment, scaling, and management of containerized applications. I'm seeing huge interest in Kubernetes from application development standpoint and Kubernetes is a preferred compute platform for variety of workloads.  

Exploring the fundamentals of Kubernetes was an exciting learning experience for me, and I have put together a user-friendly resource to share my knowledge. For those who prefer learning through videos rather than articles, you've come to the right place. I've created a YouTube playlist containing helpful tutorials, and I continue to add more as I go along. Additionally, I've included a GitHub repository for the manifest files (YAML) that I used in my labs. 

https://github.com/awslearn-repo/Kubernetes/blob/b6ef22703e12866d4182416fa40303274ce1acce/README.md

Youtube playlist refers this repo. You can make use of this repository during your learnings.

Playlist : {% embed https://youtube.com/playlist?list=PLu49v2xsj3a87zShL5nRMlyBPmVmf_l-Z %}

Video 1: Create AWS Elastic Kubernetes Service (EKS) cluster

Video 2: Add worker nodes to EKS cluster

Video 3: CREATE POD Imperative & Declarative

Video 4: What is ReplicaSet ? Create ReplicaSet !!

Video 5: Create Deployment (Declarative & Imperative)

Video 6: Kubernetes POD, ReplicaSet and Deployment -- Relationship Explained with the Demo

Video 7: How Taints & Tolerations work together?

Video 8: Kubernetes Node Selector and Node Affinity - Decides POD placement

Video 9: Kubernetes Resource Management; REQUESTS & LIMITS

I hope you enjoy the learning process!

More tutorials to come ...
Code Smell 206 - Long Ternaries
Tags: webdev, javascript, beginners, programming
Published: 2023-04-11 00:21:05

*You love ternaries too much*

> TL;DR: Don't use ternaries for code execution. You should read them as a math formula.

# Problems

- Difficult to read

- Low Reuse

- Low Testability

# Solutions

1. [Extract the method guards](https://dev.to/mcsee/refactoring-010-extract-method-object-3ff8)

# Refactorings

{% post https://dev.to/mcsee/refactoring-010-extract-method-object-3ff8 %}

# Context

When a ternary condition is used in code that contains multiple functions, it can be challenging to determine which function is being affected by the condition. 

This can make it harder to identify and fix bugs, as well as to understand how the code works in general.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/274faf5d13f9853f63228fa10ee45d7e)
```javascript
const invoice = isCreditCard ? 
  prepareInvoice();
  fillItems();
  validateCreditCard();
  addCreditCardTax();
  fillCustomerDataWithCreditCard();
  createCreditCardInvoice() 
:
  prepareInvoice();
  fillItems();
  addCashDiscount();
  createCashInvoice();

// The intermediate results are not considered
// The value of the invoice is the result of
// the last execution
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/36ef3f34e5767f120dcabe8eebda1072)
```javascript
const invoice = isCreditCard ? 
                    createCreditCardInvoice() :
                    createCashInvoice();

// or better... 

if (isCreditCard) {
  const invoice = createCreditCardInvoice();
} else {
  const invoice = createCashInvoice();
}

// Even better with polymorphism...

const invoice = paymentMethod.createInvoice();
```

# Detection

[X] Automatic 

Linters can detect large code blocks

# Tags

- Bloaters

# Conclusion

No matter where you have long lines of code, you can always refactor into higher-level functional and shorter methods.

# Relations

{% post https://dev.to/mcsee/code-smell-149-optional-chaining-jk %}

# More Info

{% post https://dev.to/mcsee/how-to-get-rid-of-annoying-ifs-forever-1jfg %}

# Disclaimer

Code Smells are my [opinion](https://dev.to/mcsee/i-wrote-more-than-90-articles-on-2021-here-is-what-i-learned-1n3a).

# Credits

Photo by [Jens Lelie](https://unsplash.com/@madebyjens) on [Unsplash](https://unsplash.com/photos/u0vgcIOQG08)

Thanks, Cory 

{% twitter 1644774155642863616 %}
    
* * *

> The programs that live best and longest are those with short functions. You learn just how valuable all those little functions are. All of the payoffs of indirection—explanation, sharing, and choosing—are supported by small functions.

_Martin Fowler_

{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}
C# Tip: Access items from the end of the array using the ^ operator
Tags: csharp
Published: 2023-07-04 13:00:42

---
title: C# Tip: Access items from the end of the array using the ^ operator
published: true
date: 2023-04-11 00:00:00 UTC
tags: csharp
canonical_url: https://code4it.dev/csharptips/access-items-from-end-of-array/
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vjvt8u9u8qlgyj6g19zs.png
---


Say that you have an array of N items and you need to access an element counting from the end of the collection.

Usually, we tend to use the `Length` property of the array, and then subtract the number corresponding to the position we want to reach:

```cs
string[] values = {
    "alfa",
    "bravo",
    "charlie",
    "delta",
    "echo",
    "foxtrot",
    "golf"
};

var echo = values[values.Length - 3];
```

As you can see, we are accessing the same variable twice in a row: `values[values.Length - 3]`.

We can simplify that specific line of code by using the `^` operator:

```cs
string[] values = {
    "alfa",
    "bravo",
    "charlie",
    "delta",
    "echo",
    "foxtrot",
    "golf"
};

var echo = values[^3];
```

Yes, **that's just syntactic sugar**, but it can help make your code more readable. In fact, if you have a look at the IL code generated by both examples, they are perfectly identical. IL is quite difficult to read and understand, but you can acknowledge that both syntaxes are equivalent by looking at the decompiled C# code:

![C# decompiled code](https://www.code4it.dev/csharptips/access-items-from-end-of-array/decompiled.png)

Performance is not affected by this operator, so it's just a matter of readability.

Clearly, you still have to **take care of array bounds** - if you access `values[^55]` you'll get an `IndexOutOfRangeException`.

Pay attention that **the position is 1-based**!

```cs
string[] values = {
    "alfa",
    "bravo",
    "charlie",
    "delta",
    "echo",
    "foxtrot",
    "golf"
};

Console.WriteLine(values[^1]); //golf
Console.WriteLine(values[^0]); //IndexOutOfRangeException
```

## Further readings

Using `^` is a nice trick that many C# developers don't know. There are some special characters that can help us but are often not used. Like the `@` operator!

🔗 [C# Tip: use the @ prefix when a name is reserved](https://www.code4it.dev/csharptips/use-at-symbol-prefix/)

_This article first appeared on [Code4IT 🐧](https://www.code4it.dev/)_

## Wrapping up

In this article, we've learned that just using the right syntax can make our code much more readable.

But we also learned that not every new addition in the language brings performance improvements to the table.

I hope you enjoyed this article! Let's keep in touch on [Twitter](https://twitter.com/BelloneDavide) or on [LinkedIn](https://www.linkedin.com/in/BelloneDavide/), if you want! 🤜🤛

Happy coding!

🐧
Identity Protocol improvements in ASP.NET Core 8
Published: 2023-04-21 00:45:06

---
title: Identity Protocol improvements in ASP.NET Core 8
published: true
date: 2023-04-10 22:56:48 UTC
tags: 
canonical_url: 
---

Last week, [Jeremy Likness discussed improvements to Authentication and Identity features in ASP.NET Core 8](https://devblogs.microsoft.com/dotnet/improvements-auth-identity-aspnetcore-8/).

I wanted to try some of it out, so I first went to install [dotnet 8.0.0-preview.2](https://dotnet.microsoft.com/en-us/download/dotnet/8.0). I think the downloads page looks slick.

## OpenID Connect, IdentityServer, and Duende

Earlier this week, I talked about the terms [Authentication vs Authorization](https://danschnau.com/blog/authentication-vs-authorization). Now I'll use this chance to tie the terms to more technical details.

ASP.NET Core, in the past, used a third-party implementation of OpenID Connect called IdentityServer to provide authentication and authorization services. IdentityServer is an implementation of the OpenId Conect protocol, which itself is a layer over the OAuth 2.0 protocol that provides Authentication, which is a protocol for Authorization.

The Authorization story here starts with the [OAuth 2.0 Authorization Framework](https://www.rfc-editor.org/rfc/rfc6749). Oauth 2.0 is a framework for dealing with limitations of client-server authentication. There are a lot of good reasons to not implement client-server authentication. From this developer's perspective, the most attractive reason is that with OAuth, I as a software engineer, don't need to spend the time and money on implementing password security. This is because the OAuth protocol specifies an authorization layer that separates the client and server, enabling third parties to provide Authorization services.

OAuth 2.0 provides an _authorization_ implementation. OpenID Connect provides an _authentication_ implementation. And both are just protocols. That is - protocols that are instructions for software to implement to work with other software that implements the same protocols.

Back to the beginning. Until version 8, ASP.NET Core used a third party implementation of OpenId Connect called [IdentityServer](https://identityserver4.readthedocs.io/en/latest/). In version 8, this dependency is removed, and developers will be able to pick from IdentityServer or any other number of OpenId Connect and OAuth 2.0 implementations.

Ostensibly, these changes will make it easier to create and ship "simple" auth systems that do things like use social logins - and I look forward to trying them out as they become available.
Why Companies Need Audit Logs Now
Tags: rust, zeroassumptions, zerotrust, networking
Published: 2023-04-10 22:39:18

As we're doing more and more engineering work from different places, "the office" is no longer a static physical location. It could be home at the kitchen counter, at the airport, at a coffee shop, or even back in your childhood home. With this distribution of the workforce, companies have a duty to their stakeholders and to compliance protocols to keep audit logs for engineer activities. 

In this article, we'll go over the ways in which Zero Assumptions provides security and data for unexpected activities performed by engineers.

## Audit logs as insurance and assurance

Audit logs provide an insurance for tracking down errors and unexpected activities being performed on company databases and servers. When something unexpected happens, designated operators only need to log in to view audit logs and interpret the logs. From there, they can report out to stakeholders using real data rather than perceptions and assumptions. 

Because Zero Assumptions is an on-prem solution, companies determine where to store logs and for how long. This means that companies have a high level of ownership over the compliance standards that they must uphold. Zero Assumptions gives that freedom back to companies, rather than dictating how data is stored. 

With audit logs and control over data storage, companies can be assured that they have a solution in place in case of bad actors, breaches, and human error. 

## Bonus use cases for audit logs

Audit logs can do a lot more than provide a written record for investigation of unexpected activities. Here are some additional ideas for how to use audit log data:

* Reveal inefficient database requests
* Provide aggregation of activity for database and server cost analysis
* Compile work hours to determine engineers' work habits (can help with exploring experimental programs like the 4-day work week, etc.)

## Stay Connected to Zero Assumptions

Follow us here on DEV, [Twitter](https://twitter.com/ZeroAssumptions), and [LinkedIn](https://www.linkedin.com/company/zero-assumptions). 

Read more about [Zero Assumptions](https://zeroassumptions.dev/).
Understanding the React Component Lifecycle!
Tags: react, javascript, webdev, frontend
Published: 2023-04-10 22:22:25

React is a popular JavaScript library for building user interfaces. One of the key concepts in React is the Component Lifecycle. It refers to the series of methods that are invoked in a particular order when a component is mounted, updated, or unmounted.

Understanding the Component Lifecycle can help you to write more efficient and optimized code. Here's a brief overview of the different phases of the Component Lifecycle:

1- Mounting: The component is created and inserted into the DOM. The following methods are called in order:
constructor()
static getDerivedStateFromProps()
render()
componentDidMount()

2- Updating: The component is re-rendered due to changes in state or props. The following methods are called in order:
static getDerivedStateFromProps()
shouldComponentUpdate()
render()
getSnapshotBeforeUpdate()
componentDidUpdate()

3- Unmounting: The component is removed from the DOM. The following method is called:
componentWillUnmount()

By understanding the Component Lifecycle, you can control the behavior of your components and ensure that they behave in the way that you want them to. Happy coding!
There's a catch
Tags: devjournal, ruby, beginners, rails
Published: 2023-04-10 22:16:59

Working right now on a creating an application, that is so far interesting to me. There's a catch though, it will be one of my first "completed" application on Ruby on Rails. I say "completed" because I started on a few prior but the idea or concept wasn't enough to keep me interested as it wouldn't really have much of an impact on improving others life(or making money for that matter). As I said before, there's a catch... stay tuned!
Day 732 : To be honest
Tags: hiphop, code, coding, lifelongdev
Published: 2023-04-10 21:57:37

_liner notes_:
- Saturday : Pretty chill day. Mostly spent getting ready for the radio. Did the radio show. Had a good time. After the show, I did a little coding on my side project before going to sleep. The recording of this week's show is at https://kNOwBETTERHIPHOP.com


![Radio show episode image of 3 members of Tennessee House of Representatives holding hands with their arms raised with the words April 8th 2023 Pasts of Angels](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ma9gidjcbd2wepzsjrz.jpg)

- Sunday : So I did the https://untilit.works study sessions. It was another pretty chill day, but I did get some stuff done. I kind of added the View Transitions API to my side project. It isn't pretty and will definitely need refactoring, but I got the basics working. I'll do some more tinkering to see if I can get it the way I want. I also filed my taxes. This was a task! haha So many forms to fill out and data to enter. I mean, the government can listen to my phone calls and read my emails, but they can't tell me if I owe them taxes or get a refund. haha After that stress, I relaxed by watching the 1st episode of the 3rd season of "Demon Slayer". It was really good. Looking forward to more.

- Professional : I have no clue where the day went. I did some research, spoke with some coworkers to get their feedback, took an online training and helped out with a community question. I look up and it's already the end of the day. To be honest, I thought I would get more done today. haha.

- Personal : So the taxes I filed were rejected. I kind of knew there would be an issue, because the government sent me a form in January and then another form in April basically telling me that the first form was void. I was like, okay? Sure enough, the reason it was rejected was because I didn't include the form. Entered in the data and re-filed. It said it was accepted, so we'll see.

![Standing on a beach in Point Reyes, CA, United States with rocky hills on the left and ocean waves crashing on the dark brown sand to the right under a cloudless blue sky](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x920ccdcleuls6g8v4cc.jpg)

Going to go through some tracks for the radio show. I want to make sure I have more than enough because I'll be out of the country next week. Can't believe the time has went by so quickly. I'll also work on my side project. I want to get that up and running before I head out next week. I'll end the night watching the new episode of "Vinland Saga".

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube RNh-6sNxx6A %}
How to make 3D Profile Card with HTML and CSS
Tags: webdev, css, html
Published: 2023-04-10 21:56:09

Hello, I just throw how to make 3D profile card with only HTML and CSS.

<p class="codepen" data-height="300" data-default-tab="html,result" data-slug-hash="oNaXdaK" data-user="YMCAts" style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;">
  <span>See the Pen <a href="https://codepen.io/YMCAts/pen/oNaXdaK">
  3D Profile Card_CSS</a> by YMCAts (<a href="https://codepen.io/YMCAts">@YMCAts</a>)
  on <a href="https://codepen.io">CodePen</a>.</span>
</p>
<script async src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script>

{% codepen [https://codepen.io/YMCAts/pen/oNaXdaK](https://codepen.io/YMCAts/pen/oNaXdaK) %}