Posts by Daniel Mendes • 6,211 points
247 posts
-
2
votes2
answers76
viewsA: Select mysql of a ranking
Hugo, To add up the values, you use the SUM of SQL. To bring the last date, you can use the MAX of SQL. To limit to ten records, you can use the LIMIT mysql. And finally, to join the names, in the…
-
1
votes1
answer80
viewsA: python does not have a mysql library.Nector in Xubuntu
Barter, I just did the installation smoothly on Linux, I think you got confused, see: When importing this library into a python font, you do it this way: import mysql.connector But when doing the…
-
0
votes1
answer62
viewsA: REFERENCE ERROR html and Node.js
JCSR, On your GET, you did it this way: response.render('index', { title: 'Node.js com Express' }); But your index expects to receive pessoas (same as empty), and you only sent in the POST, to…
-
3
votes1
answer130
viewsA: How to do a Query ignoring the side spaces of the Column content?
Matheus, You can use the function trim in the field you want to filter inside your Where, something like this: SELECT * FROM Sessao p WHERE trim(p.dc_secao) = 'SECAO DE GELO'; If you have tabs, the…
-
1
votes1
answer125
viewsA: Function Returning Multiple Values in Python 2.7
Jonah, This is happening because when there are two or more returns in a function, Python returns all the data in a tuple (tuple) format, see this example: def multiploRetorno(): return 1,2 multiplo…
-
1
votes1
answer130
viewsA: Transfer content from one Div to another
Luan, You can create a onclick in the textarea, in the case of title-Ef: <textarea onclick"moveDiv(this)" class="titulo-ef" readonly="readonly">asdasd</textarea> Declare the function…
-
3
votes1
answer331
viewsA: How to limit the number of decimals in javascript?
Flash, One option is to use toFixed javascript, see an example with your code: $(document).ready(function() { $(".operator").on('click',function() { let total = $("#product1_base_price").val() *…
-
1
votes1
answer71
viewsA: Create resulting strcut in C
Pacoca, There are several problems in your code, let’s go in parts: The use of the function isdigit, this function takes an integer and you are sending even float to it: while…
-
0
votes2
answers37
viewsA: It is returning the data below 2000, but I need to know what positions this data is in. Javascript
Wellyngton, Since you want to return the index, perhaps using the filter is not the best option, although it is possible. See these examples, using reduce and also a more traditional for, both…
javascriptanswered Daniel Mendes 6,211 -
2
votes2
answers526
viewsA: Apply a function to each element of a python matrix
There are several ways to do this you want, using Numpy, you can make use of the vectorize: import numpy as np mat = np.array([[1, 2, 3],[4, 5, 6]]) soma3 = lambda x: x + 3 vectorize =…
-
2
votes1
answer154
viewsA: Image does not open with Tkinter, how to solve?
This error occurs because you try to create the image i = PhotoImage(file="ddddd.png") before it even created the Tk. To correct, it is quite simple, just reverse the order of the lines as follows,…
-
3
votes1
answer490
viewsA: Get fetch return with await/async
James, I ran some tests and got the following results: Accessing this mocky.io API without using HTTPS generates some exceptions during the use of fetch, therefore it will be necessary replace http…
-
3
votes1
answer45
viewsA: Create style for various dynamically generated elements
Danube, A very simple way to do this event onmousemove work for all blocks, is to pass the this for the function getRandomColor: element.setAttribute('onmousemove', 'getRandomColor(this)'); And…
-
4
votes2
answers57
viewsA: Check if a variable is of the function type
Darlei, for that there is the function typeof javascript. See a small example: let fun = () => { console.log("É uma função"); } if (typeof(fun) == "function") { console.log("É uma função! =)") }…
javascriptanswered Daniel Mendes 6,211 -
4
votes3
answers557
viewsA: Continue loop if input is’S'
The infinite loop is happening because you do not change or request a new value for the variable continuar, with this once the value is 's' it will never be altered and the loop becomes infinite.…
-
0
votes2
answers241
viewsA: Problems with JsonObj:Json_hash
In ADVPL, it is possible to parse a JSON in more than one way. We can use the hashmap and Tjsonparser as you were implementing, but you can also use Jsonobject, which makes the code much simpler.…
advplanswered Daniel Mendes 6,211 -
5
votes1
answer65
viewsA: problem with Random.radint(1, 6) and if conditional
Victor, This is happening because of the types of variables. Its variable dada is a whole (int), return of the randint method, but the variable guess is a string (str), because the input function…
-
3
votes1
answer511
viewsA: In typescript can we type a variable with an object?
Victor, Below is a very simple example of parameter typing and function return: //Exemplo de classe class MinhaClasse { key: string = ""; } //Exemplo de função que recebe um parâmetro de tipo…
-
0
votes1
answer35
viewsA: Image is not changing when I click (javascript)
Robert, the error is mainly in the innerHtml property, in fact it is innerHTML, just this case sensitive issue. But in addition, your player if is causing problems, because you trade for player 2…
-
1
votes2
answers120
viewsA: Capture time range in UNIX
Luis, you did the import of datetime twice, even generating the Warning redefinition. One way to fix it would just be to remove the first import of datetime, and also correct lines using the method…
-
1
votes1
answer122
viewsA: Error: invalid syntax python
Jacksuel, On the line you order the year, missing close one parentheses: ano=int(input('Digite o Ano do Filme:')) After in the get of your zero year if, you have closed two parentheses, you need to…
pythonanswered Daniel Mendes 6,211 -
2
votes1
answer67
viewsA: Display average wage by years of service
Santana, In SQL there is the AVG function, which returns the mean of values. You can use the AVG function in the wage field and group by anoServico, it would be more or less as follows: SELECT…
sqlanswered Daniel Mendes 6,211 -
0
votes1
answer31
viewsA: Promisse daughter is not getting into the father’s catch
Rafael, This is because your methods do not make the exception. You can fix by throwing some custom error or throw the catch exception itself. See an example of errors with asynchronous functions:…
-
1
votes2
answers124
viewsA: Printf does not show all variables
William, Your scanf is incorrect, the double reading is done with lf, you also opened and closed the string more than once in the first parameter, the string reading (char array with %s) is not sent…
-
1
votes1
answer205
viewsA: Python error using Tkinter
Potato, error occurs on account of Label which is also part of import tkinter, so he also needs to have the tk. before used (because that’s how you "nicknamed" import), see below the correction:…
-
1
votes1
answer547
viewsA: Is there an equivalent php strpos() function in Javascript?
Trelhac, the closest function to PHP strpos in javascript is the index, where it returns an integer relative to the position of the searched string: let valor = "Teste"; //Vai encontrar o valor…
-
0
votes1
answer53
viewsA: I need to find the duplicates inside a CSV and count them
Fabio, using part of the code you posted, is possible to do as follows: import collections count = collections.Counter() #Lê o arquivo e pega a quantidade de repetições with open("grafo.csv") as f:…
-
1
votes1
answer1020
viewsA: How to count elements of a C File?
Leire, Below is a commented example of how to do this reading, and the file name will be asked to the user: #include<stdio.h> int main(int argc, char *argv[]) { //Nome do arquivo char…
-
1
votes1
answer90
viewsA: Problem with special characters in password meter
Daniel, in the special character regex, there is a dot (.), expecting "any" character before special character class: if ( a.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) { To fix, just remove that…
-
0
votes2
answers109
viewsA: Javascript Calculator(Returns no value)
youboll, there’s enough incorrect stuff in your code. Correcting some variables that have not been declared, such as the nnum10 and the total11, there were some errors in the validations (IF),…
-
3
votes2
answers294
viewsA: How can I finish a setInterval?
It is possible, you will need to work with the clearInterval function. let qtd = 0; let interval = setInterval( () => { console.log("Entrando..."); qtd++; if (qtd == 5) { clearInterval(interval);…
javascriptanswered Daniel Mendes 6,211 -
1
votes2
answers1000
viewsA: Fill in a matrix and add up your numbers
Daniel, Your loop is incorrect, you start at 0 and go until the row is smaller than the matrix size, the same is repeated with the column: for( int linha = 0; linha < matriz.length; linha++) {…
-
0
votes2
answers98
viewsA: I can’t get the button to run a function on the extension
Vinicius, you got a little complicated when you declared the roles for the Eventlisteners. As your check function already exists, you can pass it as callback to the Eventlisteners, so your button…
-
1
votes3
answers1785
viewsA: Put multiple variables in an Alert()
Vinicius, Concatenate values, just put the most (+) as you did, to display in another line, you must use the \n. There is a very nice way to put variables in a string, it is the string template:…
javascriptanswered Daniel Mendes 6,211 -
3
votes2
answers104
viewsA: Replace multiple word Ivs
Ericki, There are several ways to do this, below two examples, using only JS and another with Jquery: //Com JS puro function transformaData() { //Pego as divs com a class datas let divs =…
-
8
votes1
answer88
viewsA: difficulty making vowels uppercase
Hugo, you need to take the return of the replace. You did it this way: str.replace('e','E') But replace returns the changed value, so you need to assign the return to a variable: str =…
python-3.xanswered Daniel Mendes 6,211 -
1
votes1
answer126
viewsA: Create divs every click on the specified size and color button
Mario, There are some incorrect points: You set the ID as a box, but the idea of the ID is that it is unique, each element must have your ID, that way you break this idea You create the element,…
-
0
votes1
answer74
viewsA: Bubble Sort implementation error
Israel, You have errors in the loops you created. Its first loop, you generate the random number, but always puts the number in the same position as the array, because it left fixed the MAX set in…
-
2
votes2
answers180
viewsA: Receive data in a matrix c#
Gustavo, In your code, you create an array with the size of x, which in the case is zero: int x = 0; double[] dados = new double[x]; With this, you have an array of size zero, so when trying to…
-
2
votes1
answer221
viewsA: Javascript returning input Undefined
Bruno, The estate value of the element is being accessed with capital V, but in fact, it is all in lowercase... Just that =) var listElement = document.querySelector('#app ul'); var inputElement =…
javascriptanswered Daniel Mendes 6,211 -
0
votes2
answers71
viewsA: Doubt switch structure Javascript
Paulo, the switch has exactly this behavior, when the break instruction is omitted, so that the switch finds a valid condition, it will enter the other, even if the conditions are not met... It…
javascriptanswered Daniel Mendes 6,211 -
4
votes2
answers820
viewsA: Accept only numbers in the C#console app
Gabriel, if there’s any native way to do this, I’m sorry but I don’t know. Generally, people adopt a loop that keeps the user "stuck" while what they type is not a number, and the cast is done in a…
-
1
votes1
answer720
viewsA: Help with simple while summation program
Rodrigo, the problem is only at the moment of adding up the value of n negative, you are subtracting. Even if the number is negative, you must perform a sum calculation: n = int(input('Introduza o…
-
2
votes1
answer50
viewsA: Segmentation failure - C
Haryel, the error occurs because you use strcmp in a char variable, and it actually compares a string, that is, an array of char. In your case, a simple equality comparison (==) would already solve…
-
0
votes1
answer150
viewsA: Ignore the header when inserting data from a csv file into a Java string array
ADR, have you thought about putting the first line reading before the while? I confess that it is not very elegant, but I believe it solves your problem without generating problems in your logic:…
-
1
votes1
answer2559
viewsA: Set value for an oracle variable and use as parameter
Hard, when you create an Oracle query, it expects you to put the query return in a variable, otherwise you should declare a cursor. Your query is correct, but if you intend to loop (while) on it,…
-
1
votes2
answers282
viewsA: Python - Remove elements from a list
One way to do this is to remove double quotes with the function replace and turn the string into an array with the function split on the basis of (~): #Lista simples Mylist =…
-
1
votes2
answers127
viewsA: Update variable values on repeat loop
Paul, you are having problems because of this initial balance variable, if I put an initial balance, do not perform any operation, my initial balance will be my final balance... One option, is only…
-
0
votes3
answers2047
viewsA: average of values typed in python input
Natanael, to get the valid number, you will have to keep the user in a loop (while) until they enter something valid. The average can be done in two ways by following your code, dividing the number…
pythonanswered Daniel Mendes 6,211 -
1
votes2
answers84
viewsA: How many cases can you use on a switch?
Lucas, as already commented, your blood variable scanf is incorrect, because you need to catch a char, correcting this, your switch will already work. However you may have problems because of the…
canswered Daniel Mendes 6,211