teleren/devto huggingface dataset:
Como testar o locust localmente com docker
Tags: devops, locust, docker, tutorial
Published: 2023-05-16 22:37:43

Para subir o Locust usando o Docker Compose, siga os passos abaixo:

Instalação do Docker e Docker Compose: Certifique-se de ter o Docker e o Docker Compose instalados em seu sistema. Visite o site oficial do Docker e siga as instruções de instalação para o seu sistema operacional.

## Criação do arquivo de script
Crie um arquivo script.py para definir o comportamento dos usuários simulados. Nesse arquivo, você precisará importar as classes FastHttpUser e Task do módulo locust e criar classes que herdem delas. Dentro dessas classes, você pode definir os diferentes comportamentos dos usuários e as tarefas que eles executarão.

### Exemplo de um código que executa 

```python

from locust import task, constant
from locust.contrib.fasthttp import FastHttpUser

class TestCase(FastHttpUser):
    wait_time = constant(.01)
    weight = 1

    @task(1)
    def google(this):
        this.client.get("https://www.google.com.br/search?q=locust", name="Google")

```

## Criação do arquivo Dockerfile

Crie um arquivo chamado Dockerfile (sem extensão) e abra-o em um editor de texto. Adicione o seguinte conteúdo ao arquivo:

```docker
FROM locustio/locust

RUN pip install gevent
```


## Criação do arquivo Docker Compose.yml 
Crie um arquivo chamado docker-compose.yml e abra-o em um editor de texto. Adicione o seguinte conteúdo ao arquivo:

```yaml
version: '3'

services:
  master:
    image: locust-master
    build: ./
    ports:
      - '8089:8089'
    volumes:
      - ./:/mnt/locust
    command: -f /mnt/locust/script.py --master -H http://master:8089

  worker1:
    image: locust-work
    build: ./
    volumes:
      - ./:/mnt/locust
    command: -f /mnt/locust/script.py --worker --master-host master

 worker2:
    image: locust-work
    build: ./
    volumes:
      - ./:/mnt/locust
    command: -f /mnt/locust/script.py --worker --master-host master

```
Neste arquivo definimos um cluster master que vai ficar responsável em mostrar a parte de host do locust e outro 2 workers para distribuir a carga para o sistema.

## Execução

Abra um terminal e navegue até o diretório onde o arquivo docker-compose.yml está localizado. Execute o seguinte comando para iniciar o Locust:

```bash
docker-compose up
```
Isso iniciará o serviço Locust usando as configurações definidas no arquivo docker-compose.yml. A porta 8089 do contêiner será mapeada para a porta 8089 do seu sistema local, permitindo que você acesse a interface web do Locust.

Acesso à interface web: Abra um navegador da web e acesse **http://localhost:8089**. Você verá a interface web do Locust, onde poderá configurar o número de usuários virtuais a serem gerados e iniciar a simulação de carga.

Agora você pode usar o Locust em um ambiente Docker com o Docker Compose para realizar testes de carga e avaliar o desempenho do sistema. Lembre-se de ajustar as configurações de acordo com os requisitos do seu teste e interpretar corretamente os resultados obtidos.
Day 751 : Press Play
Tags: hiphop, code, coding, lifelongdev
Published: 2023-05-16 22:09:08

_liner notes_:
- Professional : Whew.... my brain is fried, haha. Had a meeting with my manager to talk about what's coming up. Did a refactor of a demo with some new functionality. Went over my blog post a couple of times and submitted it for review. Also, did some work on a talk I have coming up.

- Personal : Last night I worked on the platform I created for my talks. There's some new stuff I want to try so I need to add some functionality to the site. I got a good amount done. I also went through a bunch of tracks for the radio show.


![On top of a mountain with grass and flowers looking at mountain ranges extending into the distance at sunset in Mont Coin, France](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jyxlnb4jzg7eusyvdtdy.jpg)

Going to keep working on my talk platform. Just need to verify that log in works and start working on my slides. Hoping to get a bunch done so I can watch some anime. I'll also go through some tracks for the radio show. What I do is just press play and listen to the tracks as I work on other stuff.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube Z4ZwJSwl2Gw %}
Meningkatkan Kinerja Aplikasi Web dengan Caching di Sisi Backend
Tags: backend, caching, indonesian
Published: 2023-05-16 21:39:45

Halo semua!

Sebagai seorang backend developer, salah satu tugas penting kita adalah memastikan kinerja aplikasi web yang cepat dan responsif. Salah satu cara yang efektif untuk mencapai hal ini adalah dengan menggunakan caching di sisi backend.

Dalam postingan ini, kita akan membahas mengapa caching di sisi backend penting dan bagaimana kita dapat meningkatkan kinerja aplikasi web dengan memanfaatkannya.

Mengapa Caching di Sisi Backend Penting?
Mempercepat waktu respons: Dengan menyimpan data atau hasil permintaan sebelumnya di cache, kita dapat menghindari pemrosesan berulang yang memakan waktu dan langsung mengirimkan hasil yang sudah tersedia.

1. Mengurangi beban server

Dengan menggunakan caching, kita dapat mengurangi beban server dengan menghindari pemrosesan yang sama berulang-ulang. Ini akan meningkatkan skala aplikasi kita dan mengurangi biaya operasional.

2. Meningkatkan skalabilitas

Meningkatkan skalabilitas: Dengan mengurangi pemrosesan server yang berulang, kita dapat mengalokasikan sumber daya yang lebih baik dan menghadapi lonjakan lalu lintas tanpa mengorbankan kinerja.


**Menerapkan Caching di Sisi Backend**

- Menggunakan cache server: Pilihlah cache server yang sesuai dengan kebutuhan aplikasi kita, seperti Redis atau Memcached. Konfigurasikan dan gunakan cache server ini untuk menyimpan data yang sering diakses atau hasil komputasi yang mahal.

- Strategi caching yang tepat: Pertimbangkan berbagai strategi caching, seperti caching objek, hasil permintaan HTTP, atau bahkan fragment HTML. Sesuaikan strategi ini dengan jenis data atau respons yang ingin kita cache.

- Pembaruan dan invalidasi cache: Lakukan pembaruan cache secara periodik dan perhatikan mekanisme invalidasi cache yang tepat, agar kita tidak mengirimkan data yang kadaluarsa kepada pengguna.

**Pengujian dan Pemantauan Kinerja**

- Mengukur kinerja aplikasi: Gunakan alat pemantauan kinerja seperti New Relic atau Prometheus untuk memantau latensi permintaan, waktu respons, dan tingkat cache hit. Dengan informasi ini, kita dapat mengidentifikasi area yang perlu dioptimalkan.

- Uji beban dan uji stres: Lakukan uji beban dan uji stres pada aplikasi kita dengan dan tanpa caching. Bandingkan metrik kinerja antara kedua kondisi ini untuk memvalidasi efektivitas caching di sisi backend.

Dengan mengimplementasikan caching di sisi backend, kita dapat meningkatkan kinerja aplikasi web kita secara signifikan. Tidak hanya itu, kita juga dapat menghemat sumber daya server dan memberikan pengalaman pengguna yang lebih baik.

Saya sangat tertarik untuk mendengar pengalaman dan tips Anda dalam menggunakan caching di sisi backend. Silakan bagikan di bagian komentar di bawah!

Terima kasih telah membaca, dan semoga postingan ini bermanfaat bagi Anda sebagai seorang backend developer.

Selamat mengoding!
Trying to make a personal website
Published: 2023-05-16 21:29:48

Hello, I'm trying to make a personal website using Vue 3 and publish it on GitHub Pages https://rivan-codes.github.io but the display isn't responsive yet. Might be interested in contributing to my repository https://github.com/rivan-codes/rivan-codes.github.io, Thanks


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e61tlib991eqbp6w598z.png)
Cool Closure things! (part 1)
Tags: javascript, programming
Published: 2023-05-16 21:29:09

You can implement functions like once using closures! 

it uses the concept of scope, or "backpack".

Basically when you have a function that also returns a function, that returned function gets the variables and data around it (accessible to it in the same scope) in its "backpack", or more officially, in its [[scope]] hidden/private property! 

That allows us to do pretty cool stuff, like for example, create an implementation of the 'once' function! 

```
const creator = (cb) => {
  let counter = 0;
  function once() {
    if(counter >= 1) {
      console.log("Function only runs once!");
    }
    else {
      counter++;
      console.log(cb());
    }
  }
  return once;
}
const callback  = (a, b) => {
  return a+b;
}
const newOnce = creator(() => callback(1, 6));

newOnce();
newOnce();
```


let's explain what this code does: 

1. Here we have a closure called creator, it takes a callback, that does whatever we want, here however, it simply adds two numbers together. ```
const creator = (cb) => {
```
2. then we define a counter variable to track the number of times we ran the code```
let counter = 0;
```
3. We check the value of counter if it exceeds 1, then we don't execute the callback code, otherwise, we go ahead with the execution```
function once() {
    if(counter >= 1) {
      console.log("Function only runs once!");
    }
    else {
      counter++;
      console.log(cb());
    }
  }
```
4. we finally return the function ```
 return once;
```
One of the coolest things here is that the memory is permanent! the function returned from the closure remembers its previous state, which is really powerful! 


I learned this feature recently when I was studying js and closures, and thought it would be cool to try and explain it, hope it would be useful to someone. 

Cheers!
Recurso introduzido no java 17 "Instanceof pattern matching"
Published: 2023-05-16 20:48:45

O código abaixo verifica se um objeto é uma instância de uma classe e, se for, atribui o objeto a uma variável local com um tipo mais específico, o objeto é uma string “João Arthur”, se o objeto é uma instância de String e se a string tem um comprimento maior que 0, se ambas as condições forem verdadeiras, a string é atribuída à variável local “aux” com o tipo String e o primeiro caractere da string é impresso no console.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k84estehd2n08tsuyy3w.jpeg)
How to Set Up and Configure OpenLDAP in a Docker Container with PhpLDAPadmin
Tags: phpldapadmin, docker, tutorial, openldap
Published: 2023-05-16 20:11:27

If you are looking to set up an **LDAP server** and need an easy way to manage it, installing **OpenLDAP with phpLDAPadmin** using Docker can make your life a lot easier.


![image of openldap/docker/phpldapadmin](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9owgnxgbawpdo8r9m6es.png)



**LDAP or Lightweight Directory Access Protocol** is a protocol that allows users to access and maintain directory information services over the internet. It's used by many organizations for authentication, authorization, and other tasks.

1-Install Docker on your machine if you haven't already. You can download Docker from their [website](https://docs.docker.com/engine/install/).

2-Create a new directory on your machine where you want to store the configuration files for your LDAP server.

3-Inside the newly created directory, create a new file called **docker-compose.yml**.

3-Copy the following code into the docker-compose.yml file.


```
version: '3.7'
services:
  openldap:
    image: osixia/openldap:latest
    container_name: openldap
    hostname: openldap
    ports: 
      - "389:389"
      - "636:636"
    volumes:
      - ./data/certificates:/container/service/slapd/assets/certs
      - ./data/slapd/database:/var/lib/ldap
      - ./data/slapd/config:/etc/ldap/slapd.d
    environment: 
      - LDAP_ORGANISATION=alibnr
      - LDAP_DOMAIN=alibnr.com
      - LDAP_ADMIN_USERNAME=admin
      - LDAP_ADMIN_PASSWORD=admin_pass
      - LDAP_CONFIG_PASSWORD=config_pass
      - "LDAP_BASE_DN=dc=alibnr,dc=com"
      - LDAP_TLS_CRT_FILENAME=server.crt
      - LDAP_TLS_KEY_FILENAME=server.key
      - LDAP_TLS_CA_CRT_FILENAME=alibnr.com.ca.crt
      - LDAP_READONLY_USER=true
      - LDAP_READONLY_USER_USERNAME=user-ro
      - LDAP_READONLY_USER_PASSWORD=ro_pass
    networks:
      - openldap
  
  phpldapadmin:
    image: osixia/phpldapadmin:latest
    container_name: phpldapadmin
    hostname: phpldapadmin
    ports: 
      - "80:80"
    environment: 
      - PHPLDAPADMIN_LDAP_HOSTS=openldap
      - PHPLDAPADMIN_HTTPS=false
    depends_on:
      - openldap
    networks:
      - openldap

networks:
  openldap:
    driver: bridge
```

5-Save the file and run the following command in the terminal inside the directory where you created the docker-compose.yml file.

```
docker-compose up -d
```

This will start the OpenLDAP and phpLDAPadmin containers in the background.

6-Once the containers are up and running, you can access the phpLDAPadmin web interface by opening a web browser and entering the following URL.

```
http://localhost

```

7-To log in, enter **cn=admin,dc=alibnr,dc=com** as the username and **admin_pass** as the password.

8-After logging in, you can start managing your LDAP server using the phpLDAPadmin interface.

That's it! You now have a fully functional and easy-to-manage LDAP server using Docker and phpLDAPadmin.
Neurodivergent Talk: What strategies has your workplace implemented to make workflow more accessible for employees?
Tags: codenewbie, productivity, discuss
Published: 2023-05-16 20:27:33

Hey all!

We have a new CodeNewbie Podcast episode coming out tomorrow about neurodivergency and we thought this would be a great opportunity to discuss accommodations in the workplace!

Here is our link to where you can find our new podcast episode, which premiers tomorrow with our guest [Frankie Nicoletti](https://twitter.com/frfrfrankie?lang=en)!

{% embed https://www.codenewbie.org/podcast %}

For those who aren’t familiar, [neurodivergency](https://my.clevelandclinic.org/health/symptoms/23154-neurodivergent) or [neurodiversity](https://en.wikipedia.org/wiki/Neurodiversity) is a nonmedical framework that is used to describe folks who have differences in cognition/brain function than other folks. This term was built around the autism rights movement and [the social model of disability](https://www.notion.so/cc7badc7e89e4b3ba9deaf6afa2244ca) and can be used to describe folks with autism, ADHD, anxiety, OCD, Dyslexia, and other learning disabilities and conditions. 

**So, my question for you all is for my neurodivergent (and neurotypical too!) folks out here— what accommodations do you have in place at your work or in your workflow that help you mitigate burnout, overstimulation, etc. ?**

For myself, as someone with OCD and ADHD, I have a a bunch of different strategies that I use to keep myself feeling my best. I will share them below, and would love to hear what everyone else finds helpful in the discussion!
Any other synthesizer geeks glued to Superbooth?
Tags: music, discuss, watercooler
Published: 2023-05-16 20:21:20

If you're a synthusiast (synth enthusiast) like myself, you've likely been tuning into [Superbooth](https://www.superbooth.com/en/), a synthesizer conference that happened in Berlin just last week.

There were a lot of awesome product announcements, fun demos, and excellent coverage by the many, **many** wonderful synth YouTubers out there.

I'm curious what y'all's favorite synth announcements were, how you're getting your coverage, and anything else in the synth universe that you'd like to talk about. 🎹
#DEVDiscuss: Succeeding in OSS
Tags: devdiscuss, opensource, webdev
Published: 2023-05-16 20:14:33

*image created by [Margaux Peltat](https://www.patreon.com/margauxpeltat) for the [Chilled Cow YouTube channel](https://www.youtube.com/watch?v=lTRiuFIWV54)*

Time for #DEVDiscuss — right here on DEV 😎

Inspired by @tigt's [Top 7 post](https://dev.to/devteam/top-7-featured-dev-posts-from-the-past-week-ibc), tonight’s topic is...**Succeeding in OSS**! 

{% embed https://dev.to/tigt/how-to-succeed-in-open-source-without-really-trying-really-55pj %}

> ≥8 years ago, I wrote about an extremely niche improvement to a very specific use of SVGs. It got enough positive feedback that I turned that knowledge into an NPM package: mini-svg-data-uri.

> Today, it’s both one of the most and least important web dev things I’ve ever done.

---
Questions:
- **Have you ever had a surprise, unexpected, or random OSS success?**
- **Have you ever worked really, really hard on an OSS project and received minimal reward?**
- **What can we do, collectively, to better support OSS builders and maintainers whose work we rely on?**
- **Any triumphs, fails, or other stories you'd like to share on this topic?**
🔥 Keyword Maker Google Chrome Extension With #OpenAI & CRXJS | [2022 - ST SABBIR]
Tags: crxjs, typescript, openai, vite
Published: 2023-05-16 20:09:36

In this video, I was showed how you can easily build an extension using CRXJS vite plugin and also we will going to use #typescript. In this tutorial I'm going to teach you, how you can create a useful and very powerful google chrome extension. Anyway, to do this we are going to use CRXJS which is a vite plugin and also the most famous and useful ReactJs.🔥🔥

[![@devlopersabbir](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a21hp2x95urjelr97nqp.png)](https://www.youtube.com/watch?v=LOcWxUQbYPY)
Unveiling the Mind Reader: How Chat GPT's AI Masters the Art of Anticipating Your Thoughts
Tags: chatgpt, ai, nlp, machinelearning
Published: 2023-05-16 19:53:46


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

In a world driven by rapid technological advancements, chatbots have become an integral part of our daily lives. But have you ever wondered what makes these virtual assistants so conversational and engaging? 


Prepare to be amazed as we unveil the hidden engineering brilliance that powers the remarkable Chat GPT prompt—a ground-breaking leap in the realm of AI communication.


1. Breaking Down Barriers: How Chat GPT Bridges the Gap
2. The Magic of Natural Language Processing: Decoding Human Dialogues
3. Unleashing the Power of Machine Learning: Behind the Scenes of Training
4. The Art of Prompt Engineering: Crafting Dialogues that Inspire
5. Reinventing Contextual Understanding: The Rise of Transformer Models
6. Beyond Words: Enhancing Emotional Intelligence in AI Conversations
7. The Trials and Triumphs: Challenges Faced in Chat GPT Development
8. Securing the Future: Privacy and Ethics in AI-Powered Conversations
9. Real-World Applications: How Chat GPT is Reshaping Customer Support
10. Embracing the Chatbot Revolution: The Future of Conversational AI

Unlock the secrets behind the mind-reading abilities of Chat GPT as we unravel the awe-inspiring engineering that propels AI into an era of unprecedented communication. Delve into the world of thoughtfulness algorithms, contextual semantics, and emotional intelligence as we explore how Chat GPT masterfully predicts and caters to your needs. Brace yourself for a paradigm shift in the way we interact with technology, where conversations with AI blur the line between reality and imagination. Click now to embark on a mind-bending journey into the future of AI-powered conversations—prepare to have your thoughts read like never before!
Is prompt engineering the career of the future?
Tags: promptengineering, programming, career, discuss
Published: 2023-05-16 19:51:38

The demand for prompt engineers is growing rapidly as companies look for ways to improve user experience and engagement. With its focus on creating intuitive interfaces and experiences, prompt engineering is quickly becoming a sought-after career path for those who want to shape the future of technology.

The [DALL-E prompt book ](https://dallery.gallery/wp-content/uploads/2022/07/The-DALL%C2%B7E-2-prompt-book-v1.02.pdf) offers valuable examples of how to structure prompts effectively to achieve precise results. Based on my experience with GPT-3 and Stable Diffusion, it is evident that without careful attention, one can easily obtain unintended and misaligned outputs.

Considering the increasing prevalence of AI in various domains, it is plausible to envision a future where prompt engineering becomes one of the most sought-after skills in the workforce. This raises questions about the expertise required in prompt engineering.

Will universities offer courses on this topic? Will there be a surge in bootcamps similar to the trend witnessed in software development a few years ago? Additionally, would prompt engineering skills be specific to particular AI models, or will they be applicable across different models? Furthermore, is prompt engineering primarily a technical skill or more of a general aptitude for clear communication? Exploring these aspects will shed light on the future demand and nature of prompt engineering as a professional skill.
Code reviews and Suggestions from SARIF report
Tags: githubhack23, opensource, github, devops
Published: 2023-05-16 19:31:38

## What I built 
SARIF support for Reviewdog

### Category Submission: 
Maintainer Must-Haves

### App Link
https://github.com/HollowMan6/sarif4reviewdog/pull/5

### Screenshots 
![eg](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/srz6zwz5yv28v8w7sgd5.png)

### Description 
SARIF, the Static Analysis Results Interchange Format, is a standard, JSON-based format for the output of static analysis tools.

This action enables the maintainers to integrate the fixes proposed by static code analysis tools right from the PR comments.

### Link to Source Code 
https://github.com/HollowMan6/sarif4reviewdog

### Permissive License 
[MIT](https://choosealicense.com/licenses/mit/)

## Background
https://github.com/orgs/community/discussions/52156

GitHub Code Scanning supports generating alerts from the SARIF report, but it can't show the proposed fixes from the report. It can be a good addition to give us the option to make commits to the codebase based on the proposed fixes.

Then I submitted the feature request, but no one respond anything, so why not realize it by myself instead?


### How I built it
In SARIF, The [fix object](https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html#_Toc34317881) represents a proposed fix for the problem indicated by the Result. It specifies a set of artifacts to modify. For each artifact, it specifies regions to remove and provides new content to insert.

I build a general converter from SARIF to [Reviewdog Diagnostic Format (RDFormat)](https://github.com/reviewdog/reviewdog/tree/master/proto/rdf), then use Reviewdog to give suggested code changes as well as the context of the changes for PR reviewing.

### Additional Resources/Info
This Action is currently used by [kubescape](https://github.com/kubescape/github-action#automatically-suggest-fixes), a Cloud Native Computing Foundation (CNCF) sandbox project. It is an open-source Kubernetes security platform and includes risk analysis, security compliance, and misconfiguration scanning. Targeted at the DevSecOps practitioner or platform engineer, it offers an easy-to-use CLI interface, flexible output formats, and automated scanning capabilities.