Posts by bfavaretto • 64,705 points
902 posts
-
15
votes3
answers20650
viewsA: When to use Success: Function() and . done(Function()) in asynchronous requests?
The practical results are the same. The difference is mainly in code style. As promises (in jQuery, implemented as deferred Objects) are a widely used model for handling asynchronous operations, in…
-
0
votes1
answer86
viewsA: How do I make a case when no load data infile?
The CASE WHEN does not allow you to define a SET whole as you tried to do. You can only use it on the right hand side of the assignment, so: ... SET `Modelo` = trim(@modelo), `tipo` = trim(@tipo),…
mysqlanswered bfavaretto 64,705 -
2
votes2
answers1944
viewsA: How to create an event for href="javascript:void(0);" onclick="?() ;">
You don’t need Javascript to do this, your mistake is trying to use JS where you don’t need it. This should work (assuming your file listing the products is called produtos.php): <a…
-
5
votes3
answers199
viewsA: A mathematical method for knowing how many carrys in a sum
I did not understand 100% the mathematical solution of Leo, maybe it is the same that I will show here. I found on the site Math Overflow a discussion indicating a relationship between the number of…
-
3
votes1
answer196
viewsA: How does callback sort functions work internally?
The programmer does not have access to the algorithm that the language uses to sort, and this probably depends on the implementation. But whatever the sort algorithm, it works by comparing pairs of…
-
5
votes3
answers271
viewsA: Change read-only property in class itself
Use a private Setter: public string PropriedadeDeMinhaClasse { get; private set; } Hint found here:…
-
3
votes2
answers271
viewsA: Form for mobile phones
This doesn’t work and makes your code fail: var obg = form[i].obrigatorio; Like obrigatorio is not a standard HTML attribute, there is no automatic property of the same name in the object. You need…
javascriptanswered bfavaretto 64,705 -
4
votes4
answers810
viewsA: SQL LIKE clause does not work with Sqlparameter
One of the ways to resolve: cnxCli.sel = "SELECT * FROM cliente WHERE Nome LIKE CONCAT('%', @Nome, '%')";
-
1
votes1
answer850
viewsA: Progress-bar to DOWNLOAD files in Jquery
Answer originally included by the author as part of the question Until I added codes here, there, and I did it! Follows the code: function downloadFile(opcoes){ var options = $.extend({…
-
25
votes2
answers8548
viewsA: What is the asymchronism?
Definitions Synchronous or asynchronous relates to the execution flow of a program. When an operation executes completely before passing control to the next, the execution is synchronous. This is…
asynchronousanswered bfavaretto 64,705 -
3
votes1
answer191
viewsA: Select td based on text
Well, the table id was wrong in the code (in camelCase when the html is in low box). CSS is not able to filter by content, the [] is only valid for attributes. But since you’re using this inside…
-
1
votes1
answer90
viewsA: How to print the prefixes together with the array?
Look, what you have there is an array with an object inside: [ { } ]. There is nothing else in this array, but I will assume that there may be other objects with the same schema. And this object has…
-
3
votes1
answer253
viewsA: Error: Cannot read Property 'each' of Undefined
Use jQuery.each instead of $.each. Apparently the alias $ does not exist in your program.
-
6
votes2
answers113
viewsA: How to prevent a plugin from conflicting?
What makes the function anonymous is that it has no name :) Look at this: (function ( $ ) { Where’s the name? No, so it’s an anonymous function. The surrounding parentheses are needed for a syntax…
-
4
votes2
answers222
viewsA: What is the difference between this and var within a Javascript class?
The difference is in the instances you create of this "class". The instance only exposes what is in this her or has been inherited: var objeto = new Func(); objeto.fn_this(); // "this"…
-
7
votes1
answer2141
viewsA: Using a function variable in another function
Declare the variable out of functions at a level of scope common to both: var IdResult1; el1.on('change', function'){ //função pra trazer o valor que quero IdResult1 = 123 //valor que a função acima…
-
12
votes1
answer300
viewsA: What are the improvements that the Spread Operator implementation will bring to javascript?
The question itself already brings two of these improvements, right? Well, almost. Actually, the second example is quite different from the first. The first example shows what is commonly called…
-
11
votes1
answer85
viewsA: Mechanisms for form validation
HTML5 Practical, but can’t handle all the cases, nor has support in all browsers Javascript Quite flexible, but only for those who have JS enabled. Can be swindled by turning off the JS jQuery Same…
-
15
votes4
answers2497
viewsA: Merge two Javascript arrays
There is no native function for this, but you can build a: var array1 = ['abc', 'def', 'ghi']; var array2 = ['123', '456', '789']; if(!Array.prototype.hasOwnProperty('interpolate')) {…
javascriptanswered bfavaretto 64,705 -
2
votes3
answers210
viewsA: How to recover the first letter of a Swift array
If you do not want to use the extension suggested in Jeferson’s answer, use the same method as her: var wordEasy = ["uva", "manga"] var teste: String = wordEasy[0] let u = teste[teste.startIndex]…
-
5
votes1
answer8292
viewsQ: How to discover the original encoding of a filename (or any string)?
I have a number of files that seem to have been generated on different operating systems, because the character encoding of their names seems to vary between them. There are names whose accents…
character-encodingasked bfavaretto 64,705 -
1
votes2
answers52
viewsA: Query brings data ignoring $conditions
Change this: 'data_despesa like'=>"%$this->dataDespesa%" for: "data_despesa like '%{$this->dataDespesa}%'"
cakephpanswered bfavaretto 64,705 -
10
votes2
answers5991
viewsQ: BIT(1) versus TINYINT(1) for boolean values
I may be wrong, but I have the impression that in practice the default in Mysql is to use columns of the type TINYINT(1) to store boolean values, true/false or 0/1. Only that TINYINT accommodates up…
-
2
votes1
answer75
viewsA: SQL Server and JSON to generate Highmaps: query very long and difficult to handle
The query can simply be select maior_uf AS estado, count(*) as total_estado, count(case when natureza = 'PMI' then natureza end) as 'pmi-br', count(case when natureza = 'PPP' then natureza end) as…
-
5
votes1
answer47
viewsA: Calculate quantity by the whole number
Divide by 10, take the whole part, and use the result in your checks. For example: $dezenas = floor($num / 10); if ($dezenas == 1) { } else if ($dezenas == 2) { } // etc.…
-
3
votes2
answers71
viewsA: Select random with Sqlserver (mssql)
According to this response from the OS, you can use ORDER BY NEWID(), that generates a uuid.
-
24
votes6
answers3282
viewsA: Is there a Javascript class?
Formally, Javascript has no classes. It is an object-oriented language, but one that implements prototypical heritage (see also). Even so, there have always been construction functions, which end up…
-
5
votes4
answers5900
viewsA: How to receive form data with pure HTML?
Only with HTML is not possible. If you use GET, it is possible with HTML + Javascript, as shown in other responses. To use POST, you need a language that runs on the server.
htmlanswered bfavaretto 64,705 -
3
votes1
answer262
viewsA: PHP variable in JS inside While
PHP runs first, and only when it finishes will JS run. PHP runs on the server, and JS runs on the client (browser). I suggest you build the data structure in PHP, and pass it ready to JS. Something…
-
1
votes2
answers143
viewsA: How to create function for view?
The mistake says he’s hoping that the action, in his controller, calling esqueci_senha, and not esqueciSenha. I guess just fix it in the controller: function esqueci_senha() { // código da action }…
-
21
votes1
answer329
viewsQ: How to implement memoization in a PHP function?
I saw it today in a reply the following code: function fibonacci($n) { $a = 0; $b = 1; $c = 1; for ($i = 1; $i < $n ; $i++) { $c = $a + $b; $a = $b; $b = $c; } return $c; } echo fibonacci(100)…
-
12
votes5
answers8511
viewsA: Reverse array order
As other responses have indicated, you can use the method reverse array. But note that this changes the original array, and there are times when it is necessary to have a copy. To avoid changing the…
javascriptanswered bfavaretto 64,705 -
14
votes2
answers384
viewsA: GMT returns -0306 instead of -0300, what is the reason?
Until 1914, Brazil used the LMT (Local Mean Time) as a time reference. Since that year, it has adopted different time zones, with differences in round hours in relation to UTC. The LMT is based on…
-
6
votes2
answers738
viewsA: Why use/not use * box-Sizing?
There are two big reasons why you want to standardize the box model in your documents, or at least in a part of them: You want or need to use the model "traditional" (border-box, the old model that…
-
7
votes2
answers233
viewsA: Why create the __proto__property when using Object.create?
The __proto__ is the prototype of the object (unlike .prototype of a function, which is not a prototype of it, but of the object it creates when invoked as a constructor). Only that __proto__ was a…
javascriptanswered bfavaretto 64,705 -
10
votes2
answers14461
viewsA: Convert string to date
The builder Date (as well as the method Date.parse) is very restricted in the accepted format. The format is the one you quoted: YYYY-MM-DDTHH:mm:ss.sssZ The Z refers to the UTC time zone. It has…
javascriptanswered bfavaretto 64,705 -
5
votes1
answer572
viewsA: How to use two css files in an html
Just add them both to the <head> of your HTML: ... <head> ... <link rel="stylesheet" href="/css/css1.css" type="text/css" media="screen"> <link rel="stylesheet"…
-
4
votes2
answers12933
viewsA: Multiple conditions on an if
Use &&: if (X->meia != 's' && X->meia != 'S' && X->meia != 'N' && X->meia != 'n') { printf("\nDigite S ou N!!\n"); }…
-
4
votes1
answer102
viewsQ: How to model a set of 1 to 4 predetermined values
I am modeling a Mysql database where the main entities are documents. Among several other fields, these documents relate to one or more phases of a particular project. There are 4 basic values…
-
3
votes3
answers382
viewsA: Design Standard for Filters
Answer originally posted in the body of the question by its own author Well, I found a pattern that helped me and a lot, the Decorator, follows a reference link "Decorator Design Pattern" and below…
-
5
votes3
answers432
viewsA: Javascript - Thread, Asymchronism, Ticks
Its function betweenDates is very imprecise, it never uses millisecond information that objects of the type Date include. I did a test by slightly changing your code, and the result was 5.007…
-
3
votes1
answer97
viewsA: Doubt with javascript console.log
Just stop printing on the console. The function console.log serves only to print something on the console, does nothing else. You can find more information about the console here on the website:…
-
4
votes1
answer744
viewsA: Using PHP in the terminal, xampp
At the root of your user folder, ~, has a file called .bash_profile. Add the following at the end of it: export PATH="/applications/XAMPP/xamppfiles/bin:$PATH" Save the file and restart the…
-
25
votes2
answers2766
viewsA: What is a string template (literal string declared with "`" grave accent) for in Javascript?
The backticks delimit templates (strings template), where the language is able to interpolate variables and expressions. Example of MDN: var a = 5; var b = 10; console.log(`Fifteen is ${a + b}…
-
8
votes2
answers3255
viewsA: I need to return the null values of this Inner Join
What the INNER JOIN is precisely to eliminate the NULLs. It only establishes relationship when there is no NULL at either end. What you’re wanting is done with LEFT JOIN: SELECT credor.nome,…
-
13
votes4
answers1603
viewsA: Doubt about "encrypted code" (obfuscated) in Javascript
The code is not encrypted, only partially obfuscated. Whoever did this took advantage of the fact that Javascript strings can contain any escaped UTF-16 character in the format \xNN, where NN is the…
javascriptanswered bfavaretto 64,705 -
4
votes1
answer188
viewsA: var_dump and print_r Not Yet Implemented
I think that this means that the object in question does not implement a supposed internal method that determines how the output of this type of object in these functions will be. Something like a…
phpanswered bfavaretto 64,705 -
6
votes3
answers158
viewsA: How to reuse the connection in the subclass?
You can decouple this code and delete the inheritance. Start with a connection class that opens the connection to the bank as soon as it is instantiated: class Conexao { // (...) // Tudo o que tinha…
-
2
votes1
answer67
viewsA: Jquery - Mouse events vs Z-Index
You need to use mouseenter instead of mouseover: $(document).ready(function(){ $('.red').mouseenter(function(){ alert('in'); }).mouseleave(function(){ alert('out'); }); }); The mouseenter matches up…
-
1
votes1
answer105
viewsA: Asynchronous jQuery-Prototype conflict
It does not print because the x is outside the scope (must be giving an error, no?). You need to declare x in the outermost scope: var x = 0; // DECLARE AQUI (function($){…