Posts by Wallace Maxters • 102,340 points
1,984 posts
-
16
votes2
answers8142
viewsQ: What is it and what is YAML for?
Briefly, what is YAML? What are the advantages of using it? What are the disadvantages in its use compared to XML and/or JSON?
yamlasked Wallace Maxters 102,340 -
4
votes3
answers785
viewsQ: How can I make a query with LIKE or REGEXP ignoring table words?
I have the following data in a table ------------------- **usuarios** ------------------- nome ------------------ Wallace de Souza Vizerra ------------------------ Gustavo Carmo da Costa I need to…
mysqlasked Wallace Maxters 102,340 -
3
votes1
answer377
viewsQ: Foreach behavior with variables by reference
I was doing some tests and I realized that the foreach has a strange behavior. Suppose I have the following array: $array = array('primeiro', 'segundo', 'terceiro'); When I run one foreach using a…
-
4
votes2
answers141
viewsQ: How to bulk assign variables in Python?
In PHP, to make a variable assignment "bulk" (declare it on the same line), we can do using the function list. Example: list($a, $b, $c) = array(1, 2, 3); How to do this kind of bulk assignment in…
pythonasked Wallace Maxters 102,340 -
4
votes5
answers11633
viewsA: How to do a LIKE ignoring accentuation?
I solved the problem set the tables as utf8_unicode_ci We convert the character input type of the table ALTER TABLE `tabela` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; Then we convert the…
-
10
votes5
answers11633
viewsQ: How to do a LIKE ignoring accentuation?
I need to make queries in a database of registered users. However, I need this survey to be done by the name of the user, through the LIKE, and this should ignore the encoding UTF-8 present in the…
-
4
votes4
answers1510
viewsA: Why in PHP does the expression "2 + '6 apples'" equal 8?
This is because PHP creates a cast automatic string for int or float Let’s take this example: echo (float) '120.5 por cento de aumento da conta de luz'; Upshot 120.5…
-
55
votes4
answers1510
viewsQ: Why in PHP does the expression "2 + '6 apples'" equal 8?
I found the example funny, but the question is valid in the sense of understanding why PHP behaves this way. When we do the following example sum (an integer added to a string): $numero_macas = 2 +…
-
29
votes1
answer1107
viewsQ: What is Null Byte Injection? How to avoid it?
What would that be Null Byte Injection? How to avoid it?
-
39
votes2
answers5738
viewsA: What is PHP Injection? How does it differ from SQL Injection? And how do you avoid it?
Due to numerous comments published (at the time the question was asked by me), I believe there is some doubt as to the PHP Injection. So I’ll explain some points. What is PHP Injection? It is a form…
-
42
votes2
answers5738
viewsQ: What is PHP Injection? How does it differ from SQL Injection? And how do you avoid it?
What is PHP Injection? What difference does it make to SQL Injection? How to avoid PHP Injection in my application? What are the main forms of PHP Injection type attack? Updating Observing:…
-
5
votes3
answers12860
viewsQ: How to fill left zeros in Python?
In php, I know we can fill a number with zeros through the printf Example: printf('%04s', 4); // Imprime: "0004" How could I do that in Python? When I try to do it the way above, the result is not…
-
4
votes3
answers12860
viewsA: How to fill left zeros in Python?
To do this in Python, it is necessary to use the formatting argument d. Behold: print '%04d' % 4 #Imprime: 0004 % - is the modifier 0 - is the value that will be used in the fill 4 - is the quantity…
-
2
votes3
answers342
viewsQ: Run multiple animations in sequence in jQuery without polluting the code
I need that when one animation ends in jQuery, another begins. And this should be done in sequence (without running at the same time). I saw it on a project where I work a code that does this, but I…
jqueryasked Wallace Maxters 102,340 -
38
votes2
answers14936
viewsQ: What is Event-Oriented Programming?
What is event-oriented programming? What Differs between Event-Oriented Programming and Object-Oriented Programming? What languages can we cite that are event-oriented?…
-
4
votes3
answers392
viewsQ: How to open remote content with python?
In PHP, when I want to get a remote content (some url, for example), I use my own functions to open files and it works perfectly. Example: file_get_contents('/') And in Python, what is the correct…
pythonasked Wallace Maxters 102,340 -
13
votes3
answers2778
viewsA: What is the purpose of "continue" in C?
Generally, in any language, the continue indicates that the current iteration of the repeat loop must "skip" to the next iteration. Consider an example for printing even numbers only Example in PHP:…
-
44
votes5
answers7270
viewsQ: What is the difference between a "branch" and a "tag"?
In Git, what is the difference between a branch and a tag?
-
4
votes3
answers458
viewsA: How do I list all the files not added (untracked files) in GIT?
Another way to make the listing of files marked as untracked would be: git status --untracked Or else git status -u
gitanswered Wallace Maxters 102,340 -
2
votes3
answers458
viewsQ: How do I list all the files not added (untracked files) in GIT?
How do I list all the files not added in the commit on git? It would be important to have this listing so I know when to make one git add in specific files. Observing: I use the git from the command…
gitasked Wallace Maxters 102,340 -
1
votes3
answers1144
viewsA: Is there any way to use script as configuration files in python?
According to this response in the SOEN, I believe that a good solution would be to use a file json and analyse it by python. This can be done through the module json. Example JSON: { "version" :…
-
1
votes3
answers1144
viewsQ: Is there any way to use script as configuration files in python?
In PHP, we can use a PHP script to just return values, which is very useful for creating configuration files for an application. Example DB.php return array( 'host' => 'localhost', 'username'…
-
7
votes3
answers13058
viewsQ: How to do a range with letters of the alphabet in python?
In PHP, when we want to make a array alphabet letters, we can use the function range. Example in PHP: $letras = range('a', 'z'); Upshot: Array ( [0] => a [1] => b [2] => c [3] => d [4]…
-
11
votes3
answers25171
viewsQ: How to write multiple lines in Python?
How can I write a string with multiple lines in Python? As I come from PHP, I usually do so: $string = " uma linha outra linha2 " Or else: $string = <<<EOT uma linha outra linha EOT; When I…
-
10
votes2
answers1835
viewsQ: What is the difference between 'string' and r'string in Python?
I was taking a look at Django’s code, framework in Python, and I came across the following code in the file urls.py. urlpatterns = [ url(r'^articles/2003/$', views.special_case_2003),…
-
8
votes2
answers15912
viewsQ: How do I join a list in Python?
When I want to unite a array in PHP, I use the function array_merge Thus: $a = [1, 2, 3]; $b = [4, 5, 6]; array_merge($a, $b); Upshot: [1, 2, 3, 4, 5, 6] And how could I do that in Python in a list…
-
7
votes2
answers5604
viewsQ: How do I repeat a string in Python?
The question is simple: How do I repeat a string in Python? I’m used to PHP. When I want to repeat a string in PHP, I do so: var $str = 'StackOverflow'; str_repeat($str, 5); // Imprime:…
-
3
votes1
answer185
viewsA: Taking Jquery to Run
The problem may be caused by the lack of stop before the animations. Try to put your code this way: $(window).scroll(function () { if ($(this).scrollTop() > 0) { $('#header ul').stop().animate({…
jqueryanswered Wallace Maxters 102,340 -
1
votes1
answer128
viewsA: Distant relationship with Laravel
Maybe you can use the library Triple Pivot. See here the link and some examples: https://github.com/jarektkaczyk/Eloquent-triple-pivot…
-
10
votes2
answers11475
viewsQ: What is the git diff command for?
I asked that question a little while ago here at SOPT. Some doubts arose, and then the user @Anthonyaccioly recommended me to ask this question. What is the command for git diff?…
gitasked Wallace Maxters 102,340 -
11
votes4
answers1541
viewsQ: What is the difference between "++$variable" for "$variable++"?
What’s the difference between ++$variavel for $variavel++? I realize that when I execute a for with both forms, the results are the same. Example 1: for ($i = 0; $i < 3; $i++) echo $i; Prints: 0…
-
7
votes2
answers1636
viewsQ: Why do we have to use ? > <?php when we use Eval in the content of a php script?
I took a look at the source code of Laravel 3 and saw the following code: eval('?>'.$__contents); On other occasions, I’ve seen something like: $content = file_get_contents('file.php');…
-
2
votes2
answers108
viewsQ: What is the "array" option for in the app/config/Session.php?
I know that in Laravel 4 we can configure various ways to save session data. These are optional session storage mechanisms. Among them we can select memcached, database, cookie, apc and file, which…
-
4
votes2
answers7297
viewsQ: How to duplicate a MYSQL database?
Is there any way to duplicate a database on MYSQL by the execution of any query? I can copy a table with this code: CREATE TABLE table_2 AS SELECT * FROM table_1 But how to copy replicate a…
-
22
votes3
answers7920
viewsQ: What is the difference between "git init" and "git init --Bare"?
The question is very simple indeed: What is the difference between these two commands, git init and git init --bare? What is this option for --bare?…
gitasked Wallace Maxters 102,340 -
6
votes2
answers379
viewsQ: Is it bad practice to overwrite declared variables as a function parameter?
I used to get "reassigned" a value of a certain variable that was declared as nome of the function parameter. Example: function format($string) { $string = ltrim(rtrim($string, ']'), '['); // A…
-
6
votes3
answers943
viewsQ: How to sort DOM elements by jQuery?
Suppose I have the following list: <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> </ul> I want all elements of even numbers to be…
jqueryasked Wallace Maxters 102,340 -
4
votes2
answers189
viewsQ: What is the inverse of :Visible in jQuery?
The Selector :visible jQuery is used to search for an element when it is visible. Example: $(this).find('li:visible').addClass('color-red'); However, when trying to search for invisible elements, we…
-
5
votes1
answer2773
viewsQ: "The getPreventDefault() method should no longer be used. Instead, use defaultPrevented"
In some browsers, such as Google Chrome, always when "move" in some element of the page, the following message appears: Event.returnValue is deprecated. Please use the standard…
-
0
votes1
answer66
viewsQ: Are there techniques to reduce the use of memory (on the part of development) regarding the use of javascript?
I would like to know if there is any technique to reduce the use of memory as to the use of javascript. I mean, as to development. I noticed that a certain page that we are developing where I work…
-
12
votes3
answers3527
viewsQ: How to find the Javascript version (via code)?
Is there any simple way [or not] to find out which version of Javascript is being used in a particular browser - by the code itself written in Javascript? Something like:…
javascriptasked Wallace Maxters 102,340 -
2
votes2
answers103
viewsQ: Is there any risk of not validating the name of a function used in JSONP?
Generally, when a service is available JSONP one of the things to be passed by parameter is the name of the callback that will be used in javascript. Example: $dados = [1, 2, 3]; $json =…
-
1
votes1
answer587
viewsQ: How to group elements dynamically indepente the size?
I have a div parent who is responsible for bringing together certain quantities of children. The problem is that this div is always aligned to the left, without leaving blank spaces, but each parent…
cssasked Wallace Maxters 102,340 -
8
votes1
answer2706
viewsQ: How to count the number of tables in Mysql?
I am trying to count the number of existing tables in a Mysql database. I tried to do it the way below, but returned a syntax error: SELECT COUNT(SHOW TABLES) How can I do that?…
-
6
votes2
answers435
viewsQ: What is the rule for converting a binary value to a negative number and vice versa?
I got a gift after the @Maniero answered that question: What is the ~ (til) operator for in PHP? How to obtain the negative value in binary? And how, through torque, to reach a negative value? In…
-
1
votes1
answer112
viewsQ: How to simulate a cast of a class in PHP (other than stdClass)?
It seems to me that in java there is a way to make Casts to make a particular object instance of another. Example: MyClass variable = (MyClass) my_other_class; In php it is possible to make type…
-
25
votes1
answer18896
viewsQ: What is Connection Keep-Alive?
When I check the headers I’m sending on a php page, which is installed locally, I always see this Connection: Keep-Alive. Example: var_dump(getallheaders()); Exit: array (size=7) 'Host' => string…
-
19
votes3
answers4009
viewsQ: Why is it important to remove X-Powered-by from response headers? How to remove?
Why it is important to remove the X-Powered-By of the response headers? This prevents some kind of attack, or avoids "insider information" to the attacker? Example: X-Powered-By:…
-
11
votes1
answer415
viewsQ: Why should we use functions that start with mb_?
Sometimes, problems arise in PHP in relation to some string functions, because of the condition of them. An example, is the strlen. $a = strlen('str'); $b = strlen('stré'); var_dump($a, $b); //…
phpasked Wallace Maxters 102,340 -
5
votes2
answers957
viewsA: Include within class and access to $this, self or Static
In reply to my second question, I would vote in favour of changing the context of the included file, as regards view in the MVC. And I explain: As regards the context applied to include given within…
phpanswered Wallace Maxters 102,340