Posts by Wallace Maxters • 102,340 points
1,984 posts
-
2
votes1
answer278
viewsQ: How to update the pivot in LARAVEL 4 using the UPDATE method?
I have two models that are linked, through the belongsToMany, a relationship table N:N. So the structure is arranged as follows: class Permissao extends Eloquent{ public function niveis() { return…
-
2
votes2
answers471
viewsQ: Decrease float accuracy in Javascript?
How to decrease the decimals of a float number in javascript? For example, I want 3.3333333333 become in 3.34. What is the simplest way to do this in javascript? I tried functions like Math.ceil,…
-
8
votes1
answer104
viewsQ: What is the Emptyiterator class for?
In the documentation of PHP, has a class called EmptyIterator When I look at the method documentation EmptyIterator::rewind(), there is written: No Operation, Nothing to do. (No operation, nothing…
-
1
votes1
answer206
viewsQ: View added values in the Formdata Object and remove
I often tried to debug an object instance FormData, but I cannot see the values stored by the method append. I tried that: f = new FormData(); f.append('name', 'Wallace Maxters'); f.append('image',…
javascriptasked Wallace Maxters 102,340 -
7
votes5
answers26812
viewsA: When is isset required?
function isset According to the PHP manual, the function isset serves to verify if a variable is existing or if it does not have the value equal to NULL. If she goes NULL or does not exist, the…
-
1
votes1
answer262
viewsQ: GIT: Problems with conflicts when there is white space
I don’t know what’s going on with the repository I’m using, but all the programmers who are using it are contemplating the same conflicts after the pull. And often these conflicts are being caused…
gitasked Wallace Maxters 102,340 -
5
votes2
answers768
viewsQ: Git repository size problem
At the company where I work, I was using Git to save a system, where three people use it. After, by accident, an image folder is sent, make a git pull has become absurd, since the downloaded data is…
gitasked Wallace Maxters 102,340 -
4
votes1
answer647
viewsA: POST request is not formatted AJAX Jquery
why is not sent the POST as I determined in the division? Probably because the jQuery serializes the object you pass in the attribute data for a form data format (Query String). Maybe the…
-
8
votes1
answer6362
viewsQ: What does L, R, NC mean in HTACCESS?
I don’t quite understand the way the flag works L. The doubt arose when I was trying to use the following script: #quando vier o "public" na url, reescreve para folder/public RewriteRule…
-
14
votes2
answers3077
viewsQ: Why in class statements in Python should we extend Object?
In the Python, when we declare a class, we extend object. class StackExchange(object): def __init__(self): pass I do not know if I am mistaken, but I had the impression that in some versions this is…
-
5
votes2
answers2743
viewsQ: How do I set a private property in Python? And is there a protected property?
I come from PHP. In it, when we want to define a property of a class as private we add the keyword private in his statement. Example: class StackOverflow extends StackExchange { private $language =…
-
1
votes2
answers29746
viewsA: How to pass data from one table to another SQL
Basically, speaking: Creates a table tabela_2 based on tabela_1: CREATE TABLE tabela_2 AS SELECT * FROM tabela_1 Delete the copied table. DROP TABLE tabela_1 Note: chaves-primárias and…
-
15
votes3
answers10708
viewsQ: What is the main difference between a Tuple and a List?
What are the differences between a Tuple and a List in the Python? Example: >a = [1, 2, 3] # [1, 2, 3] >b = (1, 2, 3) # (1, 2, 3) The Tuple, grotesquely speaking, it is a constant that accepts…
-
11
votes2
answers791
viewsQ: What are the advantages and disadvantages of declaring constants as an array?
I found way too this new Feature of PHP 5.6. It is now possible to define a array for the value of a constant. Look how cool: const BR_DATES = [ 1 => 'Janeiro', 2 => 'Fevereiro', 3 =>…
-
6
votes3
answers436
viewsQ: Why is array_shift considered a slow function?
According to the Manual, array_shift removes the first element of the array. I have seen many criticisms on the Internet about the performance of this function, because it reorder the whole index of…
-
63
votes3
answers1056
viewsQ: What is "with" for in Javascript?
What is the purpose of the with in Javascript? It works only to get the object values as if it were a variable, or it is also possible to set or change properties through it? Example: var obj =…
-
11
votes2
answers437
viewsQ: Is declaring a class named after a reserved word a good idea?
Generally, when we define names for class and functions, there is a concern when colliding with the palavras-chaves of language. The curious thing is that I noticed that in PHP it is allowed to…
-
6
votes2
answers433
viewsQ: What is the difference between the union of an array via soma operator and the array_merge function?
To join two arrays in a new array in PHP, we can do through the function array_merge or through the sum operator (+). In this case we have two examples: $a = ['stack' => 'overflow']; $b =…
-
3
votes3
answers273
viewsQ: What can change with the variadic Function implementation?
PHP 5.6 implemented a feature called Variadic Function. It is as if they were infinite arguments. They can be used both in the statement of a function as for the calling. Examples PHP 5.6 Example in…
-
11
votes2
answers1824
viewsQ: Is there a difference between strtr and str_replace?
I was analyzing the way functions behave strtr and str_replace And I noticed that, at first glance, they both seem to do exactly the same thing. Example: $translators = [ 'da hora' => 'bacana',…
-
14
votes2
answers683
viewsQ: What is the Declare keyword in PHP for?
After all, what is the key word for declare in PHP? I’ve seen explanations around, including in Manual for PHP, but still I did not find its functionality very clear. It can be useful for…
phpasked Wallace Maxters 102,340 -
1
votes1
answer1769
viewsQ: How to insert UUID automatically into a Mysql Database?
Is there any way to insert a UUID automatically in a table field, in the same way as with a field of the type AUTO_INCREMENT? In a framework for PHP, Cakephp, when defining the primary key as…
-
1
votes1
answer1106
viewsA: Subfolder problem and url rewriting with Laravel
Well, after trying, trying and trying, I ended up appealing to the following solution. In case you want to configure the Laravel 4 inside a subdirectory, we have to make a small change to the folder…
-
4
votes1
answer65
viewsQ: Why can traits have methods called directly when they are static?
I just made a question about Traits and another question came to me. If the Traits are mechanisms that facilitate the import of methods, due to the limitations of an inheritance in PHP, because…
-
5
votes1
answer143
viewsQ: Traits don’t take property superscripts?
According to the excerpt from the PHP Handbook A Trait is intended to reduce some simple inheritance limitations by allowing a developer to reuse sets of methods freely... Take an example: trait…
-
7
votes3
answers972
viewsQ: Why are there so many ways to check if a value is NULL? How to standardize?
There are certain things still that do not enter my mind regarding PHP. Because there is a function is_null, when we can simply compare the values using a comparison operator. For example $variable…
-
12
votes4
answers2074
viewsA: How to get the format in hours when it exceeds 24?
The solutions presented above are very good. However, even if it seems stupid, I discovered another solution to this problem using the function SEC_TO_TIME of Mysql. Behold: SELECT SEC_TO_TIME( 28 *…
-
14
votes4
answers2074
viewsQ: How to get the format in hours when it exceeds 24?
I’m developing a PHP system where I need to get the total time of an audio file at some point. This time is saved in the database in seconds and also in the format of hours. The problem is that when…
-
0
votes1
answer157
viewsA: How to make this insertion dynamically?
Although it is not a recommended practice, you can do it as follows. Suppose your array has 500 data, such as those generated by the function below range. We could use the function implode to bring…
-
3
votes3
answers2928
viewsA: How to replace in html string only in texts within (between) tags?
If you want to search for a specific word and replace it, without influencing tag declarations, either in name or in attributes, you can use the following example, with jQuery. $(function(){ var…
-
4
votes1
answer124
viewsQ: Is it recommended to use prototype on native objects?
I think it’s great to have my own methods imported into the Javascript native objects. For example: String.prototype.hello = function(){ return this.toString() + ' hello'; } 'Say '.hello() // say…
-
1
votes1
answer110
viewsA: How to clear the value of the parameter to enter new values?
Use the method $.param jQuery to make the job easier. Also, rephrase the way to get the url. Behold: var parametro = $.param({ fespecial: valor }); var master = location.protocol + '//' +…
jqueryanswered Wallace Maxters 102,340 -
0
votes3
answers42
viewsA: Formatting problem when injecting date into datetime attribute
Concatenating strings always ends up at some point generating some confusion. That’s why, when this task becomes constant, I usually add a method to the object String of javascript, to facilitate…
-
4
votes4
answers4234
viewsA: Convert Mysql date (YYYY/mm/dd h:m:s) to dd/mm/yyyy
If you want to return only 09 Fevereiro 2015, then do it this way: setlocale(LC_ALL, "pt_BR", "pt_BR.iso-8859-1", "pt_BR.utf-8", "portuguese"); echo strftime("%d %B %Y", strtotime($data)); In his…
-
2
votes2
answers223
viewsA: Working with Iframe
Just use the event onload to the iframe. Take an example: window.addEventListener('load', function(){ var iframe = document.querySelector('iframe'), carregar = document.querySelector('#carregar');…
-
17
votes2
answers18486
viewsQ: What is the Role attribute for?
I’ve seen a code that had that tag on it Role in a form, but I didn’t understand its use. Something like: <form role="search"> </form> What’s the tag for role in HTML5 ?…
-
4
votes1
answer245
viewsA: How to create a page numerator?
let’s do a basic example in PHP: try{ $page = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT); if (!$page) { $page = 1; // Se a "page" não existir, o seu valor é 1 } $limit = 9; $offset =…
-
0
votes3
answers4054
viewsA: Close div on an output link or when clicking outside
A good way to create the "close by clicking outside" feature is as follows: HTML: <div id="conteudo" > <a href="#">Meu link</a> <p>Se clicar aqui, não vai poder…
-
6
votes4
answers452
viewsA: & Together with PHP operators and functions
This is about the Refência. According to the PHP References, in PHP, means accessing the same variable content through multiple names Take an example: $a = 1; $b = $a; $a = 2; var_dump($a, $b); // a…
-
16
votes2
answers558
viewsA: What is the difference between $(this) and $(Event.target)?
The $(this) is exactly the current element, where the event was defined. Already the $(event.target) can be either the element where the event is assigned or the child of that current element, where…
-
2
votes2
answers97
viewsA: Remove banner depending on window size
Based on the @Beet example, we can do jQuery as follows: $(window).resize(function(){ if ($(this).height() < 600) { $('#getFixed').hide(); } else { // ação caso não seja menor que 600px } });…
-
2
votes1
answer2519
viewsA: Get window width and height
To do this using javascript only, you can use the properties innerHeight and innerWidth. They will return the current size of your window. Example: window.addEventListener('resize', function(){ if…
javascriptanswered Wallace Maxters 102,340 -
1
votes1
answer462
viewsA: File manipulation . txt
You can use the function file_put_contents to manipulate a file. Creating a TXT file The file_put_contents can be used to create a file with a certain content. Example: $filename = __DIR__ .…
phpanswered Wallace Maxters 102,340 -
6
votes3
answers94464
viewsA: How to mask an HTML5 input?
What you are wanting can be done easily with jQuery Mask. Its use is exactly as @Rafaelwithoeft described in his reply. $(document).ready(function(){ $('[name=telefone]').mask('(00) 0000-0000'); });…
-
0
votes1
answer392
viewsA: Add Input with Jquery and how to get the data from this input
Friend, the most correct way to do PHP would be by using the input value as a Array. I mean. Instead of doing this: var add = 1; function add_fields() { var d = document.getElementById("content");…
-
3
votes2
answers3377
viewsA: Meanings of data-value, data-title, data-... attributes in HTML
Very well explained by the friend @Marcelobonifazio. But only one correction: The example Javascript would actually be done by the library jQuery. Without jQuery, the way to get this data from the…
htmlanswered Wallace Maxters 102,340 -
11
votes3
answers15464
viewsQ: For increment in Python
I learned that in the Python, to make a loop with for, from 1 to 10, we use the range. Sort of like this: for i in range(1, 10): print(i) Generally, in other languages, when we require a simple…
-
0
votes1
answer98
viewsA: Insert and Edit with Codigniter
Friend, as you are using Codeigniter, I do not know if there is an effective solution in it. Maybe there’s a library or helper that can help you with that. But I believe you can solve this problem…
-
1
votes1
answer1216
viewsQ: Does using a token in an HTML form really protect against CSRF?
Cross-site request forgery - The CSRF (Cross-site request forgery- Cross-site request forgery) is a type of malicious exploitation of a website by which unauthorized commands are transmitted from a…
-
5
votes1
answer316
viewsQ: What status can I return in an attempt to submit a form without a TOKEN?
I’d like to know what the status http I must return to my application if someone is trying to forge a request via form. The application I developed is done in Laravel 4 and I’m using that…