Posts by Augusto Vasques • 15,321 points
571 posts
-
2
votes2
answers55
viewsA: How to change the style of a page by clicking a button?
What I’d like to know is: as I do to change only the . css reference that gets in the head? It is possible using the method Document querySelector(), which returns the first element within the…
-
7
votes3
answers204
viewsA: How to serialize and deserialize objects containing Bigint values in Javascript?
A different approach that did not involve string analysis would be to serialize the value Bigint as an object JSON custom to store, in an array, a version of the value BigInt converted into a…
-
1
votes3
answers109
viewsA: How to compare arrays ignoring the order of the elements in Jest?
An alternative would be to install the package jest-Extended, whose goal is to add other "matchers" to existing ones, and use the method expect.toIncludeSameMembers(\[members\]) that checks whether…
-
1
votes3
answers79
viewsA: Search python data dictionary
In python you can traverse through an iterable using some tools: Iteration List comprehension Map Recursiveness Iteration is the repetition of a process aiming to generate a result. In computing,…
python-3.xanswered Augusto Vasques 15,321 -
3
votes2
answers86
viewsA: How to deal cards from a deck using dictionary
I cannot say that it is the ideal method, as there are several ways you can understand the cards of a deck. But a simple way to model cards from a deck is first to model the suits, then to model the…
-
3
votes2
answers98
viewsA: How to print a double value with zero in java?
Use the method: public PrintStream format(String format, Object... args) The method PrintStream.format() writes a formatted string in stream output using as parameters: format- A format string, as…
javaanswered Augusto Vasques 15,321 -
-1
votes1
answer54
viewsA: PHP how to delete file . jpg from all possible folders and subfolders
Some concepts should be seen. Recursive and non-rerecursive iterators PHP has no iterators "recursive", as in ArrayIterator and FilesystemIterator. There are also "recursive" iterators, such as…
phpanswered Augusto Vasques 15,321 -
5
votes1
answer45
viewsA: Interaction with multidimensional array in php
Want your data displayed in columns work them as if they were a table with array_column(). The function array_column() accepts a multidimensional array as input where each element(array or object)…
-
4
votes1
answer56
viewsA: How to stop running Python code for time?
By default, request shall wait indefinitely for a response to a request. If you want to specify a timeout for request, use the parameter timeout The example below the request timeout will be reached…
-
3
votes1
answer58
viewsA: Which is more advisable to use, - or _ to friendly url
The following text has been translated and adapted from Google Search Center Keep a simple URL structure. The URL structure of a website should be as simple as possible. Consider organizing your…
phpanswered Augusto Vasques 15,321 -
3
votes2
answers69
viewsA: How to compare several different terms in a simplified way in Python?
One possibility is to make a pertinence test: if valor_aleatorio not in (termo1, termo2, termo3): In the above case it is checked whether the value of the variable valor_aleatorio is not present in…
-
-1
votes2
answers67
viewsA: How to read two integer variables on the same line with PHP?
It is possible to extract from an input string an array of strings composed only integers independent of specifying some separator. For this just split the input string to each character that is not…
-
2
votes2
answers35
viewsA: Convert Two-dimensional String array Separated by comma
Surely there is an easier way to concatenate these values into a string: With array_column() get an array containing the values of label. With implode join elements in a string. <?php $formatos =…
-
3
votes2
answers46
viewsA: I have a date/time start and end frame, how do I separate for dates / start time / end time on pandas?
Just use the constructor of pandas.Dataframe() combined with the properties pandas.Series.dt to access the datetime values of the series: import pandas as pd df = pd.DataFrame([ ["20/07/2021…
-
3
votes2
answers47
viewsA: How to print the mathematical values one below the other?
One possibility is the use of string replacement following this table: Replacement string Description %the Emits a Javascript object. %d or %i Emits an integer number. Example: console.log("Foo…
javascriptanswered Augusto Vasques 15,321 -
3
votes2
answers86
viewsA: How can I simplify these two functions?
It is possible to simplify and unite its functions with the use of a conditional operator: expressão1 "if" condição "else" expressão2 It works by testing the logical value of condição and case:…
-
2
votes3
answers74
viewsA: Display warning message when typing numeric value
First mistake is in the first line: const ValorImovel = document.querySelectorAll("#ValorImovel") document.querySelectorAll() returns list of elements present in the document that match the…
-
1
votes2
answers81
viewsA: How do I click the + switch to - and click the - switch to +
An alternative, which I consider simpler, would be to use the HTML element <details> which creates a disclosure box in which the detail information is visible only when the element is switched…
javascriptanswered Augusto Vasques 15,321 -
3
votes1
answer51
viewsA: Sum of a specific range in a PHP array
As in PHP the order of the elements of a associative array is defined by the order in which the elements are inserted into this associative array, implying that it is possible to extract a subarray…
phpanswered Augusto Vasques 15,321 -
2
votes2
answers72
viewsA: Space between text and table borders
This answer is addressed both to the author of the question and to the other answer authors. It is difficult to write then any contribution will be welcome. Evaluating the other answers The other…
-
5
votes1
answer106
viewsA: Doubt about looping loops in C
Superficially looking. You’re missing that line: somaparcial = somaparcial + i; That should be: somaparcial = somaparcial + j; And you’re also missing the block: for (i = x; i <= y; i++){ for(j =…
-
4
votes2
answers94
viewsA: Special characters are not displayed by the console.log
An alternative would be to use the static method String.raw() as a tag function for a literal template containing your text: var myString = String.raw`If There Is Bread Winners There Is Bread…
-
1
votes2
answers48
viewsA: Divs created in Javascript
In HTML the attributes data-* form a class of attributes, called custom data attributes, that allow proprietary information to be exchanged between HTML and its representation GIFT by way of script.…
-
3
votes3
answers84
viewsA: Copy between strings inside Python lists
Use a variable l to save the character to be repeated and then iterate through the list elements coluna and one by one, in c and check if they are contained in the list lista: if yes the c is…
-
3
votes2
answers144
viewsQ: What are the differences between constants declared with const and immutable variables declared with Let in Rust?
The declaration of immutable variables In Rust if you want to declare a variable, we use the keyword let. Example: fn main() { let site_name = "Stack Overflow em Português";…
-
1
votes2
answers73
viewsA: How to print the number that appears odd times (Python 3)
Always look for the simplest alternative. Use an accountant collection.Counter to know how many times an element has repeated itself in a list and use the rest of the division of a number by 2 to…
python-3.xanswered Augusto Vasques 15,321 -
6
votes3
answers156
viewsA: How to join 2 lists in a dictionary?
It is unnecessary in python to build iteration loops to create dictionaries from two lists of the same length. Just add the lists with the built-in function zip() and pass the obtained result as an…
pythonanswered Augusto Vasques 15,321 -
2
votes3
answers57
viewsA: Convert stopwatch to hh mm ss format
Create an object of the type Date and with the method Date.prototype.setHours() adjust your time, minutes, second and milliseconds by 0. The respective portion the date in this case is irrelevant.…
-
1
votes2
answers49
viewsA: Doubt on how to use date object
Use the method Date.prototype.toLocaleDateString() that returns a string with the representation of the date part based on the language. const data = new Date(); //Pega a data do sistema. const mes…
javascriptanswered Augusto Vasques 15,321 -
1
votes1
answer51
viewsA: How do I get the sum of the values I add to the list?
Its nested function total() is not totaling, every time the value of the variable is called res is started at zero. function total() { let result = document.getElementById('res') //Aqui res é…
-
1
votes1
answer41
viewsA: Problem where I have to create a rectangle without padding, but I’m having trouble with the additional spaces in the rectangle
There are three misunderstandings: The way the function was built the line: print(retangulo(largura, altura)) is prolific because the entire printing process takes place within the function itself…
pythonanswered Augusto Vasques 15,321 -
4
votes2
answers78
viewsA: Line Break inside the P tag does not work
Where you use the property Element.innerHTML use the property Node.innerText which represents the "rendered" textual content of a node and its descendants it means that line breaks are converted and…
-
2
votes1
answer40
viewsA: How to prevent event for both father and children?
Following your own reasoning: onclick = (e)=>{ if (e.target != notificationCtn) notificationCtn.style.display = "none"; } The above code fragment is instructing the interpreter to assign the…
javascriptanswered Augusto Vasques 15,321 -
0
votes2
answers37
viewsA: I’m making an Alert after 3 clicks and stop the next clicks, but when I uncheck some that was marked Alert still appears
It can even be done using Alert but the final visual result is not good because the bootstrap button has some peculiarities: In device whose interaction with the screen is controlled by mouse, the…
javascriptanswered Augusto Vasques 15,321 -
3
votes2
answers127
viewsA: How to detect Start Codon and Stop Codon in a nucleotide sequence using Python?
With the help of the native module re it is possible to create a regular expression validating its nucleotide sequence and separating the portion of the sequence containing the codons. With an…
-
2
votes3
answers106
viewsA: How to pass a string to two whole types?
You can use the class java.util.Scanner which is a plain text scanner that can parse and primitive strings and types using regular expressions. The instance of Scanner divides your input into tokens…
javaanswered Augusto Vasques 15,321 -
1
votes2
answers48
viewsA: After finishing the program, the "textContent" disappears quickly. My intention was to stay on the screen
There are some errors in your code: Misuse of the global attribute id: The global id attribute defines an identifier exclusive (ID) that must be unique throughout the document. Its purpose is to…
javascriptanswered Augusto Vasques 15,321 -
0
votes11
answers37801
viewsA: Compute sum of digits of a number
An alternative is to use the function reduce() module functools from functools import reduce n = input("Digite um número inteiro: ") print(reduce(lambda *args: sum(args), map(int, n), 0)) reduce()…
pythonanswered Augusto Vasques 15,321 -
0
votes4
answers97
viewsA: Find a ( string ) value in a PHP array
In addition to the mandatory approaches presented in the other responses, it is also possible to use a functional approach using the function array_reduce(), which reduces an array to a single value…
-
3
votes3
answers105
viewsA: How to create listeners for multiple elements in a loop?
A simple alternative is in HTML to design a class attribute common to the elements you want to add the listeners and in Javascript(Jquery) add the System to all elements that contain this class.…
-
2
votes1
answer125
viewsA: Greeting Functions "Good morning, Good afternoon and Good evening"
Edit: As reported in the comment of hkotsubo informing that it facilitates the adoption of the Date.prototype.getHours() which returns the time to the specified date, according to the local time. So…
-
1
votes1
answer59
viewsA: Deck cards with css only
The problem is you’re trying to add a lower margin when in fact just adjust the top of <div> pointed at the :hover. .scene { top: 50px; /*Defina onde estará o inicialmente o topo das cartas*/…
-
3
votes2
answers73
viewsQ: Is there documentation in the Ecmascript standard that ensures that an array when passed as a property advisor has a defined format?
The other day debugging a code here on the page I found something peculiar. Like that: let a = {}; let b = [1,2,3]; let c = [4,2,3]; a[b]= 1; a[c]= 2; console.log(a) //{ "1,2,3": 1, "4,2,3": 2 }…
-
3
votes2
answers113
viewsA: How to use alphabet range in python?
The module string from the standard python library defines some constants among which string.ascii_uppercase is the sequence of capital letters ABCDEFGHIJKLMNOPQRSTUVWXYZ. It is possible enumerate…
-
5
votes2
answers141
viewsA: How to Split by Capital Letters and Numbers at the same time?
Just out of curiosity. Also in Python it is possible to perform the same task without resorting to regular expressions, iterating by characters and using a list as pile to separate the parts of the…
-
2
votes2
answers45
viewsA: How to make a counter with javascript speed setting to simulate game time
Use together setInterval() and clearInterval(). setInterval() creates a chronometer, returning an id to that chronometer, repeating the execution of a function continuously within a specified…
javascriptanswered Augusto Vasques 15,321 -
1
votes4
answers412
viewsA: How to check if a list contains 3 consecutive numbers
If the goal is to identify all sequences of three consecutive integer numbers in a list, one option is to sequence comparison : n = [-3, -2, -1, 10, 5, 7, 9, 20, 16, 11, 12, 13, 3] result = []…
-
0
votes3
answers11827
viewsA: Use list as dictionary value using Python append() method
As already explained the method append() does not return value and therefore on the line: dic['a'] = lista.append('a') The key dic['a'] is assigned as None. If all the values in your dictionary are…
-
2
votes2
answers68
viewsA: Javascript function equivalent to Delphi Frac
Looking for Delphi documentation found this function System.Frac(). Follows excerpt from the documentation: function Frac(const X: Extended): Extended; Description Returns the fractional part of a…
-
2
votes1
answer101
viewsA: Is it possible to link tables with keys stored in JSON column?
Yes, in the Mysql it is possible to relate data of a json document1 and yes the desired data structure is tangible. Mysql environment gives your user a function set facilitating the operation with…