Posts by Wallace Maxters • 102,340 points
1,984 posts
-
6
votes2
answers1261
viewsQ: Is there any way to detect that an attribute has been changed in HTML?
I wonder if there is a way to check by javascript whether an attribute of an element has been changed or not. For example: If I have one input, I place in it the attribute required, and someone goes…
-
2
votes2
answers2503
viewsA: How to search for a string inside an object in an array?
See if this solution suits you: var resultSearch = []; for (var key in Roteiro) { Roteiro[key].forEach(function(value, key){ for (k in value) { if (/roteiro/g.test(value[k])) {…
-
6
votes2
answers5497
viewsA: How to perform method overload with PHP?
As stated before, there is no method overload in PHP. What can be done is to use function arguments in dynamic ways, as I’ve seen in some frameworks such as Cakephp and Laravel 4. Example: <?php…
-
5
votes2
answers1198
viewsQ: DOMPDF: Frame not found in cellmap. What causes this error?
This problem has been haunting me for a long time and I still haven’t found a solution for it. I have developed a system, where in a given location, the user can print a report, which is generated…
-
0
votes1
answer440
viewsA: Add and remove fields generated via Cakephp
Cakephp follows a standard for creating form fields, if you’re using Cake Form Helper The pattern is always like this: $this->Form->input('model.id'); // <input type="text"…
-
4
votes3
answers12947
viewsA: Onclick in a select option
I believe what you’re trying to do is a onChange, and not a onClick. At least I’ve never seen click event working for select or option. You can do it like this:…
-
7
votes2
answers1844
viewsQ: How to declare an anonymous function in Python?
How do I declare and how an anonymous function of Python?
-
10
votes1
answer452
viewsQ: jQuery does not use the HTML5 dataset on the date?
When modifying a certain initial value of data from jQuery, I noticed the value of the dataset is not modified. So I drew up the following test: HTML: <div data-value="initial value"…
-
10
votes2
answers2045
viewsQ: Are functions and methods in PHP case-insensitive?
Some time ago, by an accident at the time of a debug I realized that PHP makes no difference between upper and lower case when calling a function. Example: print_r($teste); print_R($teste);…
-
0
votes2
answers749
viewsA: I need the file to list a specific folder
There is an easier way to list a directory in PHP. This can be done through the class FileSystemIterator; See in small example: $fileIt = new FileSystemIterator(__DIR__ . '/arquivos');…
phpanswered Wallace Maxters 102,340 -
9
votes1
answer1798
viewsQ: What are the advantages of using a "Generator" (Yield) in PHP?
As of PHP 5.5, the Generator. It can be used within a function from the keyword yield. In the manual, we have an example where one is compared to function range(0, 1000000) (that theoretically would…
-
10
votes3
answers5279
viewsQ: How to check if a variable was set in Python?
Is there any way to check whether a variable was set in Python or not?
-
1
votes1
answer76
viewsA: Avoid Overloading of attributes when using magic methods
When I had this problem, the solution was to declare __get with return by reference. This can be done through the character &. Behold: <?php class User{ private $email = null; private $pass =…
phpanswered Wallace Maxters 102,340 -
7
votes2
answers189
viewsQ: Which Exception should I release according to each situation?
In PHP, we have several types of exceptions that can be released. Among them: BadFunctionCallException BadMethodCallException DomainException InvalidArgumentException LengthException LogicException…
-
1
votes1
answer83
viewsQ: Ignore data type check when using $.inArray
I’m having the following problem with the jQuery: When I try to check an existing value within an array, using the method $.inArray, it is returning an unexpected result. Example: I want to check…
-
4
votes2
answers257
viewsQ: Restrict object method override in javascript
I’m trying to create an object where your methods can’t be changed. That is, its value, even if modified, should continue as originally defined. Example: var object = (function(object){…
-
1
votes3
answers165
viewsA: Does not display user names in Jquery Alert
You don’t need the i++ to perform this operation. You do not need to counter! The each jQuery uses the this inside the callback as the current element within the context of the loop. See a modified…
-
4
votes3
answers1446
viewsQ: Specify fields I don’t want in Mysql
In Mysql, when we will make a SELECT, generally we can specify each field we want to return. SELECT id, nome FROM usuarios But let’s imagine a scenario where I have 50 columns in a table and I…
-
1
votes3
answers367
viewsA: Stop Menu scroll in certain resolution
You must use the $(window).resize() to the jQuery detect that the screen has been resized Example: $(function() { $(window).resize(function(){ if ( $(this).width() < 760) {…
-
1
votes1
answer784
viewsQ: How to delete all records of a belongsToMany
In the Laravel, when we have a relationship many for many, we have a method called attach and detach The attach adds entry into a relationship n:n, and the detach remove them. In both cases, these…
-
2
votes3
answers656
viewsQ: What is the best way to convert HTML entities with Javascript?
Through researches in the English OS, I learned to do decoding and encoding of HTML entities as follows: var wm = (function(wm){ wm.encodeHTML = function (html) { var t =…
-
3
votes1
answer325
viewsA: How to work with Séssions at Silex
After installing the Silex and read some articles on Symfony 2, I’ve come to a nice conclusion. By default, it is only possible to include in the Symfony 2 values of the type chave/valor. It’s like…
-
3
votes2
answers833
viewsQ: How do I know if request.FILES is empty?
I have a code on Django where I want to upload a file from a form. At a given precise moment check if the index exists "arquivo" within the variable request.FILES I did it using the method has_key…
-
13
votes2
answers1520
viewsQ: What are the benefits of using HTTPS?
Where I work, people always comment that they have to put HTTPS in the systems to make it safer. I’d like to know: On what the SSL makes a website safer? What are the types of attacks they avoid? In…
-
5
votes3
answers10914
viewsQ: How to remove the first element from a list in python?
I have the following code: On the command line > teste.py primeiro segundo In the script teste.py: import sys print(sys.argv) And I have the following return: ['c:\\teste.py', 'primeiro',…
-
7
votes3
answers1561
viewsQ: Increment letters in PHP?
Recently I needed to increment letters in PHP within a loop. For each iteration, instead of numerical indexes, it needed letters of the alphabet. So, as I already know that PHP does letter…
-
4
votes1
answer1280
viewsQ: Save full path in the bank or just name with extension?
In the systems I used to develop back in the day, I used to save the entire file path in the database . Example: c:\xampp\htdocs\teste\imagens\post_44\stack_overflow.png // Image table imagem - id =…
-
10
votes2
answers15531
viewsQ: How to find the version of Laravel installed in my project?
I was with the version of Laravel 4.2.7 installed on my computer. I missed two important methods in Illuminate\Database\Eloquent\Builder, which is the whereDoesntHave and the doesntHave. When…
-
48
votes3
answers22473
viewsQ: What is "with" in Python for?
I’m doing a study on Python and I came across this guy with. I know him from Javascript. However, I don’t know how he works in Python. Most of the examples I’ve seen show it being used in reading…
-
1
votes2
answers3388
viewsA: How to query a data in an array in Javascript
To check if a number exists in the array, just use the method indexOf if (sorteados.indexOf(sorteado) === -1) { // Insere o número pois ele não existe } indexOf will return -1 whenever there is no…
javascriptanswered Wallace Maxters 102,340 -
1
votes1
answer53
viewsA: Automatic slider plus controls. Divergence between the two
Instead of defining the code that passes to the next slide inside the setInterval, you could simply simulate the click (where the passage to the next item is set by jQuery) within that setInterval.…
-
2
votes3
answers612
viewsA: How to leave empty textbox after an Ajax request via Post?
Luiz Henrique’s answer is fine, but whenever we can simplify something you’ll make it better You can do this in a row: $('#meu-form').get(0).reset(); That way, if you add a input the more in your…
-
0
votes2
answers485
viewsA: Extract only extensions specific to a ZIP
Based on the advice given by @Rodigorigotti, I developed a code to delete undesirable extension files. The extraction is done to a secure folder, so as not to give direct access to the folder to the…
-
0
votes4
answers1483
viewsA: Release link after completing form
If I understand correctly that you want to release a link being released after the data is filled in, do the following. Change your HTML to: <form id="formulario">…
-
2
votes2
answers485
viewsQ: Extract only extensions specific to a ZIP
I am developing a system where in some part of it the client can send a file ZIP containing only images. I’m willing to do it in a way that I can extract from this ZIP only files that contain…
-
4
votes1
answer216
viewsQ: How does the reference to undeclared variables work in PHP?
In PHP, according to the manual, the reference of one variable serves for a variable to point to the same place where the other is in memory. I also saw that when we declare references to a variable…
-
5
votes1
answer1427
viewsQ: Performance of the Eloquent of the Laravel relationship
I realize that in the Laravel 4 Framework, when we have a relationship, rather than using a JOIN of Mysql in the source code of Eloquent, he uses a select. For example. I have these two models.…
-
0
votes2
answers76
viewsA: Specific sorting of a list without plugin
Based on your Jsfiddle, I created this solution for your problem. Example: $(function(){ $('.pagination').find('a').click(function(e){ e.preventDefault(); var pos = $(this).data('position'); var…
-
3
votes1
answer4875
viewsA: Replace inverted bars with single bars - image URL
This is because, the way you declared the string, you should have put two backslashes for each bar you want to print. It’s called "escaping the bars". See about this in "Escape Sequences" in the…
-
1
votes2
answers102
viewsA: Is Binary cast available in PHP?
Following @gmsantos' instructions, I created this Bug Reporting there in PHP. According to the response of the user identified as [email protected], the reason for the binary not function as expected is…
-
5
votes2
answers180
viewsQ: Use Static Closures or Closures in PHP?
As of PHP 5.4, the Closures (Or funções anônimas), when declared within the context of a class method (other than static methods), automatically inherit to "within" the $this as a reference to the…
-
3
votes2
answers102
viewsQ: Is Binary cast available in PHP?
PHP has a cast (that until then I did not know), called binary. Example of Handbook: $binary = (binary)$string; $binary = b"binary string"; According to the PHP Handbook: (Binary) - converts to…
-
13
votes2
answers869
viewsQ: What is Finally for in PHP 5.5?
PHP 5.5 implemented a feature (which I’ve heard exists in other languages) called finally, in the handling of exceptions (together with the try/catch) We have the following example:…
-
3
votes1
answer127
viewsQ: How does Javascript’s async attributo work?
I was reading about the attribute async, which is used in the tag <script>, and I got curious and doubtful about some things. According to the W3school: A script that will be run…
-
3
votes2
answers581
viewsQ: Use Cookie or Localstorage?
I was developing a plugin for jQuery and needed to store some information. I thought I’d use the localStorage of HTML5, but I was warned by a friend that in some older versions of browsers would not…
-
5
votes1
answer248
viewsQ: Good practice with XHR requests
I have the following doubt: When I make a request via AJAX and I wish to "ride" the HTML based on data from a banco, is wrong (in terms of "good practice") to already return the HTML in the request…
-
22
votes1
answer3430
viewsQ: In the new browsers now there will be no more synchronous requests?
I saw it today in mine Google Chrome, updated to the version 40.0.2214.91, a message that said Synchronous Xmlhttprequest on the main thread is deprecated because of its detrimental effects to the…
-
0
votes2
answers200
viewsA: $(Document). height() does not return the correct value
Do so: $(document).outerHeight() This returns the value of the element also counting with the padding
jqueryanswered Wallace Maxters 102,340 -
2
votes1
answer419
viewsA: How to use the "Answer" of an XMLHTTPREQUEST in Cakephp (2.5)
Let me give you a little example of how I used to use Controller of Cakephp class JsonController extends AppController { public function teste() { $this->autoRender = false; $json =…
-
8
votes1
answer322
viewsQ: How to turn E_PARSE errors into Exception in PHP?
My question is this:: PHP has a great feature that lets you convert errors that can occur in an application into Exceptions. This can be done through class ErrorException Example:…