teleren/devto huggingface dataset:
100 algos in 100 days (Day 10-13)
Published: 2021-06-14 19:10:48

Cheating a bit ... and not technically an algo.

I tried the gilded rose refactoring kata again. If you want to have a go here is a repo with a starter pack in all different languages: 
https://github.com/emilybache/GildedRose-Refactoring-Kata

The below is where I got to (with a pleasing amount of test coverage):

<code>
export class Item {
  name: string;
  sellIn: number;
  quality: number;
  constructor(name: string, sellIn: number, quality: number) {
    this.name = name;
    this.sellIn = sellIn;
    this.quality = quality;
  }
}

export class Shop {
  items: Item[];
  constructor(items = []) {
    this.items = items;
  }

  updateQuality() {
    for (let i = 0; i < this.items.length; i++) {
      const currentItem = this.items[i];

      if (currentItem.name === 'Sulfuras, Hand of Ragnaros') {
        continue;
      }

      if (currentItem.quality >= 50) {
        currentItem.sellIn = currentItem.sellIn - 1;
        continue;
      }

      if (
        currentItem.name != 'Aged Brie' &&
        currentItem.name != 'Backstage passes to a TAFKAL80ETC concert'
      ) {
        //handle depreciating quality
        if (currentItem.quality > 0) {
          currentItem.quality = currentItem.quality - 1;
        }
      } else {
        //handle increasing quality
        currentItem.quality = currentItem.quality + 1;
        if (currentItem.name == 'Backstage passes to a TAFKAL80ETC concert') {
          this.handlePasses(currentItem);
        }
      }

      currentItem.sellIn = currentItem.sellIn - 1;

      //handle expired stuff
      if (currentItem.sellIn < 0) {
        if (currentItem.name === 'Aged Brie') {
          currentItem.quality = currentItem.quality + 1;
          return this.items;
        }

        if (currentItem.name === 'Backstage passes to a TAFKAL80ETC concert') {
          currentItem.quality = currentItem.quality - currentItem.quality;
          return this.items;
        }
        // check with first code if flipping them helped??! or has it changed how this works?
        if (currentItem.quality > 0) {
          currentItem.quality = currentItem.quality - 1;
        }
      }
    }

    return this.items;
  }

  private handlePasses(pass: Item) {
    if (pass.sellIn < 11) {
      pass.quality = pass.quality + 1;
    }
    if (pass.sellIn < 6) {
      pass.quality = pass.quality + 1;
    }
  }
}
</code>


Struggling a bit with this challenge over the weekend!
June 14, 2021
Published: 2021-06-14 19:01:44

Today, I decided to review what I learned about making APIs using .NETCore, and I decided to use the Microsoft documentation to lead the way. 

It was super helpful! This tutorial can be found [here] (https://docs.microsoft.com/en-us/learn/modules/build-web-api-aspnet-core/).

This one was especially useful because it provides more line by line explanations. This helped me understand Controllers and Models more clearly. 

Here's a definition of models provided by the tutorial: 
> A model class is needed to represent a pizza in inventory. The model contains properties that represent the characteristics of a pizza. The model is used to pass data in the web API and to persist pizza options in the data store. In this unit, that data store will be a simple local in-memory caching service. In a real-world application, you would consider using a database, such as SQL Server, with Entity Framework Core.

The definition for controller: 
> A controller is a public class with one or more public methods known as actions. By convention, a controller is placed in the project root's Controllers directory. The actions are exposed as HTTP endpoints inside the web API controller.


These are just a couple of the informational tidbits I found to be really useful. I feel like I have a better general understanding of how API creation is working behind the scenes with this framework.
Advanced AI eBooks Bundle by Morgan Claypool
Tags: ai, datascience, deeplearning, programming
Published: 2021-06-14 19:01:44

![Advanced AI eBooks Bundle by Morgan Claypool](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rsyu5l2laky5dqsmwvzo.jpg)

[Advanced AI eBooks Bundle by Morgan Claypool](https://www.humblebundle.com/books/ai-morgan-claypool-books?partner=indiekings)

If the potential and possibility of artificial intelligence has always fascinated you, get ready for the perfect bundle to fill the next few weeks with!

Humble Bundle teamed up with Morgan & Claypool to bring you insights into AI and its applications into autonomous vehicles, conversational systems, and more! Pick up this bundle and you’ll enjoy discovering eBooks like Why AI/Data Science Projects Fail: How to Avoid Project Pitfalls, Deep Learning Systems: Algorithms, Compilers, and Processors for Large-Scale Production, and Conversational AI: Dialogue Systems, Conversational Agents, and Chatbots.

Your purchase of this bundle helps support a charity of your choice.

This bundle launched on June 14 at 11:00 am PST and lasts through July 05, 2021. Pay what you want and support charity!
Connect to SFTP server using command line on macOS
Tags: sftp, ftp, macos
Published: 2021-06-14 18:56:47

Hi there!

It's here how I connect to sftp server using only command line tool from macOS:

`sftp -P replace_with_server_port -i replace_with_your_ssh_private_file replace_with_server_username@replace_with_server_host`

Maybe you will be asked about password you set for ssh private key:

`Enter passphrase for key '.ssh/ssh_private_file_path'`:

And then after you type the password you will see that:

```
Connected to server_host:
sftp>
```

It's done! You're in.

Now if you want to send a file you need to type:

`sftp> put your_file_name_with_extension`
Git ~ Workflow 
Published: 2021-06-14 18:40:04

-Fork and clone code repository (assignment)
```
git clone (url of clone taken from github repository)
```

-Make regular commits while conducting work
```
git add . 
git rm --cached to unstage
git status .
git commit .
git checkout -- <file> discards changes to working directory. reverts the specified file to last commit state.
git log - 
git history -
git remote - specify parent repo where you forked from
```

-Push your code (after each commit)
```
git commit .
```

-Create your final commit with the message "Assignment Complete"
```
git push origin master
```

-Submit your final code via a Pull request in GitHub
   done on Github
```
pwd - print working directory (displays the path)
mkdir - make directory within
touch - access or "touch" a file - if DNE, file will be created
if does exist, timestamp of last access to the file will be updated
```
Devs Java: Oportunidade de Formação
Tags: devpride, java
Published: 2021-06-14 18:34:39

Fala Devs,

Sou novo aqui, e caso não possa essa tipo de postagem, por favor, me avisem.

Hoje venho trazer uma OPORTUNIDADE para quem ainda não possui experiência como Dev.

Sou Tech Recruiter na ShareRH, e estamos com um programa em andamento: o PideDev.

O PrideDev é um programa criado com o objetivo de aumentar a inclusão de pessoas da comunidade LGBTQIA+ na área da tecnologia, oferecendo capacitação, qualificação e oportunidades de desenvolvimento profissional!

Nesta 1ª edição do programa, contaremos com a trilha oferecida pela Share RH na linguagem Java, a segunda linguagem mais popular do mundo segundo a index TIOBE (2021). Além disso, as pessoas que mais se destacarem na trilha, poderão ser direcionadas ao processo seletivo de empresas parceiras!

Teremos um processo seletivo para definir quem serão as pessoas que irão participar gratuitamente do programa de formação de 84 horas. Será aplicado um teste técnico para te conhecer melhor e, as pessoas que tiverem os melhores resultados, passarão por entrevistas individuais que vão definir a turma aprovada.

Qual é o perfil?
Pessoas da comunidade LGBTQIA+ que possuam uma base de conhecimento em programação e que estejam buscando formas de aprimorar seu desenvolvimento em Java. Além disso, precisam ter disponibilidade de:

1. Participar de 75% das aulas que irão acontecer de 19/07 a 14/08 (seg. a sex., das 19h às 22h; sábados, das 09h às 16h)
2. Ter acesso à internet de banda larga e possuir computador para acompanhar as aulas
﻿3. Ter muita vontade de aprender e ser um #PrideDever!

Vamos juntos codar um futuro mais inclusivo?

Qualquer dúvidas, entre em contato comigo:

https://www.linkedin.com/in/gabrielsilva1/
gss@sharerh.com
+55 (28) 99934-7011
1NF and 2NF
Tags: database, computerscience
Published: 2021-06-14 18:17:24

**Normalization**: It is a way to reduce/minimize data redundancy (repetition of data). It can be achieved by splitting the table into many tables.

**First Normal Form (1NF)**:
-> It is the property of converting ER Diagram into the Relational Database.
-> The Relational Database is implicitly in 1NF.
-> All attributes should be atomic [ only one value in a tuple is allowed].

**Example**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xriheeqs7h5usyss8c0i.png)
Here, SMobile has multiple values which are not allowed. They have to be taken individually.

**Approach-1**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0eun6yu9pt54uu5aibg2.png)
This approach creates a lot of redundancy in the table. Therefore it is not a suitable approach.

**Approach-2**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dkmeqihmwlef8n1ktpq7.png)
This approach also has redundancy but less when compared to the previous Approach. This is because the tables have now been split into two.

**Prime Attributes(Key):**
Those attributes which participate in the Candidate key.
**Example 1**
R(ABCD), CKs: {A, BD}
Therefore PA = {A,B,D}

**Example 2**
R(ABCDEFG), CKs: {AB, BC, CD, F}
Therefore PA = {A,B,C,D,F}

**Non-Prime Attributes(Non-Key):**
Those attributes which do not participate in Candidate Key.
**Example 1**
R(ABCD), CKs: {A, BD}
Therefore NPA = {C}

**Example 2**
R(ABCDEFG), CKs: {AB, BC, CD, F}
Therefore NPA = {E,G}

**Partial Dependency:**
If subset of any Candidate Key derives a non-key attribute.

**Example**
R(ABCD) FDs : {AB->CD, B->D}
CK => {AB}
B->D, B is a subset of AB and it derives non-key, therefore it is a partial dependency.

**Second Normal Form (2NF):**
=> If a relation 'R' is in **1NF** (and)
=> If every **non-prime attribute** is fully dependent on any complete CK (or) No **Partial Dependency** exists.

**Allowed in 2NF:**
=> Non-Prime determines Non-Prime
=> Non-Prime determines Prime
=> Prime determines Prime

**Not-Allowed in 2NF:**
=> Prime determines Non-Prime
Common Error: Accidentally Mutating State in React
Tags: react, javascript
Published: 2021-06-14 18:01:07

In React, the state is immutable. In simple terms it means that you should not modify it directly. Instead a new object should be created to set the state using `setState`.

Here are two examples.

#### Modifying the state directly - Not Acceptable
```js
onChange(event) {
  this.state.value = event.target.value
}
```

#### Using `setState()` - Acceptable
```js
onChange(event) {
  this.setState({ value: event.target.value })
}
```

The above is clear to almost all react developers. However, developers still make the above mistake accidentally. Have a look at the code snippet below.

#### Common Mistake
```js
const [arr, setArr] = useState([])

const handleSubmit = (event) => {
  event.preventDefault()
    
  arr.push("New Item")
  setArr(arr)
}
```

In the above code snippet the developer did use `setArr` but still modified the `arr`. The `.push()` modifies the `arr`.

#### Why will the above code not work?

React compares the previous state with the updated state to decide if the component needs to be re-rendered. Modifying the state directly will disturb this process. As a result the component will behave unexpectedly. In some cases not re-rendering at all even though the state has been modified.

The above mistake is independent of functional or class components. 

#### Solution
```js
const [arr, setArr] = useState([])

const handleSubmit = (event) => {
  event.preventDefault()

  setArr([...arr, "new value"])
}
```

The spread syntax creates a copy of the array. Hence we are not modifying the original array.

#### Subtler Way of Making the Same Mistake
```js
const [obj, setObj] = useState({
  key: 'value',
})

const handleSubmit = (event) => {
  event.preventDefault()

  const tempObj = obj
  tempObj.key = "new value"
  setObj(tempObj)
}
```

In the above snippet, it may seem at first that we made a copy of `obj` and modified that but in JavaScript the objects copied through reference. In other words, `tempObj` and `obj` are the same. Any changes made to `tempObj` is also reflected on `obj`.

### CodeSandbox Demo

{% codesandbox mutating-state-functional-component-w3cpt %}
Uso básico de git
Tags: git, workflow, tips, ptbr
Published: 2021-06-14 17:45:36

# Mais um post de git?

Quando eu estava aprendendo git, o mais comum era ter que pesquisar mais uma vez comandos que já havia utilizado, e com a diversidade deles acabava me perdendo ou me confundindo ainda mais.
Criei esse pequeno "esquema" para que eu pudesse consultar facilmente, coloquei todos os comandos que pessoalmente mais utilizo, e caso apareça algo novo eu simplesmente adiciono à minha lista. Sem ter que olhar trocentos comandos/sites até encontrar exatamente o que preciso.

Me ajudou bastante à decorar os comandos básicos e espero que possa ajudar alguém também. Aqui vão os comandos:

## Criar uma branch

```
git checkout master
git pull
git checkout -b <nome_da_branch>
```

## Criar uma branch a partir da branch atual

```
git checkout master
git pull
git checkout <branch_que_já_existe>
git checkout -b <nome_nova_branch>
```

## Deletar uma branch local

```
git branch -d <nome_branch_local>
```

## Renomear uma branch local

```
git checkout <branch_que_sera_alterada>
git branch -m <novo_nome>
```

## Enviar uma branch local para o repositório remoto

```
git push origin <nome_branch_local>
```

## Deletar uma branch no repositório remoto

Para deletar uma branch remota, é preciso usar o comando "git push" com a opção "--delete":

```
git push origin --delete <nome_branch_remota>
```

## Merge na branch local a partir de master

```
git pull origin master
```
Machine Learning Applications: Computer Vision
Tags: article
Published: 2021-06-15 10:06:16

---
title: Machine Learning Applications: Computer Vision
published: true
date: 2021-06-14 17:36:00 UTC
tags: Article
canonical_url: https://reinforcement-learning4.fun/2021/06/14/machine-learning-applications-computer-vision/
---

Computer Vision is a field of Artificial Intelligence that includes methods and techniques to enable computer programs to interpret and understand visual information, including images and videos.

Typical Computer Vision tasks are image classification, object recognition, and Optical Character Recognition.

The availability of large amounts of visual data, and computational power, combined with the advance …

[Continue reading Machine Learning Applications: Computer Vision →](https://reinforcement-learning4.fun/2021/06/14/machine-learning-applications-computer-vision/)
uFincs Update #10
Published: 2021-06-14 17:30:31

Today, on matters concerning my existence, is a short uFincs update. Nothing crazy going on at the moment, so I won't bore you with another multi-thousand-word post.

# Last Time

During [uFincs Update #9](https://www.onmattersconcerningmyexistence.com/p/ufincs-update-9) I went into a lengthy discussion trying to figure out what the next steps for uFincs were going to be. I eventually settled on switching out of marketing mode to get back into development mode. This way I'd be able to focus on building the next big feature: the import rules system.

That is the main subject of today's update.

# Import Rules System Progress

At this point, the rules system is already all planned out and I'm deep into implementation work. As usual, the frontend work is taking the longest, although it makes extra sense this time around considering the grandiose scope of this feature (or at least, how I've envisioned it).

I had initially estimated this as being a 2-4 week adventure, but I think I'll revise that to 4-6 weeks if for no other reason than testing this whole thing is going to be a pain (lots of new moving parts).

Nothing to show off at the moment, considering all of the component work I've been doing has been in Storybook, but I'm sure there'll be something to play with by the next update.

# Other News

One of the other things I mentioned in [uFincs Update #9](https://www.onmattersconcerningmyexistence.com/p/ufincs-update-9) was that, although I wanted to switch off marketing mode, I still wanted to keep writing some content marketing-type blog posts to fill my downtime.

There is one post in particular that I've been working on for a good while now and it's turned into an absolute monster. The current working title is "How I (Re)designed uFincs" and it goes into the story of how I spent 2020 redesigning uFincs from the ground up. If you're interested in reading about the intricacies of UI/UX design, then you have this post to look forward to!

And with that tease, I have to unfortunately tell you that it's probably not coming out anytime soon. While it is still being edited at this point, it's one of those 'marketing' posts that I can use to really drum up awareness of uFincs. As such, it probably won't come out until my next marketing push, which probably won't be till much later in the summer.

And with that, I have fulfilled my non-contractual obligations to post a uFincs update.

Till next time!
Quick tips about Navigation in Webstorm or other IDEs of Jetbrains
Published: 2021-06-14 17:22:42

I have been using Webstorm and PhpStorm for more than 1 year and I feel that Webstorm is the best IDE for the web developer (at least for me). I have reasons to say that because the Jetbrains IDEs are always useful, smart, and Jetbrains understands what the user and the customer need. So, we should use it smarter. **I hope that you will achieve some good tips in this article.**

In this article, I will use Create React App for demos because It's popular and easy to implement. You can use anything you want as long as It's can 😸

#### Go To Declaration

> Navigate to the initial declaration of the instantiated class, called method, or field.

The default with Linux and Window is **Ctr B **or you can cursor in the position you need to move and *Right-click > Go to > Declaration and Usages*

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1623690168764/bVyg-b_mw.png)

#### Move Statement Up/Down/Left/Right

![ezgif.com-gif-maker (2).gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1623690749233/jOjwKCK1F.gif)
It's so helpful if you frequently work with HTML. Not only for HTML but also for Javascript or another language.

#### Switch file with Alt

![ezgif.com-gif-maker (3).gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1623690796500/Ks6VTV-Uy.gif)

Yeah, It's easy to use by type** Alt + Left or Right Arrow** to switch.
We can reduce a little of time by this movement.

#### Select file in Project View

![ezgif.com-gif-maker (4).gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1623690830385/-jMGylKWe.gif)

So useful, many colleagues want to use this function but they don't know the keyword to search. Try doing this and you will like it from the first view.

> There are a lot of other tips (finding, plugins…). I can introduce to you when I have the time and add more to this article.

Thanks!!!
What is your error budget?
Tags: microservices, microservicesgovernance, errorbudgets
Published: 2021-06-14 16:48:18

Part of the reason I built [The Slate](https://www.theslate.co) was because I've seen this common pattern too many times.

Service A (that people interact with) relies on Service B and C. Service B & C constantly fail, but Service A gets a bad rap with their users. The teams responsible for B & C don't know about the impact they are having on Service A. The team running Service A doesn't know Service B or C's error budgets, which is much lower. 

## What's an error budget?
Pretty simply, an error budget is the maximum amount of time that a team is "happy" to allow a system or service to fail. Usually you'll see it represented as a percentage of availability (e.g. 99.99% uptime!). 

If you were to break down the percentages per month, you'd get; 
* 99.000% is 7h 18m 18s per month 
* 99.900% is 43m 50s per month
* 99.990% is 4m 23s per month 
* 99.999% is 26s per month

Some of these can be pretty tough targets to hit, that might not be required for your business. I'd say a marketing site could easily handle an error budget of 99.9%. An e-commerce site might need to be 99.99%.

Just remember, five 9s (99.999%) can be significantly more expensive than four 9s (99.99%) to achieve. Particularly if you don't have the budget, resources or business support to achieve them.

## What about those upstream services?

The services you depend on might have a different error budget. Like in my example earlier, Service A had a budget of four 9s. They had the budget, processes and resources in place to achieve that. But the other services had error budgets of two 9s.
 
As the owner of Service A, you have a choice. You might be able to build Service A to be resilient of downtime for Service B and/or C. But if you can't, then you've got two options;
* Reconsider your error budget to reflect your dependancy's budget
* Speak to the other Service's teams about their error budgets, and if it is possible to improve it.

# Who is happy with downtime?!
No one really is. But you have to be realistic, not every service is, or should be, five 9s. Outages happen. How we respond to them, learn from them and adapt to them is the vital part here. 

The first step in dealing with them however is being transparent about what each service's error budgets are, and how they might have an impact on dependant service. 

This one very small aspect of the governance of your microservices, but it can easily increase your reliability and resilience.