Posts by Augusto Vasques • 15,321 points
571 posts
-
3
votes3
answers238
viewsA: Update label every time you click a button
In Python the variables referenced only within a function are implicitly global. However if a variable has a value assigned anywhere in the body of the function, it will be assumed as local unless…
-
6
votes2
answers113
viewsA: Encapsulation of functions
No, this is not an example of using a function passed as a parameter to another function. When does... extrai_maior(gera_nums()) ... it’s actually just passing by the result of function gera_nums()…
-
2
votes1
answer50
viewsA: I’m having trouble putting two matrices together
Your iterator should scroll through the larger list. Also create two index protections that allow you to add in x only elements of a and of b whose index i be individually validated: def…
pythonanswered Augusto Vasques 15,321 -
2
votes2
answers76
viewsA: Add name to json Key
If I understand the question you want to add a pair chave/valor in the JSON representation of the object $data. To do this just create a property and pass the desired value. <?php $final = [];…
-
4
votes3
answers5507
viewsA: Count how many elements are duplicated in a string
Use the regular expression /(.)(?=.*\1)/gi to find the repeating characters. function duplicateCount(text) { let repetidos = [...text.match(/(.)(?=.*\1)/gi)].map(x => x.toLowerCase()); return…
-
1
votes3
answers362
viewsA: Functions with optional Python parameters
In python it is usually not necessary to overload functions because it is a dynamically typed language and supports the passage of optional arguments to the functions. In most cases just check the…
-
2
votes2
answers68
viewsA: Value of calculation disappearing
As SAM said in the comments just change the button type. What happens is that when click occurs the browser tries to send the form to the server. Where is: <input type="submit" id="resul"…
-
1
votes1
answer122
viewsA: How to remove the navbar effects from Materialize?
You can bypass the styles application of this framework by assigning the class browser-default for the element that wants to revert to its original state and then assign a class to that element…
-
1
votes3
answers896
viewsA: How to insert a character in the middle of the sentence
You can use the method sub module re which provides regular expression matching operations. re.sub( padrão , repl , sequência , contagem = 0 , sinalizadores = 0 ) sub() returns a string obtained by…
-
14
votes3
answers1553
viewsA: Return the index of the largest element in an array
To find the highest value within a vector you can use the method Math.max() which returns the greater of one or more numbers: var lista = [2, 3, 6, 7, 10, 1]; console.log(Math.max.apply(null,…
-
1
votes3
answers50
viewsA: Error while uploading files
You’re making a mistake because $_POST['arquivo'] returns a string obtained with the element <input type="file" id="arquivo" name="arquivo"> and when it does... $tmpName =…
-
1
votes1
answer67
viewsA: Identify matching in dataframes
From what I understand you want to find intercessions between the values of two columns of two dataframes distinguished. To find intercessions you can convert the columns you want to find…
-
3
votes1
answer53
viewsA: import PYTHON / PANDAS
Just to clarify that the title of the question: import PYTHON / PANDAS It means that here: import pandas as pd the body of the question refers to another subject... See if it helps: texto =…
-
2
votes2
answers89
viewsA: Searching for letters in an array created by random numbers
Your code can be simplified using the ES6 syntax: // Cria um array de 1000 caracteres pseudo-aletórios no intervalo [A-Z] let tabLettres = [...Array(1000)].map(x =>…
-
4
votes1
answer273
viewsA: How to import and export members using Ecmascript modules in the browser?
You need to run your code as a module. A Javascript module is a file or simple script that contains JS code. There is no Javascript keyword to define a module. But in HTML5 there is an attribute in…
-
6
votes4
answers2542
viewsA: Access list element within Python list
In Python list is a mutable and ordered collection whose access of the elements are done through an index, index whose numbering starts from zero. Knowing this and that a nested list is nothing more…
-
2
votes3
answers757
viewsA: Is there a command or function in Javascript that controls the screen update before the loop ends?
Javascript is a single thread language which means that the HTML display will only be updated after the loop is finished. To make your HTML be updated in a loop you would need to use a hypothetical…
-
7
votes1
answer218
viewsA: Process.start does not open osk.exe in C#
The problem is occurring because the process osk.exe is a 64-bit process. By default a Visual Studio application is compiled for 32-bit platforms to ensure greater compatibility, the problem is that…
c#answered Augusto Vasques 15,321 -
2
votes1
answer58
viewsA: Join two array
As explained in the comments the desired array format cannot be reached because in PHP an associative array cannot have repeated keys. Attempting to add a repeated key results in overwriting of the…
-
0
votes2
answers118
viewsA: Method to capture trex of a URL with Javascript
The author of the question mistakenly put this answer in the question: After posting, I read the code and thought about making another Split(), so it worked: var mainURL = window.location.href;…
javascriptanswered Augusto Vasques 15,321 -
3
votes1
answer275
viewsA: Sort class list in Python
You did almost everything right, just in time to set the key to sorting you got confused: #Classe definida pelo AP class Cromossomo(): def __init__(self, cromossomo, comprimento): #Construtor…
-
1
votes1
answer68
viewsA: Creating a JS animation with SVG using HTML and CSS
The problem is because when the line is called: const circle = document.querySelector('.meu-circulo'); The element: <circle class="meu-circulo"></circle> Does not yet exist generating…
-
1
votes2
answers744
viewsA: How to remove line breaking from txt file in PHP array
Use the function preg_split() to split string by a regular expression. Use the exhaust sequence \R to find a line break independent of the OS in which it was generated. <?php $texto =…
-
2
votes3
answers453
viewsA: How to perform currency multiplication in the Brazilian format in js?
As stated in the comments the best way to work with currency in trade is to remove non-numeric characters (grouping points and decimal comma) operationalize and readjust the result by dividing by…
javascriptanswered Augusto Vasques 15,321 -
6
votes6
answers491
viewsA: Optimize code in Python
It’s not really an optimization I just refactored your code. n = input('Digite o texto todo em maiúscula: ') while not n.isupper(): n = input('Texto errado, digite tudo em maiúscula: ') print('Texto…
-
4
votes1
answer117
viewsA: Checking if a number is prime
There were many logical errors so I found it easier to refactor your code than to make punctual corrections. var numeroDivisores; //É comum utilizar os iteradores em ordem alfabética ordenando dos…
-
1
votes5
answers835
viewsA: How to put the operation (sum, multiplication) within a variable
In Javascript it is not possible, at the syntactic level, to pass an arithmetic operator as argument. What you can do is merge the input numbers into an array and use the method…
-
4
votes3
answers4467
viewsA: How to take part of a String up to a specified character?
I did not understand this requirement not to use the method String.prototype.split() is a native method of language splits a String object into an array of strings by separating the string into…
javascriptanswered Augusto Vasques 15,321 -
0
votes2
answers90
viewsA: Function to queue walk in the Array, first turns the last in Javascript
Use the propagation syntax to make the left rotation of the array widgets. let nomes = ["Wesley", "Welson", "Gabriel"] let rotação = [...nomes.slice(1, nomes.length), nomes[0]] console.log(rotação)…
javascriptanswered Augusto Vasques 15,321 -
4
votes1
answer407
viewsA: Possible with javascript / jquery
One way to do this sign is to use the CSS property 'Animation' and the rule '@keyframes', which controls the intermediate stages in an animation sequence, together with the function 'translateX()`…
-
3
votes3
answers229
viewsA: How do I access the value of this array in javascript?
The problem is that you are not analyzing the JSON obtained from the server and so receive undefined when it does console.log(var[0].nome). Use the method JSON.parse() to parse a JSON string,…
javascriptanswered Augusto Vasques 15,321 -
1
votes1
answer138
viewsA: How to read two numeric values for a list in the same line in Python?
Use the method extend() that extends a list with the content of the argument. As in the question you say "multiple numeric values" use list comprehensions to convert the string for int >>>…
-
1
votes1
answer46
viewsA: Problems in the identification of the div
To solve the problem proposed in the question, which is to select the <div> to which the checkbox that was clicked, you can use the jQuery method .parent() which will return the parent of an…
-
0
votes1
answer40
viewsA: Duplicate Array in Function
Is duplicating the result because you are invoking twice the method Cal_Gorjeta(): The first call is made inline: let gorjeta = info_comprador.Cal_Gorjeta() The second is done within the method…
-
1
votes3
answers140
viewsA: I can’t view all data with foreach in PHP with data from an API
To directly modify array elements within a loop, preceded $value with &. In this case, the value will be assigned by reference. foreach ($myArray2['results'] as $key => &$value){…
-
3
votes1
answer365
viewsQ: What is the right way to perform performance tests in Python?
In answering that question Python syntax both accepts "+" and "," in the "print" command()"? : I submitted the following reply: Caso sua intenção seja imprimir apenas uma linha, ambos os métodos não…
pythonasked Augusto Vasques 15,321 -
0
votes1
answer30
viewsA: put color in a <a>
According to the documentation MDN | Styling Links there are pseudo-classes intended exclusively to style links in their respective states. These are the states in which links can exist: Link (not…
-
5
votes1
answer450
viewsA: Recover variable within JS function
Declaration and use of variables usuario and senha are occurring in different scopes. To understand what is happening I prepared a simplified example replicating the same error: function teste() {…
-
2
votes3
answers138
viewsA: How to copy to clipboard values of multiple <span> elements simultaneously with Javascript
WARNING: To date, 12/31/2019, in which this response was written this solution is only compatible with browsers based on Chromium, Firefox and Opera. The response is based on technology considered…
javascriptanswered Augusto Vasques 15,321 -
5
votes1
answer236
viewsA: Javascript elements breaking line
As mentioned in the comments your problem is about HTML and is not related to Javascript, the solution is by replacing the element <div>, within paragraphs <p>, by a single element…
-
1
votes1
answer149
viewsA: View photo registered in the bank
Assuming Foto_pet is a JPEG and $row a line returned by query: echo '<img src="data:image/jpeg;base64,'.base64_encode( $row['Foto_pet'] ).'"/>'; Assuming Foto_pet is a GNP and $row a line…
-
4
votes2
answers105
viewsA: How could I see the variables of a local server running Node.js by "Inspect" the browser?
To debug a Node.js process you must start the process with the option --inspect, that will initialize Inspector which is the debugging server for Node.js . Example: node --inspect The process will…
-
2
votes1
answer75
viewsA: How to sum all data from a table
To count the number of records from a table you have two options, or by SQL using the aggregate function COUNT(*) that returns the count of the number of rows recovered in a query or by PHP through…
-
2
votes1
answer68
viewsA: Profile page - PHP/Mysql
In the statement: $result = mysqli_num_rows($stmt); The parameter $stmt is the type MySQLi_STMT representing a prepared command and mysqli_num_rows() is waiting for a type parameter MySQLi_Result…
-
1
votes2
answers361
viewsA: How to create an array with value one?
If you are looking to fill one numpy.ndarray with a specific value use the method fill(), this method fills the matrix with a scalar value. Examples from the documentation itself: >>> a =…
-
3
votes1
answer288
viewsA: ID with the first character being a number does not work when I put in css #[example number]
According to the recommendation W3C of 28 October 2014, HTML5 A vocabulary and associated Apis for HTML and XHTML, is regulating: 3.2.5.1 The attribute id The attribute id specifies the unique…
-
1
votes3
answers344
viewsA: How to read a text file and generate a dictionary?
In Python the escape sequence \t means TAB. To replace the characters TAB by space use: string.replace("\t", " ") In your code: def simbolo(arquivo): empresas = {} with open("nasdaq.txt") as f:…
-
0
votes1
answer67
viewsA: preventDefault does not work with onclick function on button
As clarified in the comments the problem occurs with the send button of the form: <button class="btn btn-success" name="submit" type="submit" onclick="updateCliente()"> Salvar </button>…
-
0
votes1
answer83
viewsA: Class javascript
What is happening is that you are invoking the instance method makePlayer(player,socketId) as if it were a class method. I see two possible approaches: The first approach is to keep the class Player…
-
0
votes2
answers57
viewsA: When selecting chekbox I need the phrase to be strikety. Follow img example
You can also use Javascript to manipulate the property textDecoration document.getElementById('texto').style.textDecoration = "line-through"; <span id='texto'>Esse texto vai ser…
htmlanswered Augusto Vasques 15,321