teleren/devto huggingface dataset:
Diferença entre NPM e Yarn
Tags: beginners, programming, braziliandevs, webdev
Published: 2022-05-09 22:33:34

## Contexto

Pra entender o _Yarn_ é interessante saber o motivo pra ele ser desenvolvido. Antes dele ser criado, o _NPM_ tinha vários problemas crônicos como velocidade de instalação dos pacotes e um grave problema com segurança dos pacotes disponibilizados, não verificando se existiam requisições suspeitas dentro dos pacotes baixados.
Então na época o _Yarn_ trouxe uma velocidade de instalação muito maior por instalar os pacotes em paralelo, ao contrário do _NPM_ que utiliza instalação sequencial. Mas algo que trouxe muita relevância pro _Yarn_ foi a segurança que ele trazia pois suas políticas de segurança eram muito melhores do que o _NPM_ tinha.

Após muitas atualizações o _NPM_ melhorou muito e trouxe várias melhorias para o tempo de instalação, que está similar e em questão de segurança.

Então antes o _Yarn_ era uma solução, mas hoje, é uma alternativa pois o _NPM_ e _Yarn_ já estão muito parecidos e é mais uma preferência pessoal de uso.

Os comandos são extremamente similares, facilitando o aprendizado e migração de um para o outro.


## Características

### NPM
- Instalação sequencial;
- Nativo no node.js;
- Cria arquivo package-lock.json
- Compatibilidade com todas as versões do node

    **Desvantagens:**
- Saída de comandos ou erros retornados difíceis de ler
- Apesar de todas as melhorias com segurança, ainda existem algumas vulnerabilidades

### Yarn
- Instalação paralela
- Gera arquivo `yarn.lock`
- Defende a velocidade e segurança
- Cache de alguns pacotes (gerando maior velocidade na instalação)

    **Desvantagens:**
- Não funciona com node V5 ou mais antigos
- Necessita ser instalado 'por fora' (utilizando NPM ou outra forma)


## Yarn 2.x


O Yarn 2.X é uma nova forma de gerenciador de pacotes pois ele cria uma espécie de BD de pacotes na sua máquina para evitar várias instalações de pacotes de diferentes projetos. Existem algumas vantagens com isso como reaproveitamento de pacotes (_zero installs_). Nessa versão não se usa a pasta `node_modules`, pois os pacotes estão instalados em outro local no seu computador. Para linkar os pacotes é gerado um arquivo chamado `.pnp.cjs` (_Plug'n'Play_).
Is web penetration testing worth it?
Tags: programming, node, java, javascript
Published: 2022-05-09 22:28:18

One of our clients is forcing us to share a web penetration testing report. We do all kinds of security testing ourselves, but they wouldn't accept our reports. The client policy requires the vendors to share a third-party report. I spoke to a bunch of penetration testing companies. It seems they do basic tests and charge ridiculously high. My question is, is it worth doing web penetration testing? Has anyone found it helpful beyond the checklist need?
🎞️ This is how we maintain & release Secured Software on Github 🤖
Tags: github, java, security, devops
Published: 2022-05-09 22:23:54

## ❔ About

As many organizations, we have to develop & maintain (aka. **`BUILD & RUN`**) common software.

☝️ This process involves **a lot of things that have to be achieved**... (if you want to get a robust and secured software release pipeline).

I'll showcase here how we achieved all theses challenges on a common Java library dedicated to logging :

{% github opt-nc/opt-logging %}

## 🏎️ Time to Market

Software release pipeline gains everyday a shorter Time To Market.

In fact there is no real option : 

> _**maintenance & release tasks have to be drastically automated... and should embed security concerns on the left side of the pipeline.**_

## 🛡️ Security

We have three complementary ways of achieving security tasks on our pipeline : 

1. [Dependabot](https://github.com/dependabot) alerts : so we get Pull Requests to notify us what are the risks
2. [`CodeQL`](https://codeql.github.com/) Scan as part of [GitHub Advanced Security](https://docs.github.com/en/get-started/learning-about-github/about-github-advanced-security) (aka. GHAS)
3. Docker Image scan (see [previous dedicated post](https://dev.to/optnc/bench-and-choose-java-8-docker-images-with-anchoregrype-4fg8))


Then to release software we rely on [`semantic-release`](https://github.com/semantic-release/semantic-release) to implement a solid [Semantic Versioning scheme](https://semver.org/) and get a

> _**fully automated version management and package publishing pipeline.**_

## 🍿 Démo

Here is the full secured & automated release process 👇

{% youtube jfvRUCo89Iw %}

## 🧰 Stack

- [`semantic-release`](https://github.com/semantic-release/semantic-release)
- [`codeql`](https://codeql.github.com/)
- [`codeql-action`](https://github.com/github/codeql-action)
- [GitHub Advanced Security](https://docs.github.com/en/get-started/learning-about-github/about-github-advanced-security)


## 🔖 Related contents

### ⛯ Scan Docker images 🛡️

{% embed https://dev.to/optnc/bench-and-choose-java-8-docker-images-with-anchoregrype-4fg8 %}

### 🔂 Semantic release demo 🎞️

Semantic release intro demo :

{% youtube Er-W5J5ky7Q %}
Ng-News: Episode 22/18
Tags: angular, javascript, webdev, programming
Published: 2022-05-09 22:13:07

This is a weekly posting, covering the latest updates from the Angular community.

{% embed https://youtu.be/zIXiS4xjvlM %}

## Angular v14.0.0-next.15 / Standalone Components

Some fuzz was going on about Angular's beta/next for the next major release, which is 14. It already contains standalone components and a `bootstrapApplication` method that takes a standalone `AppComponent` instead of the usual `AppModule`.

So if you are curious and have the time, you can already try it out to get a first real-life impression of how it feels to work with standalone components.

[Release Notes v14.0.0-next.15](https://github.com/angular/angular/releases/tag/14.0.0-next.15)

Brandon Roberts also did a video where he and his guests discussed the impact of the new features.

{% embed https://youtu.be/NiKDEfiQ0CI %}

There was more official information on that topic in the monthly ng gaming video stream. Standalone components will obviously land in v14 but only as a developer preview. The plan is to fully enable them in version 15.

{% embed https://youtu.be/au1wml8-xVc %}

## NgRx 13.2 

NgRx, the most used Angular library for state management, got an upgrade to 13.2. ActionGroup is a new feature which will reduce the boilerplate code.

[Explanation of new Action Group Creator](https://dev.to/ngrx/ngrx-action-group-creator-1deh)

At the moment, NgRx requires NgModules. There is now a PR which shows  a path how NgRx would look like in the new world without NgModules. It is very nice to see that not just Angular but also the ecosystem starts to prepare for the big change.

[RFC: Standalone NgRx APIs](https://github.com/ngrx/platform/discussions/3399)

## Miscellaneous

### Jest 28.1

Jest, a testing framework, had a minor version upgrade to 28.1.

### Nx 14.1

Nx, a popular build framework, released 14.1. It is now possible to migrate an Angular CLI workspace with multiple projects to nx.
Growing On Dev.to - It's Possible
Tags: devjournal, wecoded
Published: 2022-05-09 21:45:23

## Table of Contents
1. [April 9, 2022](#april-9)
2. [May 9, 2022](#may-9)

### April 9
This day marked one month since my first article got published on March 9th, [Zorin OS](https://dev.to/tmchuynh/linux-zorin-os-43dk). When I first started writing on here, my intention was to share my experiences and my journey as I gained new knowledge in my field. I had just switched to Linux, was learning React and Typescript, and saw a bright future ahead of me in web development. Oh, how things have changed.

I started reading other's posts more and seeing the trend in the topics that interested me. Topics that would lead me to dive deeper into research were also things I knew I would want to go back to, want to share, and thought others could benefit from knowing as well. Therefore, I started writing on them. The more I wrote, the more research I did and the more I learned. Not only this benefited me and my journey as a developer but I was giving back to the community around me. By the time the morning of my one month came around, I had 354 followers and had been posting on average two articles each day. Note: Many people post one article a day maximum but I have always adored writing, personally.

### May 9
![two month mark](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/la6znrti0otpacrlvd9e.png)
 
TWO MONTHS! 986 followers! How incredible is that?! I am writing this and not believing that it's only been two months since I started this journey on here because it feels as if I've belonged my entire life.

Though I have gotten busier and more preoccupied with projects and other tasks that I have not stuck with posting consistently two articles a day, I am still posting on average 1-2 articles a day. Coming on here to write and share the knowledge that I am learning day in and day out has become a normal part of my week. It's actually a very special part of it that I look forward to in hopes that my articles help someone in any way shape or form.

And through even the fewest thanks and warm feedback I do get, it warms my heart knowing my writing is reaching someone and doing good out there in the world. It is helping someone and in some way I am making a difference. And this proves that you can too.

I am only at my two month mark. Imagine what two years could do. Imagine the difference that we could make in the world.

Happy coding!
Data Migration Between Two MongoDB Atlas Instances ( Connections )
Tags: mongodb, database, tutorial
Published: 2022-05-09 21:33:33

As for how easy it can be to set up a MongoDB Atlas account and database, it will just become harder when you try to move the data around.

Lately, at our company, we have decided to migrate our current development MongoDB Instance into another Instance and In this article, I will discuss how I approached and solved this task.

So the challenging part of this Migration was our database design, because of its complexity, the Application is a built upon Microservices and Microservice Architecture that includes around +30 Microservices with +10 Databases that handle Different Groups of Microservices separately, and then each of them contains around hundreds of collections that even each of them contains thousands of data.


According to the Official Documentation of MongoDb, you could export each collection separately which is not helpful for our case because we are dealing with a lot of collections.

Another Solution might be using the MongoDump command to dump the whole Database together, but again not that helpful as it's done manually for exporting and importing each of the Databases.

After enough research regarding the best way to handle this situation, I have come to a tool that could do this in a matter of seconds which I will be discussing below.


1. First of All, Prepare your Host and Target MongoDB URI or at least a connection for each of them

2. Then, We are using a tool called [NoSQL Booster](https://nosqlbooster.com/).

NoSQLBooster is a cross-platform GUI tool for MongoDB v2.6-5.0, which provides a build-in MongoDB script debuggerMongoDB script debugger, and comprehensive server monitoring tools, chaining fluent query, SQL query, query code generator, task scheduling, and much more.

3. After you have installed the tool, you will be popped up with adding connections from the first step.

![Connections pop up](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8dfgte98w62fkstad3es.png)
 
in this step , I am Connecting via my Atlas URI, so you can simply connect other atlases or any MongoDB from any server.


4. you will see your connections loaded in the side like mine in the picture 

![Loaded Schema](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/irwr4jv2g3jwzxojfahq.png)
 

5. Only part left is pretty simple, you copy a database and simply paste it into the other connection. it is simple as that, It will load the DB with all of its data and indexes into the other one.

A) Copy A Database from the Host Connection

![Copy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2dphyiat13vzlj0czug1.png)
 
B) Paste A Database to the Target Connection

![Paste](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vt6lizqiwml5yfrtsp35.png)
 
in my case, I did the copying operation around +10 times and our new database is good to go :).


Thanks for reading this Article, Just wanted to share this experience I had today in this article.

can you do all the DBs together with one click? I am not sure, maybe there is a better solution but this is quickest i have found and used. :)
Cadena Community AMA with Chris Choyce from VaynerNFT Cadena Community AMA with Chris Choyce from VaynerNFT
Tags: web3, blockchain, solidity, career
Published: 2022-05-09 21:33:06

{% embed https://youtu.be/YKatMjx2QZM %}

Our Cadena Community AMA with Christopher Choyce who is Head of Technology at Gary Vaynerchuck’s VaynerNFT.

We talk about how to get started as a developer in web3, various chains like Ethereum, Flow, Solana, and take questions from the community. We also discuss the latest developer tools like Ethers.js, Hardhat, and Truffle.

Want to learn more? Visit: [cadena.dev](https://www.cadena.dev/)
Cadena Community AMA with Arthur Sabinstev from Pocket Network Cadena Community AMA with Arthur Sabinstev from Pocket Network
Tags: web3, blockchain, pokt, smartcontracts
Published: 2022-05-09 21:29:52

Cadena Community AMA with with Arthur Sabinstev, Head of Engineering at Pocket Network (POKT).


{% embed https://www.youtube.com/embed/JwwRbyz7aMk %}

[You can learn more here.](https://cadena.dev/blog/community-ama-with-arthur-sabinstev-from-pocket-network/?swcfpc=1)
List all git commits with GitPython
Tags: python, git
Published: 2022-05-09 21:08:10

---
canonical_url: https://waylonwalker.com/til/git-python-all-commits/
cover_image: https://images.waylonwalker.com/til/git-python-all-commits.png
published: true
tags:
- python
- git
title: List all git commits with GitPython
---

I am getting ready to do some timeseries analysis on a git repo with python, my first step is to figure out a way to list all of the git commits so that I can analyze each one however I want.  The GitPython library made this almost trivial once I realized how.

``` python
from git import Repo

repo = Repo('.') commits = repo.iter_commits()
```

This returns a generator, if you are iterating over them this is likely what you want.

``` python
commits
# <generator object Commit._iter_from_process_or_stream at 0x7f3307584510>
```

The generator will return `git.Commit` objects with lots of information about each commit such as `hexsha`, `author`, `commited_datetime`, `gpgsig`, and
`message`.

``` python
next(commits)
# <git.Commit "d125317892d0fab10a36638a2d23356ba25c5621">
```
How do you manage re-usable code snippets?
Tags: discuss, productivity
Published: 2022-05-09 20:57:05

This thread asks which functions people keep around to copy into various projects.

{% embed https://dev.to/joelbonetr/which-functionsmethods-do-you-484m %}

But my question is... How do you manage this? Which programs do you use to manage your personally re-usable code snippets? Text editor? Note-taking app? Thanks!
Switch between Angular files like a lightning (HTML, TS, SPEC, CSS) ⚡️
Tags: angular, vscode, vscodeextension
Published: 2022-05-09 20:52:52

**[Angular 2 Switcher](https://marketplace.visualstudio.com/items?itemName=infinity1207.angular2-switcher) is a great VS Code extension. It brings 4 handy keyboard shortcuts to quickly switch between Angular files of one a component/service - HTML, TS, SPEC and SCSS. I can't imagine my Angular coding without it.**
What is your top priority as a developer in 2022?
Tags: discuss, career
Published: 2022-05-09 20:52:26

This is the first post in a series of big questions devised between DEV and [Mayfield](https://mayfield.com/).

**Please feel welcome to take part in a new thread every day starting with this one**. After a 10 discussions we will be rounding up some of the discussions and publishing key takeaways.

Happy coding!
Enable Self-service Deployments for Devs in EKS
Tags: kubernetes, eks, terraform
Published: 2022-05-09 20:51:16

If you are interested in establishing a smooth collaboration with your Platform Team and n Dev Teams, and allowing Dev Teams to deploy freely and at will without Platform Team being the bottleneck, please checkout my article on the [HashiCorp Learn Series](https://www.hashicorp.com/blog/enable-self-service-aws-eks-deployments-with-cdk-for-terraform).

Oscar Medina, senior cloud architect at Amazon Web Services, joined us on a live stream recently to demo a collaborative workflow to enable self-service Amazon EKS deployments for developers, using CDK for Terraform. Check out the recording of the live demo, and read on for a tutorial of the workflow that platform and developer teams can use to collaborate on Kubernetes deployments with HashiCorp Terraform, Sentinel policies, CDK for Terraform, and EKS.

```
<iframe width="560" height="315" src="https://www.youtube.com/embed/ijgKc6vGVyM" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
```
Caution with try/expect when during with concurrent requests
Tags: django, concurrent
Published: 2022-05-09 20:25:41

Look at this code:
`try
    example.objects.get(name=xxx)
 expect Exception:
    example.objects.create(name=xxx)
    blah, blah
`
The code seems to be working, but it is not thread safe. When we have concurrent requests coming to the server. The requests would penetrate into the expect block and try to create the resource or do something, causing unexpected behavior.
A New Speed testing extension came to chrome.
Tags: javascript, css, html
Published: 2022-05-09 20:23:04

Yes , A New Speed testing extension came to chrome. That is Fast.com chrome extension. 

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

---


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

---

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

---

GitHub Repo => [Fast.com Chrome Extension](https://github.com/junaidcodingmaster/Fast.com-Chrome-Extension)

Creator => [Junaid](https://abujuni.dev)
Kafka not working in Gunicorn+Django
Tags: django, gunicorn, kafka
Published: 2022-05-09 20:19:21

We are integrating kafka into our Django server. The messages never got send out, although the "send" method of the kafka producer is called.

Finally found the root cause, which is due to the gunicorn. The kafka producer instance is initiated with some threads in it during the server start, in the main process. Later the gunicorn fork the instance into workers, but not the threads. So there will be empty threads for the kafka producer in workers.

How to solve it? We don't want to initiate that kafka producer for each send request, which is a waste of time. So we made a lazy instantiation to get the kafka producer: if it does exist, instantiate one, and set it for our kafka producer instance; if it exist(must be instantiated by last send message call), return the kafka producer.
Data Models and Query Languages
Tags: ddia, distributedsystems, summary
Published: 2022-05-09 20:07:10

In complex applications, APIs could be built upon APIs. Each data model hiding the complexity of the layers below it by providing a clean data model.

One of the best data models known today is SQL, based on the relational model.

Most application development today is done in object-oriented programming languages and therefore a translation layer is sometimes required between the objects in the application code and the database model of tables, rows and columns - _aka impedance mismatch_. This is where object-relational mapping is used (e.g. of ORM is sqlalchemy in python).

Using document stores or JSON representation can sometimes help reduce the impedance mismatch but this data model also has its disadvantages (to be explored further in later chapters).

JSON representation has better locality than multi-table relational models. e.g. to obtain a piece of data you might need to perform multi-way joins in a relational database whereas in a document model, all the relevant information is in one place.

## Relational vs Document Databases
Document databases offer schema flexibility and better performance due to locality. Relational databases allow you to perform joins and support many-to-one and many-to-many relationships.

If your application needs to access "entire" datasets then the locality of document databases can be advantageous. If data is split across multiple tables, multiple index lookups and joins can require more disk seeks and therefore add time.

On the flip side, document databases typically load the entire document even if you only want to access a small portion of it.

NB: Locality is not a feature offered only by document databases. Google Spanner DB offers locality properties by allowing schema to declare that a table's rows should be interleaved within a parent table. Other such offerings also exist.

## Query Languages for Data
Imperative programming languages describes the exact operations and the order of those operations (e.g. Python, JS etc). Declarative languages (e.g. SQL) on the other hand just describe the data you want, any conditions the results must meet and any transformations (e.g. group by). It is up to the database system's query optimiser to decide how to achieve the result (using joins, indexes etc).

Declarative languages have a better chance of faster parallel execution since they only specify the pattern of results and not the actual algorithm to obtain the results.

_(summary of chapter 2 from Designing Data-Intensive Applications by Martin Kleppmann)_
The importance of sharing knowledge
Tags: discuss, programming, beginners
Published: 2022-05-09 20:00:32

I discovered that i have a weird and strong passion to share the knowledge about programming i have with friends who are programmers like me or even an unknown person who needs that knowledge, and all i have to say is that it is good and valuable to share atleast some of what you know and here is how.

## The benefit of sharing knowledge
when you share knowledge about coding, it can solidify that knowledge even more because teaching something is a great way to learn it even more, also it is so valuable to the person you teaching it to so it's a win win situation and it can improve your skills at teaching.

## Ways of sharing knowledge
programming knowledge can be shared by making tutorials, writing books, creating courses even explaining a single thing is a form of sharing.

so the point of this post is to encourage people who have some skills not only in programming but in anything to atleast try and share some of it for your personal benefit and for the benefit of whoever teaching it to.