Posts by Woss • 73,416 points
1,476 posts
-
9
votes1
answer390
viewsQ: How does CSS media query prefers-color-Scheme work?
From what I understand, it can be used to apply different styles according to user preferences. .light, .dark { display: none; } @media (prefers-color-scheme: dark) { .dark { display: block; } }…
-
3
votes1
answer127
viewsA: How to get the url from Chrome Devtools
Let’s abstract your problem for a minimal, complete, verifiable example, with no external dependencies. console.log(`/questions/${Math.floor(Math.random()*1e6)}`) Basically a random Stack Overflow…
-
0
votes3
answers184
viewsA: Function to duplicate a Python list
If you can (and I don’t see why you couldn’t) use generators, you can instead store the entire list with string and index, to control which have already been returned, store only the string which is…
-
2
votes2
answers429
viewsA: How to filter object
I see no point in defining a list of objects with the keys aluno1, aluno2, aluno3, etc, precisely because you will not have direct control over which key to access in each object. For example, if I…
javascriptanswered Woss 73,416 -
4
votes2
answers53
viewsA: Buttons don’t change color
To understand what is happening to your element you can (and should) use the tools that the browser offers you. Just click on the mouse right click on the element and go to Inspect. In the tool will…
-
5
votes3
answers189
viewsA: Why do we not receive an error when we call an undeclared variable as a window property?
Access window.a and a when both are not defined generate distinct results because they are evaluated from distinct algorithms. window.a is evaluated for the reference value a in the reference…
-
4
votes2
answers165
viewsA: Why is there a conflict of days in the Carbon API?
There is an inconsistency of the day of the month. We are at 31/07, when you do Carbon::now()->subMonth() it will basically subtract a month from the date, getting 31/06. As the month of June…
-
1
votes2
answers241
viewsA: Tkinter - pass argument to function
You did self.btnMessage["command"] = self.printMessage("Olá!") Which is basically attributing the return of function self.printMessage as command. Since it has no return, the value will be assigned…
-
6
votes1
answer3608
viewsA: What is the difference between LEFT JOIN and LEFT OUTER JOIN?
None. If you check the mysql documentation will see that it is placed joined_table: table_reference {[INNER | CROSS] JOIN | STRAIGHT_JOIN} table_factor [join_specification] | table_reference…
-
4
votes2
answers72
viewsA: How to put Try/catch in ES6 format?
The notation of Arrow Function entered in ES6 is basically a syntactic sugar for when you need to define a 1:1 ratio of the input with the output of the function, extremely useful for mapping…
-
1
votes1
answer28
viewsA: Get records that have equal values
To do this, just do the JOIN between your two tables, grouping them by email address and filtering the result to keep the groups that have 2 or more users for that email. You came close to that in…
-
3
votes1
answer63
viewsA: Compare array using 2 values
The simplest is to generate an associative array using as a key an index that is equivalent among the items you need to accumulate. As you want to accumulate quantities based on product and size,…
-
9
votes1
answer217
viewsQ: How will the null coalescence assignment operator work in PHP 7.4?
In version 7.4 of PHP was implemented the null coalescence assignment operator that promises to unify the behaviors of assignment and null coalescence operators, the latter being present since…
-
14
votes3
answers166
viewsA: Create function in javascript
The comparison x == 'y*' will only be true when x be exactly the string 'y*', that is, two characters being a letter Y and an asterisk. If the idea is to check whether x starts with the letter Y,…
javascriptanswered Woss 73,416 -
1
votes1
answer32
viewsA: System to Python Client queue error
if comandomona == mostrar : elif comandomona == lançar1 : ... When you make a if the interpreter expects there to be a code block inside it. That is, after the line with the if, the interpreter will…
-
4
votes3
answers92
viewsA: How to better organize the foreach
All rows in your table have the same pattern: <nome>: <valor>. So you can take advantage of this standard to simplify your code: $resultado = []; foreach ($dados as $dado) { list($nome,…
-
2
votes1
answer37
viewsA: List iteration problem using any() function
Basically the function os.walk returns a tuple with three values: dirpath, one string dirnames, a list filenames, a list When you do x in root, your root will be a string and therefore will be…
-
7
votes2
answers151
viewsA: Does HTTP/2 need something other than server configuration to work?
In accordance with the apache documentation, you can control the requests PUSH through the response header Link. That is, if you will respond your client with an HTML file that depends on a CSS file…
-
6
votes4
answers99
viewsA: Simplify value localization in arrays in PHP
whereas the value of id is unique for each name, you can define a map that relates the id to the respective name. In PHP, we can define this map through a array associative in which the key is id…
-
5
votes2
answers932
viewsA: How to store values of a list in individual variables without knowing its size?
You will get the list with: lista = input().split() But we must remember that values will be strings. To subtract 1 from each value and then compute the sum, just use the function sum and of…
-
1
votes2
answers90
viewsA: How to change an element after an action on the page?
As quoted in Change parent properties if CSS child exists just use the selector :focus-within in the parent element of your field: .texto-azul:focus-within > p { color: blue; } <div…
-
6
votes2
answers785
viewsA: How to check if an XML file is valid with PHP?
Just do the error handling with this same PHP XML API. The function simplexml_load_string returns false when you cannot correctly process the XML, then just analyze the function return. $meuXml =…
-
0
votes1
answer147
viewsA: Error while sending recaptcha
The warning message you received is very clear as to why: Warning: file_get_contents(): https:// wrapper is disabled in the server Configuration by allow_url_fopen=0 in…
-
2
votes2
answers1378
viewsA: How to calculate potentiation only using the sum operation?
Potentiation is nothing more than multiple multiplication operations, so you can implement multiplication through sums and use it for potentiation. Luckily this has already been discussed here in…
-
1
votes1
answer112
viewsA: PHP And Bootstrap Themes
Create multiple versions of your layout with different colors: layout.azul.css layout.red.css layout.verde.css Then, considering that you have the user configuration persisted in some way, you can…
-
3
votes1
answer57
viewsA: Javascript beginner - Pass argument to javascript
When you do onclick="onclick_edit(<?php echo 'aaa';?>);" The result will be HTML onclick="onclick_edit(aaa);" You can confirm this by viewing the source code of your page. When trying to run,…
-
3
votes4
answers830
viewsA: How to search for value in Array/object in PHP?
Whereas you have the following structure: $data = (object) [ "Chats" => [ (object) ["Chat" => (object) ["ChatId" => 1000]], (object) ["Chat" => (object) ["ChatId" => 2000]], (object)…
-
2
votes1
answer79
viewsA: Doubt about Python List
What you have created is not a list, it is a dictionary. A dictionary is a map that relates the key/value pair. In your case the dates are the keys and the number of times that is repeated are the…
-
1
votes1
answer2035
viewsA: How to find data based on another column with Pandas?
Defining your dataframe: >>> import pandas as pd >>> d = { ... 'id': [1, 2, 3, 3, 2, 1], ... 'name': ['jose', 'pedro', 'maria', 'maria', 'pedro', 'jose'] ... } >>> dfa =…
-
4
votes3
answers106
viewsA: How to convert HTML comments to HTML code?
I believe the best way is to walk through the child nodes of your element and treat those who possess nodeType equal to 8, referring to COMMENT_NODE, to identify which are comments. const container…
-
2
votes2
answers462
viewsA: Assignment of Boolean within a ternary operator
The syntax error you cite is due to the fact that you are doing assignments within the boot of a tuple. This is not possible, not until version 3.7, as jsbueno has already commented in its reply. To…
-
1
votes1
answer346
viewsA: Check the file extension and change its directory
For versions equal to or greater than 3.4 of the language use the package pathlib to manage directories and files. Its API is more direct and simple than the one provided by the package os. To open…
-
2
votes1
answer232
viewsA: Redirect to previous page: PHP vs. Javascript
It is important to point out that its two solutions redirect the frontend. It is not because there is an excerpt of PHP there that it does in the backend; PHP will only be responsible for generating…
-
2
votes5
answers1315
viewsA: Join two events that have the same function
With HTML syntax it is not possible as it is static. You can even create a preprocessor that does what you want, which would facilitate maintenance, but in the final code would end up being the same…
-
3
votes1
answer141
viewsA: How to check by the url if the page is the index
Instead of href, you can use pathname, which is the part of the URL you want to check: const url = window.location; console.log(url.pathname); In this case, in the index the value of url.pathname…
-
1
votes1
answer2434
viewsA: Python3 Typeerror: Unsupported operand type(s) for +: 'int' and 'list'
The problem was basically due to an inconsistent call to the function sum: sum([dados[2:17] for dados in dados]) If the documentation: sum(iterable[, start]) Sums start and the items of an iterable…
python-3.xanswered Woss 73,416 -
16
votes2
answers829
viewsQ: What is Svelte JS?
Nowadays, much is said about the web Components and custom Elements, and along with big names like Angular, React, Vue and Polymer, I recently heard the name Svelte JS. What is Svelte JS? It is…
-
3
votes1
answer21
viewsA: Check function only returns empty
You defined that the function should return 3 characters, you got 3 characters, but you found it strange because they didn’t come 6? Strange. Perhaps more attention was lacking when reading the…
-
4
votes2
answers153
viewsA: How to apply decorators that are classes in other class instance methods?
Contextualization of the error The problem is that when making the decorated method, the attribute Teste.foo becomes an instance of Decorator, 'Cause memorizing it like that is the equivalent of…
-
0
votes1
answer145
viewsA: Check List elements within other Python lists
if lista1 in lista2 : print('todos dentro') What you compared here is not whether one list contains all the elements of the other, but whether one list contains the other. These are separate things.…
-
0
votes2
answers36
viewsA: Pick up the value opened
You don’t need two SELECT to do so, simply order in descending order by idcaixa and fetch the first record: SELECT abertocaixa FROM tblcaixa ORDER BY idcaixa DESC LIMIT 1 See working on DB Fiddle…
-
11
votes1
answer374
viewsQ: Does multiple assignment in Python use tuples?
In the question Inverting two variables without using a temporary an answer quotes a link that comments on the multiple assignment of variables in Python: Functioning of Multiple Assignment The…
-
8
votes2
answers214
viewsA: Inverting two variables without using a temporary
For practical purposes, prefer multiple assignment, cited in this answer. Out of curiosity: When variables are integer, you can also invert with mathematical addition and subtraction operations:…
-
6
votes2
answers134
viewsA: Why is readonly valid on the form?
A field defined as readonly is intended only to present information to the user in a way that is sent together with the data in the submission of the form. As the name itself says is a read-only…
-
2
votes3
answers115
viewsA: Show a dictionary inside a class created by an external function
From version 3.6 of Python you can use dataclasses for this type of data structure. from dataclasses import dataclass @dataclass class Character: name: str genre: str race: str The dataclass will…
-
0
votes1
answer1380
viewsA: Indexerror: list index out of range in python
The error happened because you are trying to access position 0 from an empty list. ... if lista[0] == 'fechada': while lista[0] == 'fechada': del lista[0] ... At this point in the code, lista will…
-
5
votes1
answer62
viewsA: While loop being ignored
You have two repeat loops with while, that have the structure: while condition: block Where the code block block will be executed while the condition condition is true. If the condition is never…
-
3
votes2
answers123
viewsA: Python functions + lists
The main problem that contributes to the behavior you mentioned is that your indentation is wrong and, as a result, the return is inside your loop loop. Thus, it will finish the function already in…
-
1
votes1
answer40
viewsA: Mult-lingua site with regular expressions
The problem is in the regular expression you are using. You have defined lang as (?P<lang>\S+), however the \S house with any character other than white spaces (' ', \n, \t, etc.). Thus, the…
-
5
votes1
answer41
viewsA: Error when multiplying 02 fields automatically with Javascript
The problem is that as long as the field is empty, value will be a string empty and you are trying to convert a string empty to decimal, resulting in NaN. Behold: console.log(parseInt('', 10)) So…
javascriptanswered Woss 73,416