teleren/devto huggingface dataset:
typetester - typing practice for the command line
Tags: c, programming
Published: 2022-07-28 23:35:00

Typetester lets you to practice typing from the command line.  Text passages are loaded into a text file, and statistics are generated after every run


Add a passage into `a.txt`, compile and run `./main`.  Once completed, the results will appear like so:


![stats](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fepjkf7135lbe8ygkphi.jpg)

## Terminal Modes

In order to read input, `typetester` chnages terminal settings using `termios.h`.  This library contains flags that control various functions of the terminal, such as the input processing, output, etc.  A full list of them can be found [here](https://man7.org/linux/man-pages/man0/termios.h.0p.html).  For this program, canonical mode and output echo were disabled.  *Canonical mode* is the default mode of most terminals.  Input is available line-by-line, usually after the user hits Enter.  This also allows the user to edit the line, which is useful for typing commands.  

In non-canonical mode, user input is available as soon as the character is typed.  In the main loop of the program, all we have to do is check if each character equals the current character in the passage.

```c
void setup_terminal()
{
        struct termios options;
        tcgetattr(STDIN_FILENO, &options);
        // enable canonical mode
        options.c_lflag &= ~(ICANON);
        // disable echo
        options.c_lflag &= ~(ECHO);
        tcsetattr(STDIN_FILENO, TCSAFLUSH, &options);


}
```

## ANSI Cursor Controls

When a session starts, the cursor is placed at the beginning of the passage.  In order to get the correct cursor position, we save it by sending `ESC 7` to stdout.  Then after printing out the text passage, we restore the cursor position with `ESC 8`.  

```c
// save current cursor position
write(STDOUT_FILENO, "\e7", 3);
char *text = read_from_file("a.txt");
printf("%s\n", text);
// restore saved cursor position
write(STDOUT_FILENO, "\e8", 3);
```

## Summary

I made this project to experiment with terminal settings, in addition to making something that I normally have to access through the browser.  This project can be found at [this github repository](https://github.com/gbafana25/typetester).
Facade Pattern - React
Tags: react, programming, tutorial
Published: 2022-07-28 22:46:33

Existem diversos padrões de projetos que ajudam a manter o código limpo e mais legível, e neste post irei mostrar como usar o Facade Pattern para criar uma função que busca os personagens fornecidos pela SWApi.

O Facade Pattern é um dos padrões mais famosos do GoF (_Gang of Four_), e é do tipo estrutural. A maior vantagem dele é deixar a manutenção e uma possível refatoração muito mais simples, tanto do Front End, quanto do Back End.

_No exemplo eu utilizei o axios, mas você também pode utilizar o fetch._

##Configuração padrão do axios, adicionando a url da SWApi.
```
import axios from "axios";

export default axios.create({
  baseURL: 'https://swapi.dev/api/',
  headers: {
    'Content-Type': 'application/json'
  }
})
```

##Função getFetch

```
import axios from "../api/axios";

export default async function getFetch (url) {
    const response = await axios.get(url)
    return response.data
}
```

##Consumo da SWApi

```
import getFetch from "./utils/getFetch";

function App() {
  const [characters, setCharacters] = useState([]);
  const [loading, setLoading] = useState(false);

  async function getCharacters() {
    try {
      setLoading(true);
      const { results } = await getFetch("people/");
      setCharacters(results);
    } catch (error) {
      throw new Error(error);
    } finally {
      setLoading(false);
    }
  }

  useEffect(() => {
    getCharacters();
  }, []);

  return (
    <div className="App">
      <ul>
        {loading && <p>Carregando...</p>}
        {characters &&
          characters.map((character) => (
            <li key={character.name}>{character.name}</li>
          ))}
      </ul>
    </div>
  );
}
```

##Resultado final no navegador
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/81k77by2rcvylygheouk.png)

[Link do projeto no Github](https://github.com/IsaacJBS/facade-pattern)

Minhas redes:
[Linkedin](https://www.linkedin.com/in/isaac-jbs/)
[Twitter](https://twitter.com/isaacjbs)

Espero ter ajudado a tornar seu desenvolvimento mais fácil e rápido.
<img width="100%" style="width:100%" src="https://media.giphy.com/media/7DzlajZNY5D0I/giphy.gif">
LeetCode Problem Solving
Tags: programming, javascript, algorithms, database
Published: 2022-07-28 22:44:06

**

## 2. Two Sum
**
var twoSum = function (nums, target) {
    for (let i = 0; i < nums.length; i++) {
        let remaining = target - nums[i]
        for (let j = i + 1; j < nums.length; j++) {
            if (remaining === nums[j]) return [i, j]
        }
    }
    return false
};
console.log(twoSum([3, 2, 4], 6)) //[1,2]

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

**

## 11. Container With Most Water
**
var maxArea = function (height) {
    let total = 0
    let start = 0
    let end = height.length - 1
    while (start < end) {
        let heights = Math.min(height[start], height[end])
        let width = end - start
        let current = heights * width
        total = Math.max(total, current)
        if (height[start] <= height[end]) {
            start++
        }
        else {
            end--
        }
    }
    return total
};
console.log(maxArea([1, 8, 6, 2, 5, 4, 8, 3, 7])) //49

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ije4yc2etjvabqzcncf9.png)
How a Trained Therapist Diagnoses Healthy Dev Teams w/ Engineer & Entrepreneur, Kelly Vaughn
Tags: devops, productivity, podcast, management
Published: 2022-07-28 21:58:21

Not only is Kelly Vaughn one of the pioneers in building thought-leadership content for the developer community, she’s one of the rare programmers who comes to the craft with the background of a trained therapist.

From knowing what content devs need to grow to being able to recognize the cognitive-behavioral impacts of the developer experience, Kelly Vaughn is truly one of our most unique guests to date.

In our conversation, Kelly leveraged her background as a therapist to explore what dev orgs should be doing to recognize developers as unique human beings, with their own feelings, motivations and biases.

A discipline-crossing discussion, this pod is invaluable if you’re thinking about what a healthy dev team should look like as well as how to build one.

{% spotify spotify:episode:6yMgDnuYKOgLE4KY7mWDre %}

## Episode Highlights Include:
* (1:09) Ladybug podcast
* (4:44) Kelly's degree in clinical social work
* (12:37) What not to share on social media
* (19:01) Why burnout is not a "24 hour flu"
* (22:23) Bringing more empathy into 1:1s
* (23:50-31:27) Dealing with Imposter Syndrome, negative self-talk & toxic positivity
* (41:41) Dangers of comparing yourself to others
* (44:51) Importance of building your network as an entrepreneur

## Engineering Insights before anyone else....
*The Weekly Interruption is a newsletter designed for engineering leaders, by engineering leaders. We get it. You're busy. So are we. That's why our newsletter is light, informative and oftentimes irreverent. No BS or fluff. Each week we deliver actionable advice to help make you - whether you're a CTO, VP of Engineering, team lead or IC  - a better leader.*

*It's also the best way to stay up-to-date on all things Dev Interrupted - from our podcast, to trending articles, [Interact](https://devinterrupted.com/event/interact/) & our [community Discord.](https://discord.com/invite/devinterrupted)* 

### [Get interrupted.](https://devinterrupted.com/subscribe/)

![Weekly Interruption](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jj1owca0068hk9f2gd11.png)
What does the frontend dev world need to make better applications?
Tags: webdev, discuss
Published: 2022-07-28 21:47:01

I finished a side project web app recently and am about to come upon a chunk of free time before uni starts again. It struck me how difficult it was to do things like:
- Make an animation performant (lots of CSS properties trigger paint or layout unexpectedly)
- Make components with good keyboard accessibility (not just tabbing), common mobile gesture support, etc.

- Do styling properly (CSS modules aren't quite cutting it, and on the perf side sometimes recalculating styles takes up to 50ms!)

I'd particularly like to improve the performance story in the frontend world but I'd be interested in creating or contributing to anything (build tools, libraries, linters, etc.) that makes it easier for devs to make a nice user experience. I was going to experiment a bit myself with things like shadow DOM, wasm, and web workers to see if those things might be suitable for the mainstream web (for wasm we have yew, for example, but it's niche). I thought that first, I should get the opinion of web devs more experienced than myself.

To repeat the title question: What does the frontend dev world need to make better applications?
Add custom color palettes to GIMP and Inkscape
Tags: design, gimp, inkscape
Published: 2022-07-28 21:43:00

This article explains how the `.gpl` format works, how to create a `.gpl` palette file and import it into [GIMP](https://www.gimp.org/) and [Inkscape](https://inkscape.org/). 

> **Note**: The `.gpl` format is also supported by [Aseprite](https://www.aseprite.org/), [Drawpile](https://drawpile.net/), [Krita](https://krita.org/) and [MyPaint](http://mypaint.org/). 

----

## GIMP's Palettes Format

GIMP palettes are stored using a special file format, in plain text files with the `.gpl` extension. Note that it supports only ASCII characters.

Every palette must have the following structure: 

```
GIMP Palette
Name: <name>
Columns: <number>
# <comment>
  0    0    0  Black
255  255  255  White
# ... 
```

* `GIMP Palette` - it must be the first line of the file.
* `Name: <name>` - sets the name of the color palette.
* `Columns: <number>` - is just an indication for displaying the palette inside GIMP.
* `# <comment>` - comments must start with a `#`. All comments are ignored by GIMP. 
* `  0    0    0  Black` - RGB values for the color followed by the color name.

Here is an simple example: 

```
GIMP Palette
Name: Example
Columns: 5
# A simple example
  0    0    0  Black
255  255  255  White
255    0    0  Red
  0  255    0  Green
  0    0  255  Blue
```

> **Note**: The RGB values don't need to line up. 

---

## Importing the palettes

After you have a color palette in GIMP's `.gpl` format, you can easily import the color palette to start working with it. 

You can also generate `.gpl` files using palettes generators like [Paletton](https://paletton.com/) or download one from [here](https://robert-96.github.io/gimp-color-palettes/).

### GIMP

Copy the `.gpl` file in the folder `/palettes`, which you create in the folder indicated at **Edit ‣ Preferences ‣ Folders ‣ Palettes**.

Restart GIMP to see the new palette in the list.

### Inkscape

Copy the `.gpl` file in the folder indicated at **Edit ‣ Preferences ‣ System: User palettes**.

Restart Inkscape to see the new palette in the list.
Day 603 : Joy
Tags: hiphop, code, coding, lifelongdev
Published: 2022-07-28 21:41:35

_liner notes_:
- Professional : Got a lot done even though it was meeting heavy. Got some answers to questions I had. Updated some documentation and pushed a PR. Pretty much finished up all my tickets for this sprint. Not bad. Sparking some joy going into the weekend.

- Personal : Went through and did my review of the Japanese Radicals in WaniKani and got everything right. Made sure to take my time. Also worked on the feature for my side project https://dwane.in aka https://doingstuff.in. I had Twitter authentication set up from another part of the site so it was straight forward getting it to work on this part.

![Looking at some trees and a palm tree on a beach in Nananu-i-Ra Island, Fiji with the ocean in the background at sunset with the sky going from dark purple to yellow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xq50ztxawg08ir1l5jpn.jpg)

I want to go through some tracks for this week's radio show. I also saw that in WaniKani, I'm going to start learning some Kanji. Pretty excited about that. I'm also looking to get at least the form put on the site and sending data to the backend. There's some form validation checks I want to put in, so we'll see how far I get.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube iL1LwOqxojU %}
We're Hiring! Temos vagas! @Arctouch
Tags: android, kotlin, hiring, mobile
Published: 2022-07-28 21:22:44


Estamos contratando **Android Developer - Senior** brasileiros para nossos projetos, veja um pouco mais do nosso time e o link da vaga:

**Know the Android Team**
We are Androiders! We love to work with every Android project, starting from scratch or getting into a million-users project; running on phones, tablets, watches, TVs, cars, or even in the shower (why not?). Our team comes from different backgrounds, Java, Kotlin-first, web, cross-platform technologies, and that's the beauty of it: you can get a really wide perspective about any Android-related topic. We gather to talk and study new technologies and how/where we can apply them to our projects, always having a cup of coffee, tea, or water (stay hydrated!). There is no one-stack-to-rule-them-all, in the same year you might work with different architectures and technologies. If we could summarize our goal, it would be projects.forEach { project -> project.solution() }. At the end of the day, the Android team strives to build pixel-perfect, user-centered, performant, clean-coded apps, one line of code at a time.
Link: https://bit.ly/3JhmLtB
Introduction
Published: 2022-07-28 21:07:58

Hello everyone,

I'm Irwin, 23yrs old, living in Cincinnati, Ohio but originally from Brownsville,Tx.

I'm currently in the Flex program at Flatiron School, hoping to finish the course by Feb, 2023. My goal is to become a Software Engineer and further my education in C# and game development. 

A couple of the reasons why I chose Flatiron was for it's good reputation and flexibility. 

"If all difficulties were known at the outset of a long journey, most of us would never start out at all.
-Dan Rather"
HackerRank — Problem Solving — JavaScript — Staircase
Tags: javascript, hackerrank, problemsolving, coding
Published: 2022-07-28 21:01:03


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

Its base and height are both equal to n. It is drawn using # symbols and spaces. The last line is not preceded by any spaces. We have to write a program that prints a staircase of size n.

**Solution**

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

**Explanation:**
Step 01: Iterate a for loop.
Step 02: While iterating the loop we need to print the blank spaces and the "#".
Step 03: While printing we need to repeat the blank spaces by n-i number and "#" by the i number of times so that from top to bottom, in each row the blank spaces reduce and the number of "#" increases and it turns into a staircase shape.
Functional programming: a bit of history
Tags: tutorial, computerscience, functional, programming
Published: 2022-07-28 20:50:00

## History of functional programming

Functional programming is a programming paradigm, such as object-oriented, imperative and many other programming “styles”. So, before we start to crack functional programming, let’s learn a little bit about its history.

&nbsp;

## Computer Science background

To made functional programming possible, many mathematical and computer science theories, concepts and researches were published. Functional programming is very attached to math and functions, its roots are in mathematical logic.

Informal logic systems have been in use or over 2000 years, but the first formalization was made only in the middle of the XIX century. *Hamilton, De Morgan* and *Boole* published their works, that were the basis to the formal logic:

- Propositional Calculus;
- Predicate Calculus.

Also, in the XIX century, the number theory was introduced.

In 1936, three different approaches for computability were proposed: *Turing’s* **Turing machines,** *Kleene’s* **recursive function theory** and *Church’s* **lambda calculus.** Turing’s proposal is the foundation of the computer science and programming languages as we know today, and the **recursive function theory** and **lambda calculus** are the backbones of functional programming.

&nbsp;

## The first functional programming language

The first programming languages were created in the late 1940s, Assembly was the first, and FORTRAN was the first high level programming language to become popular; created in 1954. In the next years new programming languages were created, but now high level, and mostly procedural.

As the computers were becoming more popular, new languages appeared, so in 1958, McCarthy created the LISP programming language, which is considered the first functional language in history.

LISP is a very simple language based on recursive functions manipulating lists of words and numbers. LISP is a non-typed language. Besides that, LISP is not considered “purely functional”, because it has some imperative elements.

&nbsp;

## Functional languages nowadays

The functional paradigm has become popular recently, programmers and companies started to use functional languages in their projects more frequently. Some examples of popular functional languages are:

- Elixir
- Haskell
- OCaml
- Clojure

Today, we also have the “multi-paradigm languages”, that are languages that you can code using many paradigms, like imperative, object-oriented and functional. Examples of “multi-paradigm languages”:

- JavaScript
- TypeScript
- Python
Best Joke EVER.
Tags: sql, database, inclusion, lgbtq
Published: 2022-07-28 20:49:51

A male SQL query walks into a bar
It approaches two female tables and asks "Can I `join` you?

hehe


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/krq063no6xyvspxs0k7g.jpg)
Register Discord Slash Commands via the Discord REST API
Published: 2022-07-28 20:39:00

**If you've built a small Discord bot and don't want to register commands through your bot code, you can easily register them manually through the Rest API.**


Firstly, you need an application to make requests from. I personally use [Hoppscotch](https://hoppscotch.io/). Because it's a web application you don't have to install anything. You can also save the requests for later use, which is pretty useful in this case. Of course you can also use a CLI tool like curl. I will use [Hoppscotch](https://hoppscotch.io/)in this demo.

First, let's start with the Guild Application Commands. According to [Discord's documentation](https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands), to bulk overwrite the commands, we need to send a PUT request to `/applications/{application id}/guilds/{guild}/commands` with an array of commands as the body. For test purposes I use this simple payload with just one command. If you want to do something more complicated, take a look [at this table](https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands-bulk-application-command-json-params) in Discord's documentation. This will create a slash Command called test. Keep in mind that there are other types of commands, like message or user commands. If you want to create these, you have to set the type property, the default is set to slash commands so we don't have to set this property.

```json
[
  {
  	"name": "test",
  	"description": "This is a test command!"
  }
]
```

Replace the guild and application id in the url with your application data from the dev portal and put `https://discord.com/api/v10` in the front (v10 is the api version, as of writing this, the latest is v10). You should get something like this: `https://discord.com/api/v10/applications/885151175224201237/guilds/828931295592710195/commands`

Next, put it all into Hoppscotch or the tool you're using to create web requests.

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

Okay, now we've only one thing left. Authorization. Grab your Bot's token and go to the "Authorization" in Hoppscotch. Set Authorization Type to API Key and Pass by to Headers to send your token via the request's headers to discord. Set Authorization as the key and Bot YOUR_BOT_TOKEN as the value.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2bz8cheho5aqpkxpqagx.png)
 
Now, set the request method in the top left from GET to PUT and press send. If you got a `200 OK` and a Json response body with the data of the commands, everything went well.

![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7t7hko3jyt8w0lsurrjm.png) 

If you want to create Global Application Commands, just remove `/guilds/{guild id}` from the url and you should be fine.
My first LeetCode(which I failed, although I had a correct logic in my mind)
Tags: cpp
Published: 2022-07-28 20:16:00

**_LeetCode#242 Anagram Code_**

class Solution {
public:
    bool isAnagram(string s, string t) {
        
       int n1 = s.length();
       int n2 = t.length();
        
        if((n1  > 50000) || (n2 > 50000))
        {
            return false;
    
        }
        if(n1 != n2)
        {
             return false;
        }
        
        //sorting both strings
        sort(s.begin(), s.end());
        sort(t.begin(), t.end());

        for(int i = 0; i <= n2; i++)
        {
             if(s[i] != s[i])
                 return false;
        }
        
      return true;  
    }
};