Posts by Wallace Maxters • 102,340 points
1,984 posts
-
6
votes2
answers475
viewsQ: Angular locking GET form Submit
I have a form where I send a query to the current url, through parameters GET. For example, I have url/teste, when sending the query via this form, will url/teste?term=minha+consulta. I didn’t use…
angularjsasked Wallace Maxters 102,340 -
3
votes2
answers257
viewsA: domain after @- HTML
You can also validate using the following regular expression in Javascript: var regex = /@gmail\.com$/; var gmail = regex.test('[email protected]'); var hotmail =…
-
17
votes2
answers31712
viewsQ: What is the difference between " n" and " r n" (special characters for line breaks)?
For line breaking, I usually use \n. But I realize that in some cases, such as in the Sublime Text editor, some texts that I need to capture the line-breaking are only captured when I use regex…
-
7
votes3
answers1852
viewsA: Reading blank blank blank blank blank files
You can use rstrip() for that reason: with open(filename) as f: #Todas as linhas, incluíndo as em branco lines = (line.rstrip() for line in f) #linhas sem espaço em branco lines = (line for line in…
-
1
votes2
answers376
viewsA: Static method calling an object
See, as was said in Danielomine’s reply, depending on the PHP version, an error message is triggered (E_STRICT). This is because, although it is allowed, it can cause a serious error. This is when…
-
5
votes1
answer1133
viewsA: Setting a middleware for a controller, except a function in Laravel 5
There are other ways to define a middleware in Laravel, but I’ll show you the way you need it, which is by setting it directly in Controller. Option except To define a middleware specific to a…
-
2
votes2
answers80
viewsA: Is it possible to use Heredoc with special characters in an array?
Perhaps not the solution you want, but another alternative to be considered would be the use of __halt_compiler combined with file_get_contents. Behold: $name_code = array ( array( "Nome",…
-
0
votes1
answer325
viewsQ: Is it a problem to insert another controller into Angularjs?
I have the following question: I am building a page, where I have a controller called PageController, responsible for rendering the menu and page title. However, within the div where I use…
-
2
votes2
answers3964
viewsQ: Angular edit the values of an object without changing the "original"
I have a ng-repeat in Angular whose value of each iteration is an object. By clicking a button referring to the row of the table where this object is used, a form for editing it is opened, and, with…
angularjsasked Wallace Maxters 102,340 -
0
votes4
answers912
viewsA: Add variables to obtain end date
I would use the Datetime combined with the method modify to change according to the months I want to add: $mes_variavel = 3; $datetime = new DateTime('2016-08-06'); $datetme->modify(sprintf('+%d…
-
4
votes2
answers1476
viewsA: Transforming Multidimensional Array into One-Dimensional
I believe there is a simpler way, that would be using the function array_walk_recursive. whereas the indices of sub-array are not identical, we can use it to create a array one-dimensional. Behold:…
phpanswered Wallace Maxters 102,340 -
1
votes1
answer995
viewsA: How to avoid "zend_mm_heap corrupted" error?
I don’t know much about it, but I did a little digging around SOEN, I decided to bring a translation, to see if I can help someone. Possible solutions: Increase the buffering output According to the…
phpanswered Wallace Maxters 102,340 -
1
votes3
answers2129
viewsA: What is the simplest way to create a mask for numbers in PHP?
It is already very well answered, but I would like to leave here a small technique that uses vsprintf and str_split together. The function vsprintf is intended to format a string, based on past…
-
7
votes2
answers312
viewsA: Is it possible to define a class within an array in earlier versions of PHP 7?
Maybe there’s a mix-up in there. If you are talking about PHP versions prior to PHP 7 (currently PHP 5.6 down), there is no feature for Anonymous Classes. Actually, do not confuse "class instance"…
phpanswered Wallace Maxters 102,340 -
0
votes1
answer820
viewsQ: Is there a difference in performance between ng-bind and {{ }} (Interpolation)?
I realized that in Angular we have the two ways to display values in the DOM. One is using the keys {{}}, and others, is using the attribute ng-bind. Keyed example: <div ng-repeat="moderador in…
angularjsasked Wallace Maxters 102,340 -
2
votes1
answer410
viewsQ: Does Angularjs not read input of the Hidden type?
On one occasion, we were developing a form here at the company where, when selecting a product through a Autocomplete, the ID of that product was stored in a input hidden. I noticed that Angularjs…
angularjsasked Wallace Maxters 102,340 -
1
votes1
answer76
viewsQ: How to apply a scope to a dynamically created element in Angularjs?
At the angle, I realize that the scope of the Controller is not being applied in a particular piece of code, when it is created dynamically. For example, I have a certain content within a tag…
-
22
votes1
answer5957
viewsQ: What is the meaning of CORS?
I always see the word CORS related to an error occurred while trying to make a request XmlHttpRequest for a given page, which does not have the same domain as the origin. Example: Xmlhttprequest…
-
1
votes2
answers186
viewsA: Django Rest and Angularjs Cors error
The problem is that requests must be from the same origin when you use a request XmlHttpRequest. You need to configure the application that provides the data to accept the source from where you are…
-
1
votes1
answer688
viewsA: How to configure Laravel’s Auth.Basic to accept another authentication field?
As stated in the @Miguel user comment, to solve the problem you need to create a new Middleware, containing the validation needed to log in via Auth Basic. 1) First it is necessary to create the…
-
0
votes1
answer688
viewsQ: How to configure Laravel’s Auth.Basic to accept another authentication field?
I’m using the Laravel 5 and I want to use the middleware auth.basic. But in my database, the table used for authentication (usuarios), doesn’t have the field email, and yes username - the standard…
-
2
votes2
answers650
viewsA: How to use Packages in Laravel 4?
As a complement to the answer that has already been given, I recommend using the desired package installation directly from the command line, because the Laravel, by having many dependencies, makes…
-
1
votes2
answers1277
viewsA: Calculation of hours with php
I noticed that you are using a pattern of a record in the table for each action. That’s why you needed the GROUP CONCAT, which at a time will return the data set by vírgula. Then, a possible…
-
1
votes1
answer196
viewsA: Error declaring an interface to the class in PHP?
For you to use classes or interfaces the way you are using, you need a autoload. Because you are not including the classes or interfaces through the include. A simple autoload example would be:…
-
1
votes2
answers508
viewsA: Catch the Children of an Object
I think instead of using: $(e).children('.button').addClass('animated zoomIn'); You should use: $(this).children('.button').addClass('animated zoomIn'); The this in this case refers to the element…
-
3
votes1
answer73
viewsA: Query to return only the records of the last 24h (Codeigniter)
If you want the last 24 hours counting from the current time and day, you can use the function strtotime and subtract 24 hours from current date. You can add BETWEEN to your query: $maxDate =…
-
3
votes1
answer2166
viewsQ: Why do native angular directives start with NG?
I always wondered that, but I finally had the courage to ask: What is the meaning of NG in the libraries of the angular? Apparently it has nothing to do with the word Angular prefixed NG. Is there…
angularjsasked Wallace Maxters 102,340 -
1
votes1
answer197
viewsQ: How to know which is the first item in the ngRepeat loop?
How to know which is the first item in a loop ngRepeat? For example, I want to add a class in a div, when it’s the first in the loop. Example: <div ng-repeat="name in ['guilherme', 'wallace',…
angularjsasked Wallace Maxters 102,340 -
4
votes1
answer2619
viewsQ: Skip to the next business day if the date falls on a weekend
In PHP, I have a certain date, coming from the database, which is the date a request was made. I need to add 5 working days on that date, which is the deadline for the request to be delivered. In…
-
4
votes3
answers481
viewsA: How to make preventDefault links at the angle?
If you define the href empty will also work: <a href ng-click="addNinja('OnoSedai')">Adicionar Novo Ninja</a> The advantage of doing so is that you won’t need to define a CSS because of…
-
4
votes3
answers481
viewsQ: How to make preventDefault links at the angle?
I’m using a function called with ng-click, via a link (Anchor). However, because of the hash #, the page is "skipping" every time I click on this link. This is my code: <a…
-
2
votes2
answers1153
viewsA: Laravel Relationship 5.2 Eloquent
The belongsTo relationships of the Laravel are stored in a property of your Model instance. This property will always be the name of the relationship method. For example, if your model User relates…
-
8
votes1
answer822
viewsA: Which is more performatic - foreach or array_map?
The problem is sometimes to confuse the purpose of each thing. array_map has numerous functionalities, which go beyond those presented in the examples of the question. array_map is intended to map a…
phpanswered Wallace Maxters 102,340 -
2
votes2
answers387
viewsQ: Angular $timeout or Javascript timeout?
I’m a beginner in Angular JS. I realized that we have a service in Angular called $timeout. I was curious to understand why this service exists, since Javascript natively has the setTimeout. What is…
-
0
votes1
answer242
viewsA: Laravelexcel is converting the header values of an excel sheet. How to disable this?
I ended up discovering. There is really no method in the class Excel that performs the operation of disabling automatic conversion of column names, but it is possible to configure the library. There…
-
1
votes1
answer242
viewsQ: Laravelexcel is converting the header values of an excel sheet. How to disable this?
I am using the Laravelexcel library to import data from an excel to a database. To get the header data from my spreadsheet, I do the following: Excel::load('file.xls', function($reader) {…
-
4
votes1
answer1665
viewsQ: How to get the HOST IP through the PYTHON domain?
In PHP, to get the ip of a given domain, I usually use the function gethostbyname. PHP example: gethostbyname('www.google.com'); //201.17.165.210 And in Python? How can I do this?…
-
2
votes1
answer83
viewsQ: In python, how can I simulate a read-only property in classes?
I would like to know how I can simulate a read-only property on Python. For example, I have the following code: class IPInfo(object): def __init__(self, ip): self.ip = ip; ip = IPInfo(object) ip.ip…
-
1
votes2
answers74
viewsA: Error in search system with php
You are trying to capture the index that does not exist. In case query in the variable $_GET. You can make a ternary to check if the value exists: $query = isset($_GET['query']) ? $_GET['query'] :…
-
6
votes3
answers8812
viewsA: How to determine the user’s approximate location by IP?
I don’t mean to jab, but already, I have a library called WallaceMaxters\IPInfo, that takes information from a particular IP. See an example of use: IPInfo::get('8.8.8.8')->getCountry(); It…
ipanswered Wallace Maxters 102,340 -
15
votes1
answer77173
viewsQ: Is every HTTPS and HTTP connection always linked to port 443 and 80 respectively?
Every HTTP connection always has port 80 and every HTTPS connection always has port 443? Because I realize that browsers don’t need you to pass the port to make connections to those specific ports.…
-
0
votes2
answers974
viewsA: Convert XML to php
In PHP, in such cases, it is very common for you to use @ in these functions to suppress errors. Some case, it is very common this happens with DomDocument. So you can do it this way: $dom = new…
-
1
votes2
answers66
viewsA: Search something in a list and say whether it exists or not - Display Value, and amount
If you want to do $_GET, consider adding multiple items in the same parameter’s input GET. Behold: url?itens[]=pão&itens[]=leite&itens[]=ovo In PHP this would return:…
-
6
votes2
answers113
viewsQ: Is it possible to access the same argument twice in sprintf?
In PHP times the function sprintf. With it we can format the values sequentially passed from the second parameter. For example: sprintf('Meu nome é %s e tenho %d anos de idade', 'Wallace', '26') The…
-
4
votes5
answers9322
viewsA: How can I generate a 7-character alpha-numeric key?
sprintf and mt_rand Another short and simple option would be matching mt_randwith sprintf. sprintf('%07X', mt_rand(0, 0xFFFFFFF)) In case I explain: mt_rand will generate a number of 0 until…
phpanswered Wallace Maxters 102,340 -
1
votes2
answers698
viewsQ: How to send form parameters instead of angular JSON?
I’m trying to send a POST Angular way, the same way I did in the JQuery, however, when trying to capture the data via variable $_POST, is not bringing any value. I’m running a code similar to that…
-
5
votes1
answer462
viewsQ: How to solve the problem of PHP 5.6 with obsolete PPA on Linux?
I went to spin the remote sudo apt-get upgrade and I got the PHP PPA discontinuation message. After updating the PHP version, when I run php -v, appears the following: PHP…
-
4
votes2
answers458
viewsQ: How to convert Camelcase to snake_case in C#?
I would like to know how to convert a string with Camelcase for snake_case in C#. For example: EuAmoCsharp => eu_amo_csharp SnakeCase => snake_case…
-
1
votes1
answer739
viewsQ: How to convert Camelcase to snake_case in PHP (simply)?
How do I convert a string with Camelcase for snake_case in PHP as simply as possible? Example: CamelCase => camel_case AjaxInfo => ajax_info…
-
14
votes3
answers2619
viewsQ: Can subqueries decrease performance? Myth or truth?
Well, I usually just work with frameworks. I work with frameworks MVC and I usually use Orms to query the database. In my case I use Laravel, but I’ve used other frameworks, and had the opportunity…