Posts by Wallace Maxters • 102,340 points
1,984 posts
-
1
votes3
answers1379
viewsQ: How can I see upgraded package versions via Composer?
It’s nice and beautiful to see Composer installing the reports according to the version we determined in PHP. I have many applications where I use the Composer and, at that point, needed to update…
-
3
votes4
answers2166
viewsA: How to know the number of lines a large file has in php?
I, as a lover of OOP in PHP, would do this to the object SplFileObject $file = new \SplFileObject('file.extension', 'r'); $file->seek(PHP_INT_MAX); echo $file->key() + 1; I use the PHP_INT_MAX…
-
5
votes2
answers4066
viewsQ: How to know the number of lines a large file has in C#?
Well, I’m starting now in C#, but I already have a great experience with PHP and I know more or less Python. And the means that I use to appeal is to do something that I found difficult to do in a…
c#asked Wallace Maxters 102,340 -
6
votes4
answers2166
viewsQ: How to know the number of lines a large file has in php?
How do I know the number of lines in a file using PHP? I know there are functions like file, which returns all rows of the file in one array. We could just use one count, but the problem is I need…
-
1
votes2
answers2143
viewsA: Laravel - Session and Array
If you want to add these array to a session value where you had already entered a given one, the best way would be to use the method push session()->put('session_array', 1);…
-
4
votes1
answer270
viewsA: How to create a clickable image valid for W3C?
In fact, a small correction: When I asked the question, I misunderstood the answer that said IMG is not accepted within A. According to W3C it is not recommended to use IMG as a daughter of a A when…
-
2
votes1
answer270
viewsQ: How to create a clickable image valid for W3C?
According to the reply of question I did here, the W3C discourages the use of a tag img within a link (<a>); But this imposition of the W3C sounded a little controversial, because since I…
-
3
votes1
answer31180
viewsQ: Button (Button) inside an A (Link)? Is this a bad practice?
I was using a library of Scaffold for automatic HTML code generation. It was specifically for generating forms in Boostrap 3. Then I noticed that the links of actions that are being generated are…
htmlasked Wallace Maxters 102,340 -
2
votes2
answers552
viewsA: How can I "skip" elements of an array when I use "list"?
I’ve been looking forward to someone answering that one, but I’ve got to get a toothpick here. The list in PHP natively supports "skip" the elements listed simply by not declaring anything where a…
-
3
votes2
answers552
viewsQ: How can I "skip" elements of an array when I use "list"?
I got the following array $array = [25, 'Wallace', '26 anos', 'linguagens' => ['PHP', 'Python', 'C#'] I’d like to use the function list to be able to capture some elements directly into…
-
3
votes2
answers78
viewsQ: PHP 5.5 implemented the foreach functionality with list. What are the benefits of this?
In PHP 5.5, we have a new feature, which is to use list together with the foreach. $array = [ [1, 2], [3, 4], ]; foreach ($array as list($a, $b)) { echo "A: $a; B: $b\n"; } Exit is: A: 1; B: 2 A: 3;…
phpasked Wallace Maxters 102,340 -
0
votes3
answers522
viewsA: How to put variables in datetime (PHP)
To try to do it in a more simplified way than the two answers presented, if you are using a version equal to or greater than 5.4, you can do so $date = (new DateTime())->setDate( $ano, $mes, $dia…
-
4
votes3
answers1114
viewsQ: Error on line 0 (zero)? How can this?
In PHP, when an error occurs, usually the line of the script where it occurred is informed: Undefined index 'a' in line 5 But there are times when error is returned on line 0 (zero). Example: Fatal…
phpasked Wallace Maxters 102,340 -
4
votes1
answer220
viewsQ: Why does the expression "$a->b->c->d->e->f->g->h->i->j =& $null;" return several objects within each other, and it doesn’t even exist?
I was doing some tests with value assignments by PHP references and came across a curious example. $a->b->c->d->e->f->g->h->i->j =& $null; Both the variables $a and…
-
2
votes1
answer396
viewsQ: How to Reverse Engineer MYSQL Database with Sqlalchemy?
I asked that question here at Stackoverflow the other day: How to import database to Django models? But now, I need something similar to Flask. I have a bank ready, using the MYSQL. I want to…
-
2
votes1
answer899
viewsA: Laravel - Test script errors to return certain status to AJAX
First option: The Laravel pattern Honestly, if it were me, I would use the standard way that Laravel treats data. I mean, when an error occurs and the request is Ajax, the Laravel returns ['error'…
-
2
votes1
answer217
viewsA: Laravel 5.2 $errors empty
The problem is you’re calling $errors->all. This you are calling a property of Messagebag, which does not exist. In fact, you should call the method MessageBag::all(). Thus: @foreach(…
-
1
votes1
answer182
viewsA: Laravel - Search if there is a relation in the many-to-many table
I answered a question similar to that here today. You should use the method whereHas, to search the groups related to this user. Behold: public function search(Request $request) { $callbackSearch =…
-
4
votes2
answers805
viewsQ: How to define a global alias in BASH?
I’m using the Terminal in the Linux and I’m tired of repeating the same commands all the time. For example, I use a command practically all day, then I create an alias to make things easier.…
-
2
votes1
answer164
viewsA: How to get records from a table when there is no relationship with another table in Laravel?
Since no one answered, I answer. Just use the methods doesntHave and whereDoesntHave. For example, I want all usuários which do not possess the nível 'admin', both of whom have a relationship N:N.…
-
2
votes1
answer371
viewsA: PHP multi-level array_merge. How to do?
Yes, the array_merge serves to unite two arrays, according to the indexes. If it is numerical, it joins the two arrays, reordering the indexes. If it is an index named, it will replace by array…
-
5
votes1
answer181
viewsQ: Python ORM similar to Django
I studied the framework for a long time Django and I thought the ORM of the same was excellent. I had the idea, at some point, to build an application with another framework called Flask, using a…
-
3
votes1
answer164
viewsQ: How to get records from a table when there is no relationship with another table in Laravel?
In Laravel, when I want to get data from a table that contains some relationship, or when I want to get the data from a condition of a related table, for example, usuarios that contains livros, I…
-
1
votes1
answer872
viewsA: Session variables $_SESSION vs class variables in PHP
In that case, I share the same idea I learned when I started learning Python: Explicit is better than implicit Why? When I step from the data I am going to work with inside a class, it is easier to…
-
1
votes2
answers1956
viewsA: HTTP 500 error when putting an orange project5.1 into production
Generally this occurs because in Produção the error is disabled. The Blank Page Error If only a blank page is appearing or Erro 500, i like to do the following tests: > php artisan Or else >…
-
2
votes1
answer649
viewsA: Laravel 5.2 pages redirecting in the POST without showing validation errors
In the Laravel 5.2, all routes must pass through the group of middleware called web. What happens is that in some releases of Laravel 5.2, the settings of RouteServiceProvider is as follows: /** *…
-
-2
votes1
answer117
viewsQ: Why do they say that the use of global variables is bad practice?
I’ll get straight to the point. In internet tutorials outside, you always find someone criticizing some, considering it as a "bad practice". For example, one of them is the use of the keyword…
-
20
votes1
answer8743
viewsA: Python, difference between assert and raise?
raise is intended to invoke a Exception at the right time. In the same way as other languages when we use throw new Exception, the exception is invoked the moment we call raise. Example: raise…
-
4
votes1
answer664
viewsA: Use 'WHERE' if value is different from 'NULL' in a search system
Friend, I suggest using the whereSub of Laravel to do such an operation. It is called internally when you use a where with a Closure. I usually do this to make conditions for the Where in a search,…
-
1
votes1
answer27
viewsA: Pick up Remaining Records
@Zoom, this is easy if you use the features of Collection of Laravel. Come on. First you select all the data. $slider = Works::all(); Then you can use the method Illuminate\Support\Collection::chunk…
mysqlanswered Wallace Maxters 102,340 -
1
votes3
answers2577
viewsA: jQuery, block multiple clicks on link
In jQuery we have a solution ready if you want one click per link, just use the method one. $('#target').one('click', function (e) { e.preventDefault(); $(location).attr({href: this.href}); });…
jqueryanswered Wallace Maxters 102,340 -
8
votes1
answer2888
viewsQ: What is the purpose of virtualenv and why not install globally?
I saw that the VirtualEnv provides a way to create different environments for application development in Python. And, whenever we use, it is necessary to install the dependencies of a specific…
pythonasked Wallace Maxters 102,340 -
0
votes0
answers30
viewsQ: How to display a modal in the beforeunload?
With the event beforeunload, i can display a message when the page is to be canceled or updated. $(window).on('beforeunload', function () { return 'Testando'; }); But the client for whom I usually…
-
10
votes1
answer13822
viewsQ: What’s the simplest way to make an IS NULL with Eloquent?
I saw tutorials on the internet that way you had to make a IS NULL is the following: Remessa::where('campo', 'IS', DB::raw('NULL'))->get(); But I was wondering about this, because if a ORM is…
-
5
votes2
answers1185
viewsQ: What’s a Seeder for?
I saw in the Laravel that there is a folder called database. In it we have the Migrations and the Seeds. I understand that Migrations are migrations, are codes that provide specifications for…
-
0
votes1
answer40
viewsA: Why am I not able to create a function within a class named after the array list of a class method in php?
There is no way to do this in PHP. The most that can be done is a dynamic method call, but not a statement: class Aluno { public function __construct($nome) { $this->nome = $nome; } public…
-
0
votes3
answers87
viewsA: Fix data from SQL database
Execute the command: ALTER TABLE tabela MODIFY coluna DECIMAL(10, 2);
-
0
votes1
answer974
viewsQ: What is the [Httpget] statement for?
In a certain method of mine Controller raised in the Asp Net MVC, I learned that I could put the statement [HttpGet]. In other cases, as in my models, I realized that can be put too [Length(10)] and…
-
7
votes1
answer885
viewsQ: What is the difference between readfile and file_get_contents?
In PHP, there are numerous ways to read the contents of a file. There are the functions fopen, file, file_get_contents, readfile, and even a class called SplFileObject. file reads line by line and…
phpasked Wallace Maxters 102,340 -
1
votes2
answers3444
viewsA: How to test Curl PHP?
I don’t have much patience to use the functions of Curl php, because you end up having to type a lot. My suggestion is to use the Guzzle, which is a PHP library, which is a client for making HTTP…
phpanswered Wallace Maxters 102,340 -
20
votes1
answer3361
viewsQ: What is the __future__module for?
I’ve seen it in some codes written in Python the following statement: from __future__ import print_function What is the purpose of this module __future__? When do I need to import it into a script…
pythonasked Wallace Maxters 102,340 -
14
votes1
answer268
viewsQ: What happens to a 2:30 Cronjob if the server goes down at 2:28 and only comes back 5 minutes later?
I don’t know if the question is confusing, but is that I have used a lot of Cronjob in my systems currently and do not want to have problems. So I’m going to illustrate my concern with a…
-
4
votes2
answers4673
viewsA: How to simulate a keystroke with jQuery?
I will answer my question, but don’t get me wrong. Just consider it as a complement. As already stated by @Pedrocamarajunior in their excellent response, you can jQuery.Event to create an event.…
-
4
votes2
answers4673
viewsQ: How to simulate a keystroke with jQuery?
I wonder if there is any way to simulate pressing keys with jQuery. For example, when clicking a button, simulate that the "down" and "left" keys were pressed, as if the user had a keyboard.…
-
2
votes1
answer156
viewsQ: Can index in an ENUM field bring any advantage?
I was reading in a reply from Soen, that the fields of a table that have INDEX can optimize a query. Of course, as long as this query is known, such as a user survey by the email, for example. I…
-
2
votes1
answer489
viewsA: PHP Fatal error: Call to Undefined Function exif_read_data()
You will have to ask your hosting provider to install the extension exif, in case the hosting supports such an operation. Installation of the EXIF If it is already installed, you can also enable in…
phpanswered Wallace Maxters 102,340 -
2
votes1
answer1093
viewsQ: How to import database for Django models?
I have an application that is almost ready. It was developed in PHP, through the Laravel Framework. I already have the database and all some data already entered to perform tests. However, as I am…
-
5
votes1
answer1093
viewsA: How to import database for Django models?
Yes, the Django framework has a tool ready for this. It’s about the command inspectdb. This command will make the Django Scan your database and generate an output containing model definitions. That…
-
1
votes1
answer1627
viewsA: How to install Laravel on a server?
I believe that answer leads us to the famous "depends"... Depends on what? Your server is shared or dedicated? On Dedicated Servers In the company where I work, I use a dedicated server. When we…
-
1
votes2
answers247
viewsA: Image upload using CGI Python - Doesn’t work!
Well, I think your problem is simpler to solve. Your form must contain the attribute enctype="multipart/form-data". I guess you forgot.