Posts by Woss • 73,416 points
1,476 posts
- 
		2 votes1 answer291 viewsA: Is the ALT attribute inside the SPAN tag valid?No, much less makes sense. The element <span> allows only the global attributes of HTML and alt You’re not one of them. Otherwise, apparently this image is part of the content of the page,… 
- 
		1 votes1 answer486 viewsA: How to speed up my python program?There are several factors in your code that will directly impact the performance of the application without it being the direct fault of Python, but only of bad structuring of the same code. First,… 
- 
		1 votes1 answer647 viewsA: python (Logging) daily log fileJust change the file name of Log.txt for the current date: from datetime import date log_file = path.join(path.dirname(path.realpath(__file__)), f"{date.today()}.txt") The function date.today()… 
- 
		3 votes3 answers71 viewsA: Why is the pseudo-class :Hover not working?Because the selector you used in CSS does not agree with your structure in HTML. While doing #p1:hover #p2 you will be selecting the element #p2 that is descended of the element #p1, but in HTML the… 
- 
		4 votes4 answers519 viewsA: Remove last space from a variable1) Removing the last blank To remove the last space, you will first need to make sure that it is a blank space. If it is, return all the string except the last character. if (mb_substr($name, -1)… 
- 
		2 votes4 answers104 viewsA: Hover does not workBriefly, the problem is that your HTML is very poorly structured. The code starts with a <li> loose; Here we can even consider that you omitted the rest of the code, but it’s just an… 
- 
		4 votes1 answer190 viewsA: algorithm to remove repeated elements in pythonFirst, you need to remember that a stack has the English LIFO behavior last input, first output; i.e. the last one in will be the first one out. So, when you pop elements of P and stack them into Q,… python-3.xanswered Woss 73,416
- 
		2 votes2 answers668 viewsA: Problems trying to access JSON file in PythonThe name json.loads has S at the end just to indicate "load String". json.loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None,… 
- 
		2 votes1 answer97 viewsA: Sum variable is accumulating the value instead of starting at zeroThat’s because you started the value of soma out of the loop, then the value will accumulate during the iterations. What you need to do is start the soma at zero for each new client, within the… 
- 
		5 votes1 answer152 viewsA: How to send variable with link in PHPConsidering $id = $_SESSION['idusuario']. Concatenating strings: echo '<a href="DepoimentosPT-BR.php?id='.$id.'">Depoimentos</a>'; Interpolating strings: echo "<a… 
- 
		8 votes2 answers362 viewsA: Is adding more than one element to Append possible?With the method append is not possible. If you look at documentation you will see that it accepts only one parameter: list.append(x) Add an item to the end of the list. Equivalent to a[len(a):] =… 
- 
		5 votes3 answers48 viewsA: Verification of repeated information in arrayarray_diff (PHP 4 >= 4.0.1, PHP 5, PHP 7) array_diff - Computes the differences between arrays array_diff ( array $array1 , array $array2 [, array $ ... ] ) : array Compares array1 with one or… 
- 
		3 votes2 answers127 viewsA: How to write the condition "if not A" more explicitly?When you do something like if A: ... In Python happens what we call Truth Value Testing, that in a fairly free translation would test the veracity of the value. It turns out that some values are… 
- 
		6 votes2 answers124 viewsA: Get the date of the first Tuesday of each monthAs I commented on Does not return date in input it makes no sense to do: $terca = date($dia->format('Y-m-d')); You create an object DateTime, formats in a string to use again in date? I reinforce… 
- 
		5 votes1 answer137 viewsA: JSON badly formattedInstead of open up, write down and close the file at each iteration in its loop of repetition, why not keep it open during the process? Incidentally, the problem is that you are formatting for a… 
- 
		1 votes3 answers78 viewsA: How to style classes initiated with . fa-?But why do you need to change the font color directly on the icon? Just change it in the context the icon is in. body { font-size: 5rem; } div { color: green; } p { color: red; } <link… 
- 
		2 votes1 answer42 viewsA: Deduct quantity within a PHP loopTo change the data within the loop you must go through by reference. foreach ($estoques as &$estoque) { // -----------------^ } And so basically implement the logic you’ve already made: foreach… 
- 
		3 votes2 answers82 viewsA: How to turn multiple variables into one PHPWith PHP you can check which value is filled and use it. Like the other values will be strings empty, just make a logical operation between them: $quantidade = $_POST['qtdbuffet1'] ||… 
- 
		1 votes3 answers650 viewsA: What is the best way to build a Mysql table with recipe items? All ingredients in one row or one ingredient per row?I see at least three steps to making the ideal solution: Solve the problem; Make the solution beautiful; Make the solution fast; It seems you are starting with item 3, worrying if the solution will… 
- 
		3 votes1 answer57 viewsA: Does not return date in inputDo you understand exactly what you are doing or are you trying to code separately? With $dia->format you format your object DateTime for string; then with the function strtotime you create again… 
- 
		5 votes2 answers689 viewsA: Using self-free method in PythonYou can do what you want, but do it when you know what you’re doing. As Maniero replied, as he put it, it seems more that you only need two functions, so review the need for a class. However, in… 
- 
		11 votes3 answers566 viewsA: How does Python handle and represent an array internally?First, array is different from list. When it comes to Python’s "list", it is wrong to call "array"? In many cases, usually more information, the nomenclature error will not be an aggravating and… 
- 
		3 votes1 answer124 viewsA: Validate explodesIf the full name of the person does not have a blank space, the function explode will return a array of only one element at zero; you cannot access index 1 assuming it will exist, because when it… 
- 
		1 votes2 answers34 viewsA: validation of a Parameter of number type, in jsonschemaAs commented, you want to validate that your number has up to 23 characters in the whole part and 8 characters in the decimal part. You don’t do it with numbers, you do it with strings. The guy… javascriptanswered Woss 73,416
- 
		3 votes1 answer89 viewsA: Sort array as more than one conditionTo sort, you will need to group the values using the function array_map, make ordination with usort and then return the original structure with array_column. For example, you have the following… 
- 
		3 votes1 answer178 viewsA: Create an empty set() objectJust like you put it in the title, set is a predefined class in Python, so just instantiate it as well as you do with any other class: objeto = set() As you have noticed, the keys define an empty… 
- 
		6 votes2 answers5265 viewsA: Scientific notation in PythonYou don’t need any library for this, Python itself already has tools for formatting in scientific notation, just use the e in formatting: >>> número = 123456789.123456 >>>… 
- 
		5 votes3 answers85 viewsA: Make item open when givingYou yourself answered: the problem arises because they are fraternal elements; when the mouse is on the secondary menu, the event of Hover is waxed. How to resolve? Do what the hover stays even over… 
- 
		40 votes3 answers4843 viewsA: For a search with no results, should the HTTP response be 404, 204 or 200 with an empty body?First, I must say that one of the Urls seems to be poorly built. The text means that the URL /users/name/guilherme return all users it has name equal to guilherme. If it is a search, it is not a… 
- 
		5 votes2 answers156 viewsA: Pin tabs bar below navigation bar (navs x navbar)It’s not just putting the two elements inside the same <div> and add the class .sticky-top in it? <script… 
- 
		12 votes1 answer178 viewsQ: Are there advantages to using "use Function" for native PHP functions?When worked with namespaces, it is normal to see the use of use to import classes outside the local scope: namespace Foo; use Bar\Classe; use DateTime; It is also possible to do the same with… 
- 
		6 votes2 answers247 viewsA: How to force string interpolation when one comes from the database?Interpolation works when the string is handled directly by the PHP interpreter. Since it is static in the code, it can analyze it and generate the necessary structure for the interpolation of… 
- 
		5 votes1 answer98 viewsA: Show value, not form IDAccording to the documentation: For each model field that has Choices set, Django will add a method to Retrieve the Human-readable name for the field’s Current value. See get_FOO_display() in the… 
- 
		13 votes2 answers1397 viewsA: How to calculate the value of a polynomial function at an arbitrary point?Answer still incomplete, but already has content on full polynomials. Complete Polynomials By complete polynomials we mean the polynomials that can be represented by Being thei other than zero; that… 
- 
		3 votes5 answers6310 viewsA: How to stop the end='' command in PythonAnother important point is that you don’t need to make a repeat loop just to display the values of the tuple. You can generate the string from the method str.join: tabela = ('Palmeiras', 'Flamengo',… 
- 
		2 votes2 answers53 viewsA: Library importThere are some advantages, yes. Does not pollute the local scope; One of the great advantages of modularizing code is separating things into different scopes, so you have the freedom to work on your… 
- 
		1 votes2 answers189 viewsA: Add array at the end of another array in a foreachIf you need to change the element of array, needs to maintain the reference of the same. Remember that the foreach naturally iterates over a copy of array. So you need to put the character &… 
- 
		4 votes4 answers110 viewsA: Maintain select element value when cloning with jQuery and deleting LabelsWhen you do the clone in jQuery, the state of select is not cloned together, so you will need to set the values according to the last selected value. To do so, you can always clone the last item on… 
- 
		2 votes1 answer122 viewsA: Mean between positions of two vectorsIf it is guaranteed that all lists have the same number of elements, you can use the function zip to generate the lists with the values of each position, calculating the average by dividing the sum… 
- 
		1 votes1 answer186 viewsA: Statement for 2 arguments, how does it work?def multiple_of_index(arr): return [val for index, val in enumerate(arr) if index and val % index == 0] The parameter arr will be of an eternal type. The function enumerate will go through the… 
- 
		4 votes1 answer4515 viewsA: Python data output formattingYou formulated the solution incorrectly. It is not the size of the spacing between the values that is constant, but the width available for each column. If you notice the desired output: 1 alexandre… 
- 
		2 votes1 answer101 viewsA: Error in function - Empty returnUnlike many other programming languages, variables that are defined in the global scope are not naturally imported into the local scope. Thus, a variable that is defined outside the function will… 
- 
		0 votes2 answers212 viewsA: PHP percentage calculation and save to DatabaseI recommend reading again the documentation of the functions you are using: execute, bindParam. The method PDOStatement::execute() expects a parameter of type array, which is optional, but you pass… 
- 
		3 votes2 answers1399 viewsA: Is there a difference between flex-Basis, flex-Grow and width? What is the recommendation for using them in a Flex container?He obtained the same by an innocent coincidence, that is, in this particular situation resulted in the same thing, being two child elements and using 50%. Not always - in fact almost never - will… 
- 
		3 votes1 answer46 viewsA: Remove classes recursivelyJust you do: $('.active').removeClass('active'); This will remove the class active of any element than possess it. If you want to limit the search tree to avoid conflicts with the rest of the page,… 
- 
		3 votes2 answers187 viewsA: Create dynamic menu that adjusts the size of the divI wouldn’t use it grid for this solution, as the grid was created thinking of... well, grid. What you need is not to create a grid, but just to align the elements in the desired way. For this I… 
- 
		16 votes3 answers681 viewsA: What makes cache invalidation a difficult solution?The caches are the mogwais of computing: they are cute, friendly and our friends, but they have the three rules that must be obeyed: It cannot come into contact with water; Keep it away from the… 
- 
		6 votes2 answers3255 viewsA: Using Append - PythonAdd an element to a list dynamically and there are several reasons why this is possible: Do not know previously the value to be added; Make sure your list has room for the new value; And possibly… 
- 
		8 votes4 answers401 viewsA: Skipping route due to poorly formatted parameter is a syntax error?The URL is an opaque value by definition, meaning that it does not necessarily reflect the structure of your application; so much so that accessing /user/1 is not necessarily access the file in… 
- 
		1 votes1 answer35 viewsA: How to create sequential objects?There are numerous ways to implement this, but in essence just understand exactly what the line of code does: $user = Database::table('users')->where('name', 'John')->first(); Database is a…