Posts by yoyo • 671 points
31 posts
-
3
votes2
answers57
viewsA: What is the difference between onDestroy and the function returned by onMount callback in Svelte?
The difference is that the function returned by the callback of the onMount: onMount(() => { console.log('Componente montado') /* função que será executada após a destruição do componente: */…
-
3
votes2
answers57
viewsQ: What is the difference between onDestroy and the function returned by onMount callback in Svelte?
Svelte provides the function onMount, which is executed just after rendering the component and takes a function per parameter: onMount(() => { console.log('hello') }) If the argument function…
-
0
votes0
answers56
viewsQ: How to allow a method to execute another method of the same Typescript class?
I am working with a class that manages the registration and login of new users. Imagine that this class has two methods, the first isCharacterNameRegistered() checks if the nick already exists, and…
-
4
votes2
answers67
viewsQ: What does the "jsx" prop do in Next.js' jsx <style?
In Next.js, we can insert direct styling into the component through the tag <style jsx>, as in the example: function Vitro() { return ( <div className="vitro"> <style jsx>{` .vitro…
-
0
votes1
answer72
viewsA: How to expose the son’s Tates to the father?
You can use the React context API. The flow of information from React always goes from top to bottom, from parent to child. To provide a state to several components, from the API context, you must…
-
1
votes4
answers276
viewsA: Prime numbers with Python
Complementing the other answers, it is also worth commenting that half of the iterations of for i in range(1, number): are useless. Note that no number is divisible by one greater than its half. To…
-
1
votes1
answer43
viewsQ: Why isn’t my function changing the background as expected?
I’m trying to change the transparency of mine header based on the scroll of the screen. To do so, I created a eventListener of scroll triggering the following function: function solidHeader(){ if…
-
2
votes2
answers185
viewsA: Beautifulsoup: Catch text inside table
Kleyton, this happens because the request does not return the full HTML right away. Let’s follow with what you did in the code: import requests from bs4 import BeautifulSoup url =…
-
0
votes0
answers22
viewsQ: Why can’t I access the variable outside the while loop in Node.js?
I have a module that takes public information from the TJPB from the number of a process. This information can be at any of nine different addresses. Therefore, I make requests to each of these…
-
0
votes1
answer213
viewsQ: How to increase bar thickness in Chart.js?
I am using Chart.js in React and would like the bars on my chart to be thicker without piling up. Next is my component rendering the graph: import React from 'react'; import { HorizontalBar } from…
-
1
votes2
answers58
viewsA: problems with the Return function
First you have to understand that return is a reserved python word, which serves to return a value and terminate the function. So the return is executed, the function to. Therefore, its function…
-
-1
votes2
answers352
viewsA: How to delete negative elements from one list and add them to another in python?
Your program presents 3 main problems: Notice that you are filling in the list X more than once. This is redundant. You are iterating over a list and changing it at the same time, and that is…
-
2
votes1
answer88
viewsQ: How to access a function within a python dictionary?
We have the following functions: def oi(): print('oi') def ola(): print('ola') Now let’s store them inside a dictionary as follows: saudacoes = { 'chegada':{ 'simples': oi(), 'cult': ola(), } } I…
-
1
votes2
answers47
viewsA: Login function does not access the register, which has already been entered
I made some changes to the code proposed by @Lucasv75, I suggest you see the comments from time import sleep grupos = dict() opções = ["1 - Logar","2 - Cadastrar","3 - Sair"] def Logar(pessoas):…
-
0
votes1
answer56
viewsQ: Wrong numbering of data frame lines in R
I cleaned a dataframe and, after processing it, the result was a table with all the rows with the wrong numbering. Notice that the first line has the number 90, the second 92 and so on. I want it to…
-
-3
votes2
answers157
viewsQ: How to optimize this code?
A music loop is an excerpt of music that has been composed to repeat continuously (i.e., the excerpt starts again every time it reaches the end). Loops can be scanned for example using PCM. PCM,…
-
0
votes1
answer41
viewsQ: Why can’t I trigger a function in a <div/> daughter tag in React?
I am using the Unform package to create a form in React and have the following function that renders the form: function FormularioCliente() { function handleSubmit(data) { console.log(data); }…
-
-1
votes1
answer72
viewsQ: How do I make the React application scroll down if the content doesn’t fit on the screen?
I thought it was natural that when the contents of HTML did not fit on the screen, the browser would automatically allow scrolling for easy viewing. In the following case, for example, I have the…
-
0
votes1
answer54
viewsQ: CSS does not access HTML subclasses in React
I’m having trouble accessing one class within another. I have the function Banner: import React from 'react'; import './Banner.css'; function Banner(props) { return ( <div className="Banner">…
-
1
votes1
answer201
viewsQ: Why doesn’t React accept camelCase to name components?
I was preparing a component whose only function was to export a tag <p> containing a text. I naturally created a function that exported the text: import React from 'react'; function…
-
2
votes1
answer152
viewsQ: How to transform each digit of a number into an element of a vector in R?
For example: numero <- 516481 how can I transform each digit of that number into an element of an array, in order to access them by index? For if numero is a vector with each element being a…
-
4
votes1
answer101
viewsQ: How to globally save the output of a function in R?
I have trouble saving function output in R. In the following code, for example, I create an array representing a sudoku game: quantLinhas <- readline(prompt = 'insira o número de linhas do…
-
0
votes3
answers137
viewsA: Problem reading readline keyboard input on R
If you want all the code to be executed at once, without the id value being assigned to the part, you can try a functional approach by transferring the method into a function. Thus: verificadorIdade…
-
5
votes2
answers195
viewsQ: What is the logic behind the switch case in Javascript?
I started my studies in Javascript and had contact with the switch, following example: let permissao; switch (permissao){ default: console.log('sem acesso'); break; case 'estagiário':…
-
1
votes2
answers172
viewsA: How to remove NA from a dataframe in R?
You can use the [ ], which are a very powerful and underestimated indexing tool, like this: df[is.na(df)] <- ''
-
0
votes4
answers3254
viewsA: GIT error: pathspec 'master' Did not match any file(s) known to git
Try deleting the folder manually, then open the terminal at the place where it used to be and run: git clone link instead of "link" put the cloud link to your repository. If you use Github just go…
-
4
votes1
answer130
viewsQ: (Language R) How to make the axis of the graphs more detailed in ggplot2?
I would like to know how to add more numbers to my y axis, so that the bottom grid has more horizontal lines. Note that in my chart, the Y-axis only shows the markings every 500 units (0, 500, 1000…
-
0
votes2
answers298
viewsA: How to put Y-axis variables in ascending order in ggplot
Hello, first of all, use the "reorder" function within the y parameter. I will also take the opportunity to suggest a better way of organizing your code, to facilitate even your understanding and…
-
1
votes1
answer110
viewsQ: (R Language) How to ask a user for data frame input?
I’m doing a function that traverses data frames in search of non-numerical values. To do so, I have to ask the user to provide a data frame as input. Thus, I write: data.frame <- readline(prompt…
-
0
votes1
answer53
viewsQ: Wrong return when grouping rows from a data frame
I am working with a dataframe and I aim to group the lines that have the same content in the first column (Course, which are factors). Therefore the following commands: library(dplyr) data.test2…
-
3
votes2
answers124
viewsQ: LANGUAGE R: Error "Error in course[[1:98]] : recursive indexing failed at level 2" when trying to search the items in a list, how do I resolve?
I have a "course" list in R, it consists of 98 items, each item has one or two variables of type Character. I want all the first variables of each item in the list, but when typing the command:…