Posts by Danizavtz • 2,246 points
169 posts
-
1
votes1
answer22
viewsA: How to use Scanner to define the characteristics of the "product" object
From what I understand of the code has only one logic error. What confused a little was the fact of having declared parameters in the method cadastrarProduto(). Another thing is that tried to make a…
-
-1
votes1
answer52
viewsA: How to install modules from a Python project with Flask?
You must install the dependencies using Pip (python index Packages). In general (this is a convention) the dependencies are listed in a file, with the name: requirements.txt Which also by convention…
-
0
votes3
answers79
viewsA: Search python data dictionary
First let’s go through the dictionary with a for. At the same time we iterate in the loop we already mount the array output tupla, that we add the size of string, added to the previous value, these…
python-3.xanswered Danizavtz 2,246 -
0
votes1
answer20
viewsA: Migrations from my Django app are not applied
By the way you described the problem you created the new app (using the nomenclature of Django) myapp in the "hand". When the correct would be to use the command provided by Django. python manage.py…
-
1
votes1
answer26
viewsA: Error with custom validation with express-Validator
The correct thing would be to do the validation using the express-Validator itself and the string of expressions to do the validation you want. This way we can use the function optional parameter…
-
3
votes2
answers98
viewsA: How to print a double value with zero in java?
One way to solve the problem is by using the class NumberFormat. NumberFormat is the abstract base class for all number formats. This class provides a standard way to format and parse numbers. This…
-
0
votes1
answer23
viewsA: Doubt to return a query
One way to solve would be using the SQL function max with the help of function group by as a subquery of the clause IN. Follow an example: SELECT * FROM contrato WHERE id IN (SELECT MAX(c.id) FROM…
-
0
votes1
answer30
viewsA: (Python + Mysql) Enter the database password automatically in a dump
If you’re using linux (Ubuntu), all you need to do is create a file .my.cnf at home. touch ~/.my.cnf Fill in the file .my.cnf, with the following content: [mysqldump] user = mysqluser password =…
-
0
votes1
answer20
viewsA: Error sending mongodb information on Node
As you said in the question, if you did: const User = require('./model/user') When creating a user instance, you should do: const user = new User({nomecompleto,email,password}) So you’ll probably…
-
1
votes4
answers177
viewsA: Insert names to a list depending on their value
One way to solve this problem is by inserting people directly into an array and then drawing lots. Follow an example: from random import choice def inserirNoSorteio(lista, nome, qtd): for i in…
-
2
votes1
answer33
viewsA: How to run table algorithm again if user chooses to run again?
One way to solve the problem would be to place your code within a loop loop loop structure and keep the execution of the program loop until the user makes the option to exit the program. Here is an…
-
0
votes1
answer42
viewsA: Git push -u origin master command shows error
According to the documentação, it is only possible to do two types of operations. You can push only two URL address types: A HTTPS URL such as https://github.com/user/repo.git An SSH URL, such as…
-
2
votes1
answer31
viewsA: filter the name of an obj according to the highest number
Using the ideas of @Rafael Tavares, one way to solve it would be: const obras = [ {valor: 1, nome: "um"}, {valor: 2, nome: "dois"} ] if (obras.length > 0) { let maior = obras[0] for (let i = 1; i…
-
-1
votes2
answers36
viewsA: Compare two to two elements of a vector
One way to implement it would be: vetor = [2,3,4,4,5] for x in range(len(vetor)-1): if vetor[x]==vetor[x+1]: print('sim') else: print('não') For this code I used the functions len and range that are…
python-3.xanswered Danizavtz 2,246 -
-1
votes2
answers50
viewsA: In if, when the user puts another state that is not specified, instead of entering Else, he enters if and continues the code normally
You could write the if conditions the same way you wrote the first conditional. Follow the example: if est == 'São Paulo' or est == 'SP' or est == 'sao paulo' or est == 'São paulo': I am…
-
0
votes1
answer51
viewsA: Conditional API in Java Script
You could check before including the element in the array. By detecting that the element already exists, simply send the error message. server.post('/users', (req, res) => { const { name } =…
-
1
votes1
answer26
viewsA: How do I perform more than one database query on a single request . GET on the same route on NODE.JS?
To achieve the desired result it is necessary to put your queries in order and in a way that they are executed after the callback of the query, so it is only necessary to rearrange your code Here is…
-
0
votes1
answer202
viewsA: Running Simple Python Script with Docker on Windows
To run a simple python script in windows, just create a folder for the project. In this case I created the directory pythondocker. C:\Users\Naokity\development\pythondocker> Inside this folder we…
-
0
votes1
answer114
viewsA: Generate PDF in Golang
It is possible to compile this example, follow the steps I have done to successfully run: I created a project with the command: $ go mod init example.com/x Create a project with the following folder…
-
0
votes1
answer52
viewsA: Is there any way to instantiate an entire class that is within the main class?
Yes it is possible, just that the declaration of its internal class does not have the level of visibility "public". What you’re trying to do is known as inner class (inner class). To instantiate an…
-
2
votes2
answers93
viewsA: How to allow null values in a field that was originally NOT NULL in SQL?
One way to solve it is by using the command alter table ... modify .... For more information see manual 5.7, manual 8.0. To execute the command below I used the definition of create table that is in…
-
0
votes1
answer47
viewsA: How to make a formatted print?
Could use the function str.format (retro-compatible with python 2.6+). print('O candidato(a): {} tem {} votos.'.format(aux['NOME'], aux['NUM_VOTOS'])) A version compatible only for (Python 3.6+)…
-
-1
votes2
answers44
viewsA: I’m not being able to print javascript
When executing your code, you can see the error by clicking the button executar. Uncaught Referenceerror: i is not defined To solve this problem just use variable x. This to fix this problem just…
-
1
votes1
answer95
viewsA: How to insert JSON values in Postgresql using Nodejs?
Could make the insertions using a repeat command, and iterate the elements contained in the array activities-steps. One way to solve is to iterate over the items using for..of and insert using the…
-
2
votes2
answers61
viewsA: Request for the Nodejs API
Missing pass id to variable. If you were using an older version of nodejs it would be: listUmJogador(request, response) { const id = request.params.id //adicionar este .id…
-
-1
votes1
answer55
viewsA: How do I repeat a password check?
One way to implement is by using a repeat command of.. while. Here’s an example, using your code: public static void main (String[] args) { Scanner password = new Scanner(System.in); String…
-
2
votes1
answer90
viewsA: Remove all before the last occurrence of a - (dash) regex
An approach without regex and without using. In my example I am using only java code. No "step" of Pentaho is used. String endereco = "Rua Fulano Full, 725 - Bloco1 - 'CEP' - CIDADE Imaginaria/UF";…
-
1
votes1
answer55
viewsA: Inserting CSV into Postgresql with Nodejs
One way to solve is to make a loop to fill the missing values, if it is possible to insert null values into your database then it is possible to make a function to "complete" the values of the array…
-
1
votes1
answer60
viewsA: how do I execute without taking the int from the code?
Ever tried to make a conversão (cast) for str? Here is an example of how it can be implemented: codigo = int(input('Digite um numero: ')) for i in str(codigo): print(f'{i} |', end='') Note that it…
python-3.xanswered Danizavtz 2,246 -
1
votes1
answer60
viewsA: ENOBUFS error on Mongodb Nodejs
In this solution we make the connection with the mongo only at the time of npm start (an alias for node bin/www). Check into my package.json the section scritps. After creating the connection we…
-
2
votes2
answers130
viewsA: Separate String in Java Character
Could try iterating with a class instance string. And iterate the characters of this String with the method charAt. Follow an example: public static void main(String args[]) { String vetor =…
-
-2
votes1
answer88
viewsA: How to put a fixed and responsive card on top of the map?
One way to solve the problem is to add a customcontrol in the instance of google maps. This will add a custom control on a layer above the map, it is possible to choose the position where it will be…
-
-3
votes1
answer65
viewsA: How do I ignore one in the Python code
Could use the value r at the beginning of the string, to indicate to the compiler that it is a string raw. This way it is not necessary to do the escaping string. The final result would look like…
-
-1
votes2
answers44
viewsA: Improve select SQL Server performance
You could try a simpler strategy, using the order by together with limitand offset to paginate items from 1000 to 1000, in this case its variable would be the value offset. To the primeira página…
-
1
votes2
answers58
viewsA: I cannot execute if and Elif commands
The problem is that you are reading a value str and is comparing with a value int. As I commented in the previous answer it is possible to verify the problem using the function type(reg), can be…
-
-2
votes1
answer57
viewsA: How can I add these numbers that are going through the foreach?
One way to solve is by using a sum of the power values. Simply declare a variable that will accumulate the sum of the values you are showing in the console. Follow an example: // CONVERT TO BINARY…
-
-2
votes1
answer48
viewsA: Fieldset is inside another, how to tidy up?
Should close the element select correctly where you have: </selection> Replace with: </select>
-
0
votes1
answer164
viewsA: Error Cannot make a Static Reference to the non-static method from the type
You have to declare the function access method as Static. public static int triplo(int numero){ return numero * 3; } If you do not want to use as a static method you must create an instance of an…
-
0
votes1
answer146
viewsA: Import: cannot import name 'Bot' from 'Telegram'
According to the documentação, follows the correct way to create a new instance of a bot: import telegram bot = telegram.Bot(token='TOKEN') To generate a token you need to talk to @botfather…
-
-6
votes3
answers229
viewsA: Convert the string "5.541.00" to int in C#
One way to solve is to use decimal.parse and then cast to integer value. Follow an example: using System; using System.Globalization; public class TransformToIntegerRepresentation { public static…
-
1
votes1
answer44
viewsA: Selenium Wait function does not capture loading element that appears quickly on the screen
I have never used Selenium for c#, what I will suggest is from a script that I have that might do what you want. One way to solve is by using the function expected_conditions in combination with the…
-
1
votes1
answer33
viewsA: Send the result of two Mysql tables to a view (ejs)
From what I understand, you want to add the two information in the template. Here is an example of how it can be done: app.get("/calc", (req, res)=>{ Palpite.findAll().then(calc =>{ req.calc =…
-
-2
votes1
answer55
viewsA: repeat loop - while
One simple way to solve this problem is by using the while loop. Value n must be read. This value being a valid integer, we must consecutively add values from 1 to value n. An imperative approach…
-
-2
votes1
answer41
viewsA: how to create a lock in the code
It could create an auxiliary function to keep the user in a loop while there is a successful read of an integer. Here is an example of how this auxiliary function can be implemented. def…
-
3
votes1
answer62
viewsA: "local" server with python, does not receive an external POST on the same network
You are unable to receive an external post because you are not binding with the machine ip, http://0.0.0.0:5000. The configuration must be done in the local instance of flask to set an initial value…
-
1
votes1
answer32
viewsA: Google does not recognize a Label linked to input
Probably not this item. I ran your code in the local Lighthouse and could not play. Follow the html I used: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8">…
-
0
votes1
answer89
views -
1
votes4
answers184
viewsA: How to set a GET request header in Golang
You must set the header before making the request. Follow an example: API_URL := "https://www.google.com" request, _ := http.NewRequest(http.MethodGet, API_URL, nil)…
-
2
votes3
answers58
viewsA: I cannot convert mongodb files to json in python using bson in python
To cast str for a Dict, simply import lib json which is part of the standard python library for JSON Discovery and Code. The loads function deserializes a string or array of bytes (containing json)…
-
0
votes2
answers164
viewsA: Django does not create tables
In this solution I am assuming that there is no problem in erasing the database, in this way a way to solve the problem is: remove the contents of the folder migrations that is inside each app,…