teleren/devto huggingface dataset:
Resolvendo a soma da lista de compras sem usar laços.
Tags: java, map
Published: 2022-10-28 23:50:53

``import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class DesafioSemLoop {

    public static BigDecimal totalCompras(List<Compra> compras) {
         return compras.stream()
                .map((c)-> c.produtos)
                .flatMap(List::stream)
                .map((item) -> BigDecimal.valueOf(item.qtd).multiply(item.valorUnitario))
                .reduce(BigDecimal.ZERO, (Acumulador, ValorAtual) -> Acumulador.add(ValorAtual) );
    }`

    // a partir daqui não pode mudar nada
    public static void main(String... args) {
        List<Compra> compras = Arrays.asList(
                new Compra("2022-01-01",
                        Arrays.asList(
                                new ItemCompra("a", 2, new BigDecimal("12.34")),
                                new ItemCompra("b", 1, new BigDecimal("3.99")),
                                new ItemCompra("d", 3, new BigDecimal("98.14"))
                        )),
                new Compra("2022-01-02",
                        Arrays.asList(
                                new ItemCompra("a", 6, new BigDecimal("12.34")),
                                new ItemCompra("b", 1, new BigDecimal("3.99")),
                                new ItemCompra("c", 1, new BigDecimal("34.02"))
                        ))
        );

        System.out.println("O total das compras foi de " + totalCompras(compras).toPlainString());
    }

    public static class Compra {
        public final String data;
        public final List<ItemCompra> produtos;

        public Compra(String data, List<ItemCompra> produtos) {
            this.data = data;
            this.produtos = Collections.unmodifiableList(new ArrayList<>(produtos));
        }
    }

    public static class ItemCompra {
        public final String cod;
        public final int qtd;
        public final BigDecimal valorUnitario;

        public ItemCompra(String cod, int qtd, BigDecimal valorUnitario) {
            this.cod = cod;
            this.qtd = qtd;
            this.valorUnitario = valorUnitario;
        }
    }
}`
Error: No hosted parallelism has been purchased or granted
Tags: azure, devops, pipelines, community
Published: 2022-10-28 23:45:28

Greetings my fellow Technology Advocates and Specialists.

In this Troubleshooting Session, I will demonstrate, how I resolved the encountered error - "__No Hosted Parallelism has been Purchased or Granted__" while executing Azure DevOps Pipeline.

Very Recently, I created __one additional New DevOps Organisation.__

Below follows the Details:-

| __KEY__ | __VALUE__ |
| --------- | --------- |
| __DevOps Organisation URL__ | __https://dev.azure.com/AM0704__ |
| __DevOps Organisation Owner__ | __AM@mitra008.onmicrosoft.com__ |
| __DevOps Project__ | __AMCLOUD__ |
| __DevOps Service Connection__ | __amcloud-cicd-service-connection__ |
| __Repo Name__ | __AMREPO__ |

As soon as I executed my First Pipeline on __Microsoft Hosted Build Agent__, below error was encountered:-

| ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fszy0dd5yu79bv1q1d2p.jpg) |
| --------- |

When verified under __DevOps Organisation Settings > Pipelines > Parallel jobs > Private projects__, Parallel Jobs was set to 0 for Microsoft-Hosted. 

Reference Screenshot follows below:-

| ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4xmr6ax7glczucx7fvn4.jpg) |
| --------- |

Browse to below link (__It was mentioned in the error screenshot.__)

| https://aka.ms/azpipelines-parallelism-request |
| --------- |

Fill the Form and Submit. Microsoft then takes 2 -3 Business Days to process the Request.

| ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o96crst7paa1ndunerq5.jpg) |
| --------- |
| ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/km89mh2c7ef47t68eo1r.jpg) |
| ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/60szjr5yyhcv34bkhktm.jpg) |

__Free Tier Request__ was then completed by Microsoft. 
Below is how the Email Response from Microsoft looks like:-

| ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vpyatx1qkkag8hf2bem8.jpg) |
| --------- | 

Changes are reflected in DevOps Organisation.

| ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4xxsk8ztl0lyodnzwtcd.jpg) |
| --------- |

Finally, when Pipeline is executed again, __Earlier Encountered Error was no more found. It was Resolved.__

| ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ggxvqeoq009jg86oocsn.jpg) |
| --------- |

 
__Hope You Enjoyed the Session!!!__

__Stay Safe | Keep Learning | Spread Knowledge__
Agent-based disease spread model in Python
Tags: python, simulation, agentbased, datascience
Published: 2022-10-28 22:51:27

In this article I will demonstrate how agent-based modeling can be used to model and investigate disease spread. I will use the [abm_framework ](https://github.com/LinnartSF/abm_framework) in Python to implement an agent-based SIR model in Python. This application was first published here: [Agent-based SIR model (Python)](https://www.supplychaindataanalytics.com/agent-based-sir-model-python-example/)

## Introducing the SIR model

The SIR modeling framework is a popular framework for modeling disease spread. SIR stands for Susceptible, Infected, Recovered. Below figure illustrates the SIR model.


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

For example, anyone in the susceptible state can be infected. Once you are infected you can infect anyone in the susceptible state. The risk of infection can be modelled to be between 0% and 100%. 

Anyone infected will recover with a certain probability. Once you are recovered, you are either resistant or you can fall back in to susceptible mode. Every state transition is described with probability ratios.

## Introducing agent-based modeling in Python

Agent-based modeling is a popular simulation technique, next to discrete-event simulation, monte-carlo simulation and system dynamics modeling.

Agent-based models describe agents and their inner attributes and dynamics, as well as the interaction between agents. From this one hopes to study and understand the emergence of complex macroscopic system behaviour.

I use the abm_framework in Python for implementing agent-based simulation models. Its setup is illustrated in below figure.


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

**model.py** is the application specific model. It consumes the modules provided by the abm_framework. I implemented the SIR model in Python that way. You can find the code [here](https://www.supplychaindataanalytics.com/agent-based-sir-model-python-example/). The model has the following specifications: 5% initial infection, 7% infection risk, 3% recovery chance. Agents interact with a defined neighbourhood, with a fix radius. Infected agents can infect other agents within their limits of that neighbourhood.

## Simulation results

Below chart summarizes a simulation run with the parameter settings described in previous section.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2nku102djnxrus905cwo.PNG)

Recovery and social distancing (limited infection radius) end disease spread. Only 12% of all agents are infected.
Vinyl Floorig in Dubai
Published: 2022-10-28 22:11:58

Water-resistant, scratch-resistant vinyl flooring from us will make your life effortless. Today’s vinyl flooring is long-lasting, low-maintenance, and simple to install. We have it all, whether you need luxury vinyl plank flooring, vinyl tile, or vinyl sheet flooring. Our range of the most popular styles, colours, textures, and top brands is unrivaled. You’ll want to put in every room of your house because of its financial benefits.
[Vinyl Flooring Dubai](https://flooringdubai.ae/vinyl-flooring)
Vinyl Flooring Dubai offers the best installation services at your doorstep for all of your flooring requirements. We offer the best vinyl flooring, hardwood flooring, and various other flooring options for any commercial or residential setting, such as homes, offices, hotels, schools, restaurants, etc. Our collection includes:

Vinyl tiles
Vinyl sheet
Flooring
Floor skirting
Customized orders
We are a high-quality combination of design, durability, and long-term guarantee, all at an affordable price.

Vinyl flooring is a floor covering made of 4 layers of materials. The first, or bottom, layer is the backing layer, which is often constructed of cork or foam. It is intended to act as an underlayment for vinyl flooring, eliminating the need to install another material before laying it down. It also serves as a cushion to make walking on the floor more pleasant and a sound barrier to keep noise at bay.

Types of Vinyl Flooring
Vinyl Flooring

Vinyl tiles are made to look like stone or ceramic tiles. They, like vinyl planks, are available in a wide range of designs and colours that mirror their natural counterparts. Some individuals use grout when installing vinyl tiles to approximate the look of stone or ceramic tiles more accurately. Many individuals like vinyl tiles for small portions of their home because, unlike stone tiles, vinyl tiles can be easily trimmed to fit into small spaces.

Vinyl Sheet

Unlike vinyl planks and tiles, vinyl sheets are available in rolls up to twelve feet wide and may be installed in a single step. The preferable choice is a vinyl sheet because of its affordability and endurance.

Vinyl Plank

Vinyl planks are designed to provide the appearance of hardwood flooring and are available in a variety of wooden patterns. Many people choose vinyl planks over wood, as vinyl planks are water-resistant, stain-resistant, and simple to maintain. This type of vinyl flooring is best suited for high-traffic areas prone to wear and tear.
Permission Error - Discord.js
Tags: javascript, typescript, discord, bot
Published: 2022-10-28 22:06:43

**DiscordAPIError[50013]: Missing Permissions**

Hello guys, what's up? this is my first post in this community 😃, but i'm with a trouble and i find this site, i'm with a little problem about "permissions" of my discord bot, i gave Administrator permission for bot, but every time when i finish the request to give role with a interactive button, he return this error:

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

I'm using a instance of client class of Discord.js like this:

```js
...
 getClient() {
        const client: any = new Client({ intents: GatewayIntentBits.Guilds });
        client.commands = new Collection();
        client.commandArray = [];
        return client
    }
...
```

But the problem is happening in this line:

```js
const guild = client.guilds.cache.get("1032496332306403409");
                const member = guild.members.cache.get(interaction.user.id)
                member.roles.add("1032639462938787880");
```

I tried to change role of bot, or re-invite for the server with ALL cargos and with all scopes, not is happening...

If anyone have another better way to change the role of a person or make this line works, i will feel very hapiness 😁
CSV Reader - Filters and Maps
Tags: programming, php, csv
Published: 2022-10-28 19:00:21

## Intro
In my previous post, [CSV Reader](https://dev.to/godsgood33/csv-parsing-library-3n8o), I discussed the CSV Reader I created.  In this post, I want to explain how the `Filters` and `Maps` work within the object.

## Filters
Filters are a way that you filter content before ingesting it.  After creating your object you have to add the filter.

```php
$filter = new Filter(‘Phone’, [Customer:class, ‘sanitizePhone’]);
$csv->addFilter($filter);
```

The first parameter is the field that triggers the call.  So in this case, when retrieving the Phone with `$csv->Phone`, it will call `Customer::sanitizePhone()`.  It will automatically pass in the value from the file to that method.  So then you will need to create the method for it to call.

```php
/**
 * Method to sanitize the phone number from a CSV file
 * @param string $val
 * @return string
 */
public static function sanitizePhone(string $val): string
{
    return preg_replace("/[^0-9\+]/", ‘’, $val);
}
```

## Maps

Maps are another really powerful feature.  Maps allow you to combine multiple fields and concatenate them together into one formatted string.  One easy example is an address or a name.

```php
$map = new Map(‘Address’, “%0\n%1, %2 %3”, [‘add’, ‘city’, ‘state’, ‘zip’]);
$csv->addMap($map);
```

In this case, when reading `$csv->Address` it would return with a formatted string similar to

```
123 Main St
Anytown, ST  12345
```
Day 646 : Lazy Days
Tags: hiphop, code, coding, lifelongdev
Published: 2022-10-28 21:53:41

_liner notes_:
- Professional : Today was one of those productive lazy days. Didn't have any meetings so I was able to code and complete a feature for a demo. I just got it working so I can have some other folks check it out and let me get some feedback. I can finalize things once I hear back. Also took some company learning guides that are due in like 2 weeks, but I may be at a conference around that time and wanted to get it out of the way.

- Personal : Yesterday, I went through a bunch of tracks for the radio show. I ended the night watching a course on WebXR. Kind of fell asleep during the middle because I was super tired. Didn't even watch any anime.

![A large orange sandstone formation in the centre of Uluru, Australia surrounded by shrubbery in a desert under a blue almost cloudless sky.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6c970irdeqiyfp14x4ko.png)

Going to finish putting together the radio show. Watch the WebXR course. Fit in an episode of "Mob Psycho 100". I'll also be doing the study sessions on Sunday at https://untilit.works

Have a great night and weekend!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube RPLq8vuLRIk %}
Hacktoberfest Update 4/4 completed
Tags: hacktoberfest, documentation, discuss
Published: 2022-10-28 21:28:36

It's the last days of Hacktoberfest. It's also the weekend plus Halloween. So this is about as far as I probably go this year.Here's a quick update on my progress.

## Contributor.
4 Pull requests accepted and matured. I have reached the Hacktoberfest goal. I wanted to go beyond the goal and have a couple things outstanding.

1 documentation Pull Request is pending. 
1 more documentation is written and waiting some feedback. The maintainer is reworking the documentation section. I have some content written but it has no where to go yet. 


![wire frame sphere. text says "your fourth Hacktoberfest pull request has been approved."](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6bqdpot29wgx2v49qps1.jpg)

## Rewards

I have ordered my shirt and DEV badge. I also got some holopin badges. The design this year is cool. It's on the back of the shirt so it won't be covered by my beard. 

Did we have to order DEV Hacktoberfest badges last year? I didn't get a badge but also don't remember filling out a form like I did this year. If we were suppose to that explain why I didn't get one.

## Maintainer.
This is my first year maintaining a project. So far I had 4 new to Hacktoberfest PRs accepted. I haven't had time to raise new issues due to travel and working on some content for a web site.

## Your Progress

How are you doing in HacktoberFest?
Do we must implements unit test just to have coverage?
Tags: tests, coverage, unittest, myopinion
Published: 2022-10-28 21:18:33

---
title: Do we must implements unit test just to have coverage?
published: yes
description: yes, no, always, depends, let's go to read a paragraph.
tags: tests, coverage, unittest, myopinion
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2022-10-28 20:55 +0000
---

> Sharing a feeling

Since I have started my career I saw many tests in many pull requests, code, etc..., most of the time all people only wish **__have coverage__**. However, this is not good practice because all the tests that we need to implement in our codes should behave according to business rules to simulate whole cases based on your essence.

thanks a lot to read it

best regards
see ya
Uprise | Made with Gatsby JS
Tags: javascript, showdev, gatsby, react
Published: 2022-10-28 21:17:25

![Uprise | Made with Javascript | Gatsby JS](https://res.cloudinary.com/madewithjavascript/image/upload/v1666921941/large_uprise_made_with_gatsby_js_b9ffef15e7.png "Uprise | Made with Javascript | Gatsby JS")


### Uprise optimizes your whole financial life, for free.

> <p>An average $1.5M in net worth back in your pocket. The financial optimization strategies of the experts, personalized for you, completely free.</p>
> <h2>We build financial plans that are:</h2>
> <ul>
> <li>Fully personalized</li>
> <li>Reviewed by a (human) expert</li>
> <li>100% free</li>
> </ul>
> <h2>Personal finance that's actually personal</h2>
> <p>We understand you - your goals, your interests, your work - to optimize your finances for your unique situation...</p>
> <h2>How to allocate your income</h2>
> <p>Make sense of where your money should be going to achieve your goals.</p>
> <h2>Minimize taxes before you file</h2>
> <p>Based on your unique profile, we can minimize your taxes well before filing season.</p>
> <h2>HOW IT WORKS</h2>
> <h3>Tell us about yourself</h3>
> <p>Goals, what do you care about, where do you live, who do you work for? All these things matter when it comes to optimizing your unique situation.</p>
> <h3>We connect you to the best options for you</h3>
> <p>We route you to all the best financial options out there (credit cards, high yield savings accounts, loans, benefits) and tell you how to take full advantage of them - and, yes, there's actually a human looking at your situation.</p>
> <h3>Stay on track</h3>
> <p>We'll continuously monitor your finances for optimization opportunities, and adjust with you as your life changes.</p>
> 

## Want us to feature your project

[Submit your Project to Made with Javascript](https://madewithjavascript.club/submit-project)


You can also write to us for any of your queries at:

[Email Made with Javascript](mailto:madewithjavascript@gmail.com)

## Project already shared on our social media handles.

| SocialMedia | SharedLink |
| ----------- | ---------- |
| Twitter | [Uprise on Twitter](https://twitter.com/withjavascript/status/1586102306512183299?s=20&t=-8AQxOuoDjckjFEvbL1xzQ)
 |
| Medium | [Uprise on Medium](https://medium.com/@madewithjavascript/uprise-made-with-gatsby-js-497dbf6ee121)
 |
| Facebook | [Uprise on Facebook](https://www.facebook.com/madewithjavascript/posts/pfbid07cUbBA6cuuRvC95SqkAQLSUW1nrXApLESfRvSdkZNV5HYvjExivd77KouDrpMQEfl)
 |
| Tumblr | [Uprise on Tumblr](https://at.tumblr.com/madewithjavascript/uprise-made-with-gatsby-js-uprise-optimizes/b71m32xjcyff)
 |
| LinkedIn | [Uprise on LinkedIn](https://ReplaceLink.com)
 |
| Pinterest | [Uprise on Pinterest](https://pin.it/mrtqW4l)
 |


Filled Under:


 - Made with Javascript
 - Made with Gatsby JS
    
Make sure to give this post ❤ 50 ❤ hearts, click the 🦄 unicorns 🦄 and follow 👉 @madewithjavascript 👈 for more such awesome showcases. Show you love for the people who have worked so hard!
Dev.to en español
Tags: opensource, spanish, español, espanol
Published: 2022-10-28 20:45:08


En días anteriores estuve leyendo un post en el que se preguntaban si existía más contenido en español en esta plataforma que uso constantemente.
Y dada está pregunta empecé a revisar el contenido que se crea en nuestro idioma y grata sorpresa que es bastante y muy buena y de contenido muy variado.
Por ende empecé a crear un proyecto con unas premisas cómo cabeza de este: 
1. Nunca monetizar (el contenido es de cada autor)
2. Intentar hacer visible a cada autor, para que reciba la mayor visibilidad y el mayor apoyo posible.
3. El código sea abierto
4. Lo más sencillo para iniciar (más adelante se pueden crear funcionalidades que ayuden a mejorar el proyecto)
5. Y la última no quitar interacciones a dev.to por lo que este proyecto es solo una presentación con los artículos que redirigen a esta plataforma.

A esto cree el siguiente sitio https://devtospanish.danniel.dev/ .
Que se necesita para aparecer en los tags agrega español o spanish o espanol y listo un api consulta estos tags y los presenta en en devto en español.

Cabe aclarar que está abierto a comentarios y mejoras.

Espero este proyecto ayude a la comunidad.
what is your SaaS product?
Tags: saas, product, business, programming
Published: 2022-10-28 20:25:37

**Can you share what is your SaaS product and what the problme your SaaS prdouct is resolving for the end clients!**

- Product Name?
- What problem it will solve or solving?


I'm working on the **Churnfree** which is helping every SaaS business to reduce your churn rate and increase your customer retention and win back your customer again.
Should we teach programming in humanities?
Tags: programming, humanities, python, college
Published: 2022-10-28 20:22:05

I come from a Humanities background. I received 3 degrees in communication studies. Some even like to call communication studies the super humanities. I love everything about communication studies, I love that it is so open for me to research almost anything... that being said, one of the biggest problems with this degree is that no one outside the major really understands what we do. Communication studies is a research-driven field. We take in information from around the world and break it down into bit size snips of information. We use data to tell a story.

I decided to write this post because I've always wondered why humanities don't offer a basic programming or computer logic class. As I was receiving my communication degree, I tried to learn python programming. I did this because I knew this skill would help me conduct research in the future. Understanding that the future will bring us into a world that views programming as essential as reading and writing, why is it that humanity colleges falling to get their students ready for a world of research that is depended on basic programming skills?
We solved B2B and B2C Churn problems?
Tags: churn, business, growth, saas
Published: 2022-10-28 20:16:37

In business, you may know the churn problem is the major problem where people leave your product. In this way, most businesses lost most of the reviews and the investment they have put into bringing their valuable customer.

You Know bringing new customers is very hard now in this competitive era. 

We have developed a tool that will help you to reduce your business churn and save your customers who plan to cancel your membership with the help of customer retention flow. Churnfree and save up to 40% of churned requests. 

Suppose in 1 month, 100 people want to cancel, and this tool will help you to save 30% of your customer you can imagine how big a number it is and how much money you have saved. If you are not using this tool, it means you will lose all your customers. 

You can try 14 days free tarail of **[Churnfree](churnfree.com)** tool for your business.