Posts by Woss • 73,416 points
1,476 posts
-
3
votes2
answers3871
viewsA: Matrix multiplication
Mathematically, two matrices are multipliable if the number of columns of the first is equal to the number of rows of the second. Whereas your matrices are in format: n1 = [ [1, 2, 3], [4, 5, 6] ]…
-
2
votes3
answers205
viewsA: Doubt about HTML input attributes
The input being the type number, you can define the minimum and maximum values through the attributes min and max, respectively. <input type="number" name="numero" min="0" max="9"> If you want…
-
1
votes1
answer79
viewsA: Questions about HTML/CSS - Spotify Page
A very simple way, using basically HTML elements is to use the tag sub. span { font-weight: bold; color: white; background-color: Indigo; padding: 10px; } span sub { font-weight: normal; color:…
-
0
votes2
answers211
viewsA: Dynamic search for selection
Consider a input: <form> <label> Qual é o seu número da sorte? <input name="number" type="text" /> <sub>Pressione <kbd>F2</kbd> para exibir a lista.</sub>…
-
1
votes1
answer750
viewsA: Typeerror: 'float' Object is not iterable in 2D CHOICE function
from random import choice def escolher(): a = choice([[10.00,90.00,30.00,40.00],[50.00,60.00,90.00,80.00]]) fitness_1_temp = 0 for i in a: for j in i: #---------------^^^ if j <= 85.0:…
-
2
votes1
answer519
viewsA: How do I check for a file?
This is because you check the existence of the file twice and at first you run continue if the file does not exist. The continue causes the current iteration to be completed and thus the second if…
-
0
votes1
answer513
viewsA: How to organize the root folder of a website correctly?
This question is quite based on opinion, so you risk being closed soon. For static websites, it is quite common for you to find the format: ├ audios/ ├ css/ │ └ style.css ├ fonts/ ├ images/ ├ js/ │…
-
2
votes1
answer2915
viewsA: Pick table value with jQuery
First, add a parameter to the function that references the span where you are calling the function. I called the parameter of obj. In the call, add the value this for this parameter. In the second…
-
1
votes1
answer356
viewsA: Anchor scrolling
If the intention is just to return to the previous page, I believe that using Javascript to access your browser history is an option, through the function history.back(). window.history.back()…
-
2
votes1
answer119
viewsA: How can we allow just one particular word?
We can create a list of names that will be allowed: ALLOWED_NAMES = ["maria"] Note that the name is all in low box. It is important for a future validation. We define the variable nome and read as…
-
3
votes3
answers2105
viewsA: Use external file function without giving include
Not possible due to symbol table. Symbol table The symbol table defines the context in the programming languages. Variables, functions, classes, objects, constants, etc will have a reference stored…
-
5
votes1
answer4625
viewsA: Remove HTML tags from an Input with PHP
strip_tags (PHP 4, PHP 5, PHP 7) Removes HTML and PHP tags from a string. string strip_tags ( string $str [, string $allowable_tags ] ) This function tries to return a string by removing all HTML…
-
1
votes1
answer57
viewsA: How to collect and insert gradient properties from one div to another div
Why jQuery isn’t searching the information correctly, I can’t say. I did a quick search and couldn’t find a suitable material. It seems he doesn’t consider inline style element as part of CSS and…
-
0
votes2
answers200
viewsA: Validate Fields and Form Submit
One thing you can do, if you’re not already doing it, is call the function validarSenha at the event onsubmit form: <form ... onsubmit="validarSenha()"> This way, when the user presses the…
javascriptanswered Woss 73,416 -
11
votes2
answers875
viewsA: How to load Facebook content?
When it comes to large companies such as Facebook, Google, etc. it is very difficult to conclude how they make their applications. However, I believe it is something very similar to the technique…
-
2
votes1
answer2392
viewsA: Generating pdf with MPDF class
First, we can isolate the tasks. As the data appears only once, let’s define the text in the variable $top, with the header codes and client details: include_once…
-
3
votes2
answers1004
viewsA: Transforming string text into picture
You can use the element canvas to generate the image, as in the example below: var canvas = document.getElementById("receipt"); var context = canvas.getContext("2d"); const messages = […
-
4
votes1
answer1035
viewsA: How to move the mouse automatically, realistically, using Python?
Quite interesting the problem. I believe that a good technique to improve would be to use the concepts already studied in UX (User Experience). For example, as quoted in Google Material, you can use…
-
2
votes1
answer28
viewsA: References not available in the final program
By the error, the object encoding is only missing when executing the hash. Try to apply the encoding, such as: sha256(str(secret_key + url_encoded_data).encode('utf-8')) Staying: def…
-
1
votes1
answer58
viewsA: Combo select does not work
If your return is a list of objects: [ {subcategoria: "Artesanato"}, {subcategoria: "Esculturas"}, {subcategoria: "Ferramentas"}, {subcategoria: "Livros"} ]; It makes no sense for you to interact on…
javascriptanswered Woss 73,416 -
4
votes1
answer341
viewsA: Else does not work in PHP
Missed the : in the first line: <?php if ($status == 'True'): ?> ----------------------------^ And ; in the end: <?php endif; ?> -----------^ In the third line, there’s something that…
-
2
votes1
answer149
viewsA: In what order does a class inherit from its python superclasses?
In accordance with the official documentation about classes in Python, we see in the item of multiple inheritance the definition: For Most purposes, in the simplest cases, you can think of the…
-
1
votes1
answer66
viewsA: Why doesn’t the event end?
First, the function of start It’s not called at any point in its code, so it doesn’t even begin to execute. Assuming the "upload" should start along with the page, I will call you through the event…
javascriptanswered Woss 73,416 -
3
votes3
answers212
viewsA: Get source file from a Python module
I could not understand well what you want with "assign a method to a module", but to search the source file, the way you did it is valid, along with several other, such as using the module inspect:…
-
1
votes1
answer149
viewsA: PHP for each with an if rule
Just put the if within the loop, before any HTML code, conditioning it: <?php $i=-1; foreach($this->rows->rows as $row): if (number_format($row->amount_paid,2) != 0): ?> <tr…
-
4
votes1
answer472
viewsA: Error using monolog: PHP Fatal error: Class 'Monolog Logger' not found
As discussed in the comments, seeking to better understand the problem, the lack of file loading autoload Composer makes PHP not know how to find the classes. Composer does magic, but not so much.…
-
13
votes1
answer197
viewsA: Why does '-1' have to be placed right after a variable?
In Python, as in many other programming languages, the index in vectors starts at zero. However, it is not common for you to provide the user with a list of options that starts at zero, usually…
-
1
votes3
answers119
viewsA: Create Page Loop 3 times
Whereas you have the relationship between the tables enterprise and director, in order to store the id of the company in the director’s register, something like: create table empresas ( id int, name…
-
1
votes1
answer163
viewsA: Function "Extract()" does not work inside the foreach loop
The function extract, PHP, has the following syntax: int extract ( array $var_array [, int $extract_type [, string $prefix ]] ) Parameters: $var_array: a variable of type array associative. For each…
-
1
votes1
answer437
viewsA: How to create this expression in C#
Basic mathematics: valorComDescontos = valorTotal - (valorTotal * percentual) You will have the values of valorComDescontos and percentual, seeking the value of valorTotal. First, put in evidence on…
-
1
votes1
answer201
viewsA: Problem uploading PHP files
Realize that the array $_FILES["fotos"] has only 5 positions (name, type, tmp_name, error, size)? So only 5 photos are recorded in the bank. Try to iterate on $fotos["name"], for example: if…
-
4
votes5
answers13183
viewsA: Python - NIM game
Selecting the type of game First, we will solve the problem of knowing which type of game will be run: partida or campeonato. Your logic works very well on this part, so let’s keep it. tipo_jogo = 0…
-
1
votes2
answers303
viewsA: How to recover data from an invalid form? PHP
If the request is handled in the same file, the reply of Marcos, where the variable is directly used $_POST, is valid. If there is a need to process the request in separate files, I believe that…
-
15
votes2
answers366
viewsA: Does using "Document.open" and "Document.close" make a difference?
Document.open The operation document.open opens a document for writing (output stream) and if there is already a document instance in document, its contents are overwritten. See below: <!DOCTYPE…
-
5
votes3
answers2684
viewsA: How to check if the form was sent empty
It is worth mentioning that using <input name="btn" type="submit" value="Enviar" />, the value of btn will always be present in the vector $_POST, because PHP treats the button itself as a…
-
2
votes2
answers764
viewsA: use variable cmd command with python
Since the difficulty is only to insert the value of the variable nome1 at the command, the solution is to use the method format of type objects string. >>> nome1 = "nome_no_arquivo"…
-
2
votes1
answer79
viewsA: How to modify a list in the global Scope using a function? Python 3
Just return the value and assign the L variable again: def lsum(x): res = [] for i in x: res.append(i+1) # <- Aqui é i+1, não x+1 return res # <- Retornando o valor L = [1,2,4] L = lsum(L) #…
-
47
votes2
answers1150
viewsA: How to count the objects present in the image with PHP?
It is worth mentioning that in this answer was more valued for the simplicity of the solution than the performance of the same. Logic The most natural thing to think about is, I’m going to go…
-
2
votes1
answer440
viewsA: select multiple jquery inputs using the name attribute
With jQuery, you can use all those selectors. For your case, the most practical is the ^. Has $("[title^='Tom']") selects all elements that have the attribute started by Tom. See below as it would…
-
3
votes3
answers922
viewsA: Check external file loading with JS
According to some examples I found on the web, just use the event window.onload to hide the div charging is not always enough, because on slower connections, the video may not be ready for execution…
-
1
votes1
answer34
viewsA: How to access a non-explicit function
If I understand correctly, the problem is to call a method of bd.collection, through a string, with the method name, which comes from another code location, probably. Something like: call the method…
javascriptanswered Woss 73,416 -
3
votes3
answers304
viewsA: How to get the highest numerical value supported by php?
Whole Official documentation: The size of an integer is dependent on the platform, although a maximum value of about two billion is the usual value (that is, the largest flagged value represented…
-
6
votes1
answer2187
viewsA: The sum of the difference between 2 Python lists
In a line of code: A = [4.34, 0.05, 0.02, 12.81, 2.16, 0.0] B = [3.96, 0.05, 0.02, 22.22, 3.41, 0.0] print(sum(abs(a - b) for a, b in zip(A, B))) The result: 11.04 How it works? First, we use the…
-
1
votes1
answer1473
viewsA: How to expect one javascript function within another?
A simple way to get around this problem is to work with callbacks. Basically, a function that will be executed when an operation is completed. In your case, rather than waiting for the return of…
javascriptanswered Woss 73,416 -
2
votes2
answers1016
viewsA: What’s Options Multiviews for?
Multiviews Functionality in your Application This is an Apache content negotiation rule. The Multiviews enabled for your application, hides the extension of a file assuming it is a directory. Below…
-
4
votes4
answers182
viewsA: How can I get a specific snippet inside a string using PHP?
One way to get the value directly, without having to work again with the return is to use the function preg_match_all. function getNumberFromFilename ($filename): int { preg_match_all("/_(\d+)/",…
-
6
votes3
answers1393
viewsA: Sort array in PHP
Sorting Algorithm The sort algorithm that will be applied in this answer is called Sorting by Insertion, or English, Insertion Sort, as is best known. The way such an algorithm works resembles a…
-
1
votes2
answers399
viewsA: While on dynamic carousel
Just formalizing the answer. Given the code: <?php $this_post_id = get_the_ID(); $urls =get_post_meta($this_post_id,'my-images', true); $totalUrls = count($urls); $number = 0; ?> <div…
-
1
votes1
answer586
viewsA: Merge two objects into one with conditional attributes in Javascript
Another way to do what you need is the one below. The interesting points are: Store the return of the condition in a variable to, if the condition changes over time, simply change a line of code;…
-
4
votes1
answer296
viewsA: Error in month language Django
If you are using the Mysql database, the problem must be in the variable lc_time_names. To check, use the following instruction: SELECT @@lc_time_names; The return must be something like this:…