Posts by Thiago Barcala • 574 points
19 posts
-
1
votes1
answer36
viewsA: Update exported property in nodejs
You could do it like this: // Importa o model const loading = require('../models/loading'); let loadingWindow; const exported = { createWindow: function (dir) { exported.window = loadingWindow = new…
-
0
votes1
answer310
viewsA: Error: 1215 cannot add Foreign key Constraint -Mysql 5.7
Use this statement for the Period table: CREATE TABLE Periodo( sigla_curso VARCHAR(5) ,ano_grade SMALLINT ,semestre_grade CHAR (1) ,numero TINYINT NOT NULL ,CONSTRAINT fk_sigla_curso FOREIGN KEY…
mysqlanswered Thiago Barcala 574 -
1
votes1
answer188
viewsA: Canvas increasing the animation speed with each change of animation
You don’t need the line mySprite.addEventListener("load", gameLoop); in the onkeydown. Your gameLoop is already constantly scheduling the next run. If this function is invoked again, you end up…
-
1
votes1
answer126
viewsA: Grid system, calculations of
The bootstrap standard is to divide the layout into 12 columns of equal size. In this case, the 5 in the class name indicates that the element must occupy 5 columns, that is 5/12 which is equivalent…
-
0
votes2
answers121
viewsA: setTimeout doing lose value of variable?
Your problem is the reference to this. This is a fairly recurring error in Javascript. O this that you use in the callback of the setTimeout is not necessarily the same this that you have in the…
-
1
votes2
answers48
viewsA: How to do quicksort animation with canvas
The problem is that its Sleep function blocks the thread, preventing the browser from processing anything else (rendering or events). This is because Javascript is by nature monothread. You can work…
-
4
votes2
answers943
viewsA: C# - Random primes?
You forgot to reset the number of splitters to 0 at each while iteration start. Since the variable is only used in one place, it would be clearer if you declared it inside the while.
c#answered Thiago Barcala 574 -
4
votes2
answers2720
viewsA: Differences in the use of $this, self, Static and Parent
Fabio, I believe that this example you posted should not be followed (that of using Parent::setName). There is no advantage, and if using Parent this way is necessary, it is probably indicative of a…
phpanswered Thiago Barcala 574 -
7
votes4
answers229
viewsA: Is overloading methods less performatic?
It does not affect performance as the method that will be invoked can be determined at compile time. Perhaps the author of the commentary was referring to avoid abusing overloading, because it can…
-
1
votes3
answers913
viewsA: Conditions with typescript
Lacked a =... Use = for assignment. Use == or === for comparison.
-
1
votes1
answer93
viewsA: Empty shopping cart returns Invalid argument supplied for foreach()
The mistake happens because $_SESSION['monalisa_produto'] is not defined yet, or has a non-extendable value. You can use: if (isset($_SESSION['monalisa_produto']) &&…
phpanswered Thiago Barcala 574 -
2
votes2
answers81
viewsA: Fix incorrect module return
This is because some numbers cannot be represented exactly in floating point notation. What you can do in this case is to approximate the number to a certain number of decimal places when showing…
-
0
votes1
answer179
viewsA: Regex - remove element
The syntax depends on the regex implementation you are using. But an example using the js syntax: str.replace(/^.*([A-Z])[^A-Z]*([A-Z])[^A-Z]*([A-Z])[^A-Z]*$/, '$1$2$3')…
regexanswered Thiago Barcala 574 -
0
votes1
answer29
viewsA: Archive of Magento’s queries
The class that executes queries depends on the driver that is configured in Magento. If you are using mysqli it would be in this class:…
-
0
votes4
answers106
viewsA: What’s wrong with my class function to diminish the value?
The problem is that floating point arithmetic (float) has no infinite precision. If you add up floats values and try to compare by equality you will not always get the expected result. 1.49012e-08…
-
7
votes3
answers4426
viewsA: In practice, what is the use of C-pointers?
Pointers exist in any language, the difference is that in C they are explicit, and in other languages they are usually not explicit. When you declare an object in Javascript for example you are…
-
0
votes1
answer150
viewsA: Query single input ID - AJAX
The code always shows the details of the first client pq the inputs of all clients have the same id, and the query "$("#input_client"). val()" will always return the first input. You can fix this by…
-
0
votes1
answer45
viewsA: Variable error in Identity
By the error message it seems to me that you have not set the value of this new column in the existing records in the database. The framework is probably trying to "hydrate" the entity, but the…
-
0
votes2
answers225
viewsA: Select com group by
The only way I know to do this exclusively with SQL would be something like this: SELECT CONCAT ( 'SELECT name, ', GROUP_CONCAT( DISTINCT CONCAT( '(', 'SELECT IFNULL(SUM(value), 0) ' 'FROM tabela b…