teleren/devto huggingface dataset:
Como usar uma classe Fixture com xUnit
Tags: csharp, dotnet, tutorial, testing
Published: 2022-02-13 13:40:22

Oi pessoal, tudo certo? Gostaria de compartilhar uma dica que acho interessante para quem escreve testes utilizando o xUnit, que é o uso de Fixture. Para quem está iniciando nessa jornada de testes unitários assim como eu é normal escrevemos dessa forma:

``` cs
[Fact]
public void TesteAreaDoQuadrado()
{
    Area area = new();
    int result = area.Quadrado(5);
    Assert.Equal(25, result);
}

[Fact]
public void TesteAreaDoTriangulo()
{
    Area area = new();
    int result = area.Triangulo(10, 5);
    Assert.Equal(25, result);
}

[Fact]
public void TesteAreaDoRetangulo()
{
    Area area = new();
    int result = area.Retangulo(5, 3);
    Assert.Equal(15, result);
}
```

O que é normal no início, mas podemos que notar que para cada teste estamos instanciando a classe **Area** repetidamente para podermos utilizar os métodos nos casos de teste, isso significa que toda vez que um de nossos testes na mesma classe precisa ser executado, uma nova instância dessa classe é criada e ter uma Fixture resolve essa necessidade. Fixture é uma classe que compartilha todos os métodos de teste, nessa classe você pode configurar tudo que for necessário, assim, evitamos de instanciar classes para cada teste individual e melhorando o tempo de execução dos testes.

## Criando a Fixture

Dentro da classe de teste, criamos uma outra classe, no meu caso AreaFixture que irá ter como propriedade a classe Area já sendo instanciada:

``` cs
public class AreaFixture
{
    public Area Area => new();
}
```

Após isso para compartilhar essa instância entre todos os nossos testes adicionamos uma interface para nossa classe de teste usando o *IClasseFixture*, a interface IClasseFixture espera receber a uma classe Fixture nesse caso a AreaFixture:


``` cs
public class AreasTest : IClassFixture<AreaFixture>
```

Ultimo passo é via injeção de dependência adicionamos ao construtor da classe AreaTest a classe AreaFixture

``` cs
public class AreasTest : IClassFixture<AreaFixture>
    {
        private readonly AreaFixture _areaFixture;
        public AreasTest(AreaFixture areaFixture)
        {
            _areaFixture = areaFixture;
        }
```

Agora quando o xUnit executar os testes irá ser criado uma instância apenas e todos os nossos testes agora possuem acesso aos métodos da classe Area atráves do campo  _areaFixture.Area .

```cs
[Fact]
public void TesteAreaDoQuadrado()
{
    Area area = _areaFixture.Area;
    int result = area.Quadrado(5);
    Assert.Equal(25, result);
}

[Fact]
public void TesteAreaDoTriangulo()
{
    Area area = _areaFixture.Area;
    int result = area.Triangulo(10, 5);
    Assert.Equal(25, result);
}

[Fact]
public void TesteAreaDoRetangulo()
{
    Area area = _areaFixture.Area;
    int result = area.Retangulo(5, 3);
    Assert.Equal(15, result);
}
```

[Código completo](https://gist.github.com/fernanduandrade/9901165cfb1bb66a1d8483cc9823d4ff)
Brain Emotional Learning Model
Tags: machinelearning, ai
Published: 2022-02-12 04:10:16

The **Brain Emotional Learning** (BEL) model is an algorithm based on the mammalian limbic system proposed by Caro Lucas, 2004. The model is characterized as a machine learning algorithm, of reinforcement learning.

One of the examples of implementations of this model in a practical problem is the Brain Emotional Learning Based Intelligent Controller (BELBIC), an intelligent controller that has achieved great results in experiments in the industry.

The BEL block diagram is represented in the figure below:

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

We can observe the representation of parts of the limbic system, responsible for emotions, such as: Thalamus, Sensory Cortex, Orbitofrontal Cortex and Amygdala. An important feature of this model is that stimulus generator (Sensory Input) and Reward/Reinforcement Signal (Rew) can be represented by a function defined by the author himself, according to the problem addressed.

Below is a simulation of a third-order plant, with its natural behavior:

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

And below is the BELBIC algorithm controlling the plant shown in the Figure above:

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

In addition to studies in the control area, the model (BEL) is also used in classification tasks and time series analysis, where the algorithm can be integrated into a genetic algorithm.
I created the colormyweb 🌈🌈
Tags: productivity, javascript, webdev, programming
Published: 2022-02-13 13:30:06

Hello yesterday I created Colormyweb it is the best platform for all web designers
It helps you to design the prototype of the website and handles the color combination of the website in the coming days I update the website

I suggesting this website for all web developers and designers
And also mainly suggesting for @Ben

The web link:https://sripadhs.github.io/colormyweb
Fomir: A Schema-First form library
Tags: form, react, schema
Published: 2022-02-13 13:06:57

## What is Fomir?

Fomir is a Schema-First library for building form.

Source code in Github: [**Fomir**](https://github.com/forsigner/fomir).

## Why create a new form library?

I have tried many form libraries, like redux-form, formik, final-form, react-hook-form... None of them suit my taste. I would expect a forms library with these features:

- Using schema
- Easy to update form state
- High Performance
- More abstract

So I create a new form library, and name it to [**Fomir**](https://github.com/forsigner/fomir).

## Philosophy

### Schema-First

Fomir create form by passing a form schema which is a json tree. the form schema is very flexible, you can create any form by the schema.

### State-Driven

Every thing in form schema is state, you can build the form interface easily. it's useful when you create a dynamic form.

### High Performance

In some case, form performance is very important. Performance of Fomir is high because of subscription-based form state management. It will not rerender the whole form when you update a single field.

### Sharing and Collaborating

In fomir, the component property in form schema decide how to render the form field. Fomir will push you to create some form component like Input, Select, DatePicker... this will make it easy to share form component in you team.

### Low-code friendly

Fomir builds form with schema, so fomir is very easy to use in low-code scenarios. when you want to create something like form builder, Fomir might be a good choice.

### Strongly Typed

Fomir Form provides strong typing via Typescript to allow you to catch common bugs at coding time, and providing the coding intellisense.

## Installation

```bash
npm install fomir fomir-react
```

## Basic Usage

```jsx
function BasicForm() {
  const form = useForm({
    onSubmit(values) {
      alert(JSON.stringify(values, null, 2))
      console.log('values', values)
    },
    children: [
      {
        label: 'First Name',
        name: 'firstName',
        component: 'Input',
        value: '',
      },
      {
        label: 'Last Name',
        name: 'lastName',
        component: 'Input',
        value: '',
      },
      {
        component: 'Submit',
        text: 'submit',
      },
    ],
  })

  return <Form form={form} />
}
```

## Documentation

For more detailed usage, please see the documentation: [fomir.vercel.app](https://fomir.vercel.app/).
Composition in React 
Published: 2022-02-13 12:31:38

React has a powerful composition model so that unlike inheritance where the one component extends another component, we can use a parent-child relationship between components.

This is useful in cases where some components don’t know their children ahead of time.

Let's say we want to create a counter component  with a common header.
{% codesandbox cefjo view=split %}
Here, FancyHeader is acting as container component which can take any other component as a `children` prop.The Counter component is only concerned with the functionality.

Composition also works with class based component.
{% codesandbox vx562 view=split %}
How PHP Switch Case Statement
Tags: php, phpswitchcase, programming, beginners
Published: 2022-02-13 12:28:53

The **[PHP switch Case statement](https://www.codeexampler.com/php-switch)** is followed by the variable or value to compare

The case statements inside the switch block are followed by the alternate variable or value to compare

 The Code following the colon in the case statement will only execute if the switch and case values match

Only one dereliction case is allowed, which will execute if no break statement exists previous

a,The break statement prevents any following cases from being tested, therefore precluding their law from running
b, The continue statement can be used in place of break
continue accepts an voluntary numeric argument which tells it how numerous situations of enclosing circles it should skip – see latterly in the composition for what this means in switch statements

Switch/ case makes a loose comparison by dereliction
This means that 2 and “ 2” are equal – as are 0 and FALSE – as the variable type is ignored
See latterly in the composition on how to use strict comparisons where the variable type are considered

**[Switch Case PHP Example](https://www.codeexampler.com/php-switch)**

<?php

$i=250;
Switch($i)
{
Case 150:
echo "Value is 150";
Break;

Case 250:
echo "Value is 250";
Break;

Case 350:
echo "Value is 350";
Break;

Case 450:
echo "Value is 450";
Break;

Default:
echo "Enter Correct Value";
Break;
}

?>

Learn also **[PHP Variables Tutorials for Beginners](https://www.codeexampler.com/php-variables)** because wihthout good knowledge on basic variables you don't understand PHP Switch Case by CodeExampler Website

![Switch Case PHP Free tutorial for Beginners by CodeExampler](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9f10ugnvuix6uzgj0o3e.PNG)
Kotlin Basics
Tags: kotlin, beginners
Published: 2022-02-13 12:22:14


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

# Data Types
```kotlin
// Type Annotation //
// String
val string: String = "Yasha Gozwan"

// Character
val char: Char = 'A'

// Integer Numbers
val byte: Byte = 122
val short: Short = 12_345
val int: Int = 1_234_567_891
val long: Long = 1_123_456_789_123_123_123L

// Float Numbers
val float: Float = 123.123F
val double: Double = 123.123

// Boolean
val isVerify: Boolean = false
val isSuccess: Boolean = true
```
# Strings
```kotlin
// String
val myStr = "Hello World"

// uppercase and lowercase
val upper = myStr.uppercase()
val lower = myStr.lowercase()

// Get length
// length
val myLength = myStr.length

// getting first and last character
val firstChar = myStr[0]
val lastChar = myStr[myStr.length - 1]
```
# String Interpolation
```kotlin
// String Interpolation
val name = "Yasha"
val age = 26
println("Hello everyone. My name is $name and i $age old thanks")
```
Python 101: Ultimate Python Guide 
Tags: beginners, python, luxacademy
Published: 2022-02-13 12:07:21

Python is a widely-used programming language that was created by Guido van Rossum, and first released on February 20, 1991.Python is a multipurpose programming language, and it has applicability pretty much anywhere that uses data, mathematical computation, or lines of code.

Python usability goes beyond a basic web development and can be used for: Data science, Machine learning and Data mining. Python has been fronted as a preferred programing language due to its various advantages;

1. Python has a huge community to support it, 
2. It's  free and open source software.
3. Simple syntax- Python coding language has an easy-to-learn syntax and uses English words.
4. Readability-lines  of code in python are easy to read

**Python Installation**
You can download the various versions of python through your preferred browser(preferred versions 3.8- 3.9 and 3.10 have bugs).
One can download through Pycharm with the below link

[((https://www.jetbrains.com/pycharm/download/#section=linux))]
Alternatively, one can use an online python e run from online interpreter, like you can get started from **Replit** 
[(https://replit.com/languages/python3)]

**Python Operators**
Operators are used to perform operations on variables and values.
Python divides the operators in the following groups:

- Arithmetic operators
- Assignment operators
- Comparison operators
- Logical operators
- Identity operators
- Membership operator

**Python Data Types**
Data types are the classification or categorization of data items. The following are the standard data types of Python:
• Numeric
• Sequence Type
• Boolean
• Set
• Dictionary

**Python Collections (Arrays)**
There are several collection data types in the Python programming language:

1. **List**- A list is a collection which is ordered and changeable. In Python lists are written with square brackets.

`thislist = ["lemon", "lime", "avocado"]
print(thislist)`

2. **Tuple **-A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets
`thistuple = ("lemon", "lime", "avocado")
print(thistuple)`

3. **Dictionary**-A dictionary is a collection which is unordered, changeable and indexed and written with curly brackets, and they have keys and values.
`thisdict = {"brand": "Gucci", "model": "Prada", "year": 2019}
print(thisdict)`

4. **Functions**-A function is a block of code that runs when it is called.Function is defined with the **def** keyword.

`def Year():
    print('2022')`

Year() is calls the function to execute.

In summary, this is what I've learnt in week 1 Python Bootcamp at Lux Academy. Looking forward to building my skills in programming with python.
Public Service Announcement: I've joined the SRE team
Tags: sre, devops, career, dotnet
Published: 2022-02-13 11:53:12

> Cover image by <a href="https://unsplash.com/@brianna_santellan?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Brianna Santellan</a> on <a href="https://unsplash.com/s/photos/career-promotion?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>

Since I joined my current company 9 months ago, I have always looked at the SRE team with interest. They look to be experts in everything: technology stack, application domain knowledge, software architecture, the ability to handle hot and risky tasks, DevOps techniques, cloud services and infrastructure. They literally looked so brilliant.

Since then, I simply wanted to become one of them. So I thought that I had to work hard to fill the knowledge gap between me and them and then ask to join the team one day. I never explicity asked for a team change but few - and apparently right - people knew I would like it.

> If you don't known what an SRE is, it stands for Site Reliability Engineer. It is a software engineering approach invented by Google in the 00s but became public knowledge only in the last years. Lot of companies like Amazon and Netflix adopted this technique. It is like a DevOps subset approach, but teams members have a software development background and they can fill the gap between devs and operation teams. SREs have to make sure the system runs smoothly. Resources provisioning, infrastructure, bugs, check and fix of production data, automation of ripetitive tasks in order to remove the toil is what they do everyday.

In an afternoon about a month ago, my boss called me on Teams and I thought the reason was a task I was working on. Instead, he asked me if it was true that I was interested in joining the SRE team, because they probably needed more people. The question was unofficial because everything needed to be sorted out yet but obviously I gave the green light on my candidature. At that moment I didn't realize immediatly what was going on and I felt completely normal. After the call I started to understand what happened and I was so excited about the news! A couple of week later I received another call from my boss and he confirmed the move. Deal was done!

For the first time in my work career, I can finally say that I am not a software developer anymore, but an SRE! 🎉
Indicate your customer segments
Published: 2022-02-13 11:47:12


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u2wb3bbpftqmpdje1jug.png)
Pumping money into various different marketing services, but failing to see any return on investment (ROI) can be a real drag. The product or service you are offering is great, in fact, you have a number of customers that can already vouch for that. You’re doing all the right things; optimizing your website for SEO, posting regular content, sending email campaigns to your database, keeping active on social media pages, advertising online, and more!
So what exactly is the problem? Probably, isn’t your target audience simply segmented enough?

If you are still looking for an ally that offers you a technological solution to be able to segment your audience, we recommend you approach [**Simla**](https://simla.com/es). With its system you can not only personalize customer service by having all your communications integrated in a single window, but you can also segment your audience to make your sales processes more efficient.
Breaking your target audience down into smaller segments is one of the most important tasks a marketer can do in order to increase the likelihood of having a successful marketing strategy.
Day 19/100 Java
Tags: 100daysofcode
Published: 2022-02-13 11:40:07

After todays sections my brain hurts.

Day 19/100

**Language:**
JAVA

**Time Period Spent:**
2hrs

**Course Taken:**
Udemy: Java Programming Masterclass - Tim Buchalka

**Todays Learning:**
- Arrays
- Array Recap
- Sorting Array
- User input to array
- Forloop recap
- Intro to algorythm

**Additional Notes:**
Starting off a new section today, arrays. Not only have we based the first two episodes of the course on arrays and a challenge, which consisted of getting user input of numbers to fill an array, but additionally we printed the results with forloops and print statements. The issue came when we got into the challenge, where we created input and output of the array but also creating a sorting algorithim. Simple algorithem of sorting the numbers by decending order, in principle its easy but my understanding of Java so far where increasingly is getting better, it is currenly quite low in consideration. Going through this sorting algorithem I was not able to complete the challenge, after spending some time googling and understanding how this was created, I cannot replicate it but at least I understand the consept of it.
Day 20/100 Java
Published: 2022-02-13 11:36:01

Satisfied with progress.

Day 20/100

**Language:**
JAVA

**Time Period Spent:**
2hrs

**Course Taken:**
Udemy: Java Programming Masterclass - Tim Buchalka

**Today’s Learning:**
- Reference Types vs Value Types
- More Algorithms

- Code Challenges:
	- Minimum Element Excersise
	- Reverse Array Challenge
	- Reverse Array Exercise

**Additional Notes:**

Today has been quite possibly the most motivated I have found myself. Not going to lie, yesterday's events made me question if this was for me as I did not gather the concept of what the tutor was doing. Although I know what the outcome was and why he wrote what he did, I did not understand it to a level of being able to craft something like this myself.

I pushed through it with persistence. The outcome of today has taught me that you need to come back sometimes with a fresh mind to tackle the problem at hand. Today’s challenges were based on finding only the minimum number of a users input and reversing a given array no matter the size or numbers added. I am satisfied that I can tackle the oncoming issues ahead. Battling the urge of wanting to look at the answer sheet and staring blankly at the screen for 20 minutes, I have successfully come out on top. On to tomorrow’s challenge!
Understanding how virtual DOM works in React
Tags: react, javascript, webdev, tutorial
Published: 2022-02-13 10:44:41

# DOM

To understand virtual DOM, we must know how DOM works.

When you enter a URL in the browser, the browser requests the specified server send back files, including HTML, CSS, and JS files. Just like where you need to compile a C file with a compiler before running, the browser first renders HTML into a DOM (Document Object Modal) tree using the HTML parser.

DOM is a tree structure where each node is an HTML element, HTML attribute, plain text, comments, etc. You can check out how HTML gets translated into DOM using this tool.

![HTML translation into DOM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o2jvxg50csi0lchrzwlh.png) 

The browser then binds CSS styles and JS events with specified nodes in the DOM tree, paints the render tree, and finally displays the real web page you see on the screen.

For example, JS can access nodes in the document with functions like `document.getElementById()`

![Browser Rendering Workflow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/belj1i573fnn7qk7hcwd.png)

# Virtual DOM

When for example, the text value in a `<p>` tag changes, the browser re-renders the HTML into a new DOM containing all original nodes with the updated value. This is time-consuming. React, on the other hand, first converts HTML into a JS object as a virtual DOM.

For example,

```html
<div id="app">
  <p class="text">hello world!!!</p>
</div>
```

would be

```javascript

{
  tag: 'div',
  props: {
    id: 'app'
  },
  chidren: [
    {
      tag: 'p',
      props: {
        className: 'text'
      },
      chidren: [
        'hello world!!!'
      ]
    }
  ]
}
```

Since the browser only understands the traditional DOM, React must render the virtual DOM into DOM first. We can write a simple version of `render()` in the React library.

```javascript
function setProps (element, props) {
  Object.entries(props).forEach(([key, value]) => {
    element.setAttribute(
      key === 'className' ? 'class' : key,
      value
    )
  })
}

function render(vdom) {
	if (typeof vdom === 'string' || typeof vdom === 'number') {
		return document.createTextNode(vdom);
	}
	const { tag, props, children } = vdom
	const element = document.createElement(tag);
	setProps(element, props);

	children.map(render).forEach(element.appendChild.bind(element));

	vdom.dom = element;
	return element;
}
```

When a property in the JS object (a component in the virtual DOM) changes, React uses a diff algorithm to compare the new virtual DOM with the old one, and only re-renders the updated nodes.

---

Although computing diff and rendering virtual DOM to DOM is slower than directly rendering HTML to DOM, the cost of re-rendering the whole DOM is usually much larger than updating the necessary nodes.

As a result, React gives better re-render performance using virtual DOM than plain HTML and JS with the traditional DOM. The virtual DOM is a perfect design for React in modern web projects where state changes and components re-renders happen a lot.