Posts by Wallace Maxters • 102,340 points
1,984 posts
-
1
votes0
answers121
viewsQ: Why even set the headers the page cache is not updated?
Use the Laravel 3 in a certain system that we develop here in the company. I need that every time the application version changes, the cache of all users be updated. The programmers here have…
-
12
votes4
answers489
viewsQ: How does jQuery make parameters dynamic?
I noticed that in jQuery, parameters can often be passed or omitted, and regardless of order, they work as expected. What I mean is this. See the following codes below: $('#x').fadeOut(function(){…
-
3
votes2
answers1125
viewsQ: How to round to the nearest ten in PHP?
I saw this question here at Stack Overflow How to arrendondar to the nearest ten? and I found it very interesting. Only that the question is Javascript. How could I round a number to the nearest ten…
phpasked Wallace Maxters 102,340 -
1
votes2
answers1640
viewsA: How to know if a stdClass is empty?
Just for extra help, if anyone needs it, we could do it using a loop on top of the stdClass. If you enter the foreach is because it is an object with properties. If not, it is empty. Behold:…
-
1
votes2
answers985
viewsA: How to convert stdClass to array recursively?
If the goal is to convert the object to array recursively, here are some tips. Create a function create a role for this: function object_to_array(stdClass $object) { $result = (array)$object;…
-
2
votes2
answers985
viewsQ: How to convert stdClass to array recursively?
I have the following object: $a = new stdClass; $a->id = 1; $a->nome = 'wallace'; $a->parentes = new stdClass; $a->parentes->pai = 'Sidney'; $a->parentes->mae = 'Maria'; I know…
-
3
votes2
answers1640
viewsQ: How to know if a stdClass is empty?
In PHP, to check if a array is empty we can use the function (or language constructor) empty. Thus: $a = array(); $b = array(1, 2); var_dump(empty($a), empty($b)); // Imprime: bool(true),…
-
3
votes1
answer217
viewsQ: How to make a denial condition with instanceof, without affecting the order of precedence?
I hope the question does not sound strange, but I can clearly explain what I mean. I know that as far as checks are concerned, it is sometimes necessary to take care of the question of the…
-
31
votes4
answers52318
viewsQ: What is the difference between PUT and POST?
Some teach that POST is to send data to create something and that PUT is to update, but found poorly explained. So, after all, what is the difference between the PUT method and the POST? When I must…
-
3
votes1
answer55
viewsA: class_exists is running spl_autoloader_register
According to the PHP Handbook, just set the second parameter of this function to FALSE. Behold: class_exists('Foo', false); See the skeleton of this function: bool class_exists ( string $class_name…
-
4
votes2
answers7903
viewsQ: What is the difference between offset(). top and position(). top in jQuery?
What’s the difference between $(el)offset().top and $(el).position().top in jQuery? I realize that some cases the results are different.
jqueryasked Wallace Maxters 102,340 -
4
votes1
answer2938
viewsQ: How to convert a string to Base64 in Python?
I am starting in Python and come from PHP. To convert a string to base 64 in PHP, I do it as follows: base64_encode('stack overflow'); //c3RhY2sgb3ZlcmZsb3c= And in the Python, how do I do that?…
pythonasked Wallace Maxters 102,340 -
8
votes3
answers1791
viewsQ: Is there any way to convert a string to base 64 in javascript?
Is there any way to convert a string to base 64 in javascript? In PHP we can do so: base64_encode('stack overlow'); //c3RhY2sgb3Zlcmxvdw== How can I do this in javascript?…
-
2
votes3
answers66
viewsQ: How do I use my jQuery extension in the on function?
In jQuery, I know it is possible to extend and create functions for certain types of operations through $.fn. Thus: (function ( $ ) { $.fn.clickOut = function (callback) { var that = this;…
jqueryasked Wallace Maxters 102,340 -
4
votes2
answers7536
viewsQ: Select textarea text by clicking
How can I do it, when I click on a certain button, the text of a given textarea or input be selected? I wanted answers with jQuery and jQuery solutions (pure javascript).…
-
4
votes3
answers434
viewsQ: What is the maximum value for javascript number?
In PHP, we have a limit to the values of the type int, which is demonstrated by the constant PHP_INT_MAX. echo PHP_INT_MAX; // Imprime: 9223372036854775807 What about javascript? How do I find the…
javascriptasked Wallace Maxters 102,340 -
4
votes2
answers15191
viewsQ: How do I know if a list is empty in Python?
I’m starting at the python and always end up appearing some doubts at the beginning. I need to know how to test if a list is empty. As I always say, I come from PHP. So I used to make these shapes:…
-
20
votes4
answers3838
viewsQ: What is the expression 'if __name__ == "__main__"' for?
I notice some scripts on Python, at the very end of the code, have the following expression: if __name__ == "__main__": #faça alguma coisa aqui What’s the point of this?…
pythonasked Wallace Maxters 102,340 -
5
votes3
answers833
viewsQ: With the ninth digit on the phones, how can I solve the problem of displaying 8-digit phones?
This was a question that came to me with the news of the ninth digit in the phones here in Brazil. I have in the system a list of phones that are saved along with the DDD. How could I do for an…
-
0
votes3
answers7891
viewsA: How to create a click event that is only called when clicking outside a div?
When we need to do something countless times, maybe it’s worth creating an extension on jQueryin order to solve this problem. I did it this way: (function ( $ ) { $.fn.clickOut = function (callback)…
-
3
votes2
answers2678
viewsA: css files in Laravel 4
Amanda, you just need to put them in the folder public of the application. You can create a folder for each document/script type you will use. Example: public/css public/js I don’t usually use the…
laravel-4answered Wallace Maxters 102,340 -
1
votes1
answer32
viewsQ: Why does the Splstack class not serialize with the json_encode function?
In PHP there is a problem regarding the serialization of the object. Usually this is solved when the class that attempts to serialize implements the interface JsonSerializable. class Obj implements…
phpasked Wallace Maxters 102,340 -
12
votes2
answers213
viewsQ: What is the name of the operation when we make an ajax request to the internal server that in turn takes information from external?
I always do that, but I don’t know what the technical name of it is. When I need to make a request, where I take information from an external content (for example facebook), I always use my server…
-
3
votes2
answers419
viewsA: Is it possible to restrict access to variable information with Angularjs?
Friend, there is no way to do this through javascript. The only thing that can be done - and that’s what I would do if I had to hide that information - is to make a proxying. Translating, you will…
-
36
votes5
answers4312
viewsQ: What does Nan mean in Javascript?
When we have an error in the sum of a number with Javascript, it is returned NaN. Example: parseInt('a') + 3; //NaN What does it mean NaN?…
-
2
votes3
answers67
viewsA: Format buffer, php
The encoding returned in your example is part of the serialization generated by the function json_encode. Example: json_encode(array( 'conteúdo' => '<div class="alguma-coisa">Alguma coisa e…
phpanswered Wallace Maxters 102,340 -
12
votes2
answers3131
viewsQ: How can I turn line breaking into <br /> in Javascript?
In PHP, we can convert a line break to a <br/> through function nl2br. What about Javascript? How can I do this safely? I decided to ask the question because I don’t know if a simple…
-
4
votes1
answer104
viewsA: What is the Emptyiterator class for?
I believe that the solution to this question can be found in the answer given by @Maniero, here at SOPT, What is the Null Object standard for? Probably the EmptyIterator was created as a way to make…
-
2
votes3
answers396
viewsQ: Why does the php string sometimes return instead of a few accented letters?
I asked a question about coding problem and json_encode of PHP. In order not to generate a very broad question, I decided to ask this question separately. Because sometimes PHP returns the character…
-
2
votes3
answers9219
viewsQ: json_encode returning "Malformed UTF-8 characters, possibly incorrectly encoded"
I’m using the Laravel 3 in a given system. Sometimes I’m having a problem with the json_encode, returning false in some cases. In this code, I upload an external page and, with the DomDocument, make…
-
5
votes6
answers992
viewsA: Like saving today at the bank?
In my opinion, you should save the full date of today. If you need to filter the day, use specific functions of MYSQL for that reason. Defines your bank as CURRENT_TIMESTAMP in the field referring…
-
2
votes3
answers527
viewsA: Take data from the page by javascript and convert it to whole
I notice from your code that there is an error. You used the regular expression /[\d]/g. But this regular expression captures numerical values. That is, you are asking to replace numerical values…
-
8
votes1
answer439
viewsQ: With doing an iterator/Generator in javascript?
In PHP, we have the Iterators and the Generator. Iterator example: $f = new FileSystemIterator(__DIR__); foreach($f as $file) { echo $file->getFilename(); } Example Generator: function…
-
3
votes2
answers2611
viewsA: Is it possible to place a 'pre-image' in the youtube iframe?
Just add the code to the given section of that url: https://img.youtube.com/vi/<codigo>/0.jpg Example https://img.youtube.com/vi/uipTZ2re4Uk/0.jpg What I did was leave a fixed image. When the…
-
2
votes1
answer1301
viewsQ: What is the meta tag with itemprop="image" attribute for?
Out of curiosity, I used the Google Chrome option to view Google’s source code, and there I found a meta tag with an attribute itemprop="image". Thus: <meta…
-
7
votes3
answers6427
viewsQ: When should I use Empty or isset?
I noticed that some people have doubts about the use of these two functions, or if they have no doubts, they seem to apply unnecessarily one of these functions, and in certain cases the other serves…
-
11
votes1
answer3807
viewsA: Block direct access to a page
More simply, if you use pure PHP, you can do so: session_start(); if (empty($_SESSION['admin'])) { return header('location: login.php'); } The empty will already assess whether the value of admin…
-
29
votes2
answers1630
viewsA: What does the + sign in CSS mean?
That selector + in CSS is called Adjacent sibling selector. The sign of + (Adjacent Selector) in CSS reminds me a lot of the method siblings jQuery, which is intended to pick up a sibling element.…
-
5
votes5
answers446
viewsQ: How can I capture a favicon from a site via PHP?
I upload an external content from a website and then import it to the DOMDocument. Currently, I can capture tag information title easily. I do so: $dom = new DOMDocument();…
-
0
votes2
answers1163
viewsQ: Copy local computer file to remote via terminal
Is there any way to copy a file from a local folder to a remote, via the terminal? Something like the command ssh?
-
5
votes1
answer506
viewsA: Error removing accents from a string for creating friendly Urls
You just want to convert the accents to ordinary letters? Use the function iconv. So do it like this: echo iconv('utf-8', 'us-ascii//TRANSLIT', 'Pêra maçã côco'); Exit: Coconut maca See working on…
-
12
votes7
answers1017
viewsQ: Is there any way to know if an array is associative or sequential?
In PHP, a array can be both associative as it can be a list, with sequential numbers. Is there any way to detect this difference in PHP? Example: $a = array('item 1', 'dois' => 'item 2'); //…
-
6
votes2
answers204
viewsQ: get_called_class or new Static?
I don’t remember which PHP library I saw this, but there was a code snippet where, to get a new instance of the current class, the function was used get_called_class. But PHP has the keyword static,…
-
1
votes1
answer71
viewsA: Criticizing empty field in PHP
First I’d trade an excerpt of your code for htmlentities, to avoid problems with the impression of value: <input type="text" style="color:chocolate" size="1" id="note1" name="note1"…
-
3
votes1
answer62
viewsQ: Is it possible to load undescore templates externally with javascript?
I usually use Template Engines in order to render HTML via Javascript. I commonly use undescore.js. I really like this way to make it easier to create HTML with Templates. Example: Somewhere in the…
-
20
votes3
answers2999
viewsQ: What is the difference between for...of and for.. in?
I was taking a look at that question from the SOEN and there I saw this for..of. I’ve never seen that before in Javascript. This is a new resource and we can implement it reliably, or we should…
-
2
votes1
answer3089
viewsQ: Is it possible to pass variables by reference in javascript?
In PHP it is possible to pass variables by reference when we flag the parameter name with a & before. And thus, the variable can be changed without the need to reallocate value. Example:…
javascriptasked Wallace Maxters 102,340 -
2
votes1
answer54
viewsQ: Why does a javascript array continue to the same size even when we use delete?
I was running some tests on javascript and I realized that when I use the function delete in an index of a array, the array is still the same size. Example: a = [1, 2, 3] delete a[1]…
javascriptasked Wallace Maxters 102,340 -
2
votes2
answers75
viewsQ: Is there any way to call an action when the method does not exist in a javascript object?
In PHP, we have some special methods that can be included in a class. One of them is the __call, that causes an action to be invoked (through it) when a method does not exist in a class. Example:…
javascriptasked Wallace Maxters 102,340 -
4
votes4
answers205
viewsA: How do you round it up in PHP?
Use the function ceil. ceil(1.1); // Imprime 2 This function is usually used to know the number of pages that will be generated in a pagination. Example: $total = 100; $limit = 12; $pages =…