Posts by Filipe Moraes • 8,737 points
259 posts
-
0
votes1
answer51
viewsA: Show one button and hide another
You do not need to create a function for each state, the fact of hiding and showing a particular element in the DOM is not inherent to the state the user has chosen, it is just a reaction to a user…
-
3
votes1
answer119
viewsQ: How do you protect a stateless API built on the Adonis framework against CSRF and XSS attacks?
Consider a REST API stateless with all endpoints protected with authentication, except endpoint for authentication. The authentication endpoint returns a JWT which is later sent in all requests…
-
1
votes1
answer846
viewsA: Format input value using [ngModel] and (ngModelChange) while typing
The solution would be to change the event and use the Two-way Data-Binding, see the section Binding syntax: an Overview. <input matInput placeholder="Proposta" [(ngModel)]="valorProposta"…
-
0
votes3
answers1422
viewsA: Convert string with HTML tags into an array
I managed to solve the problem. I don’t know if it is the best approach but it is a solution that works. I await suggestions. Before separating by space, I stored all tags and their contents in an…
javascriptanswered Filipe Moraes 8,737 -
5
votes3
answers1422
viewsQ: Convert string with HTML tags into an array
Consider the following string: var texto = 'Esse é um texto de <span class="red"> teste </span>'; I need to transform the string into an array separating by space, ie: var palavras =…
javascriptasked Filipe Moraes 8,737 -
2
votes1
answer112
viewsA: Error npm install Angularjs-dragula
The error occurs because the files .json were created manually without a valid structure. When the command npm install angularjs-dragula --save is executed, occurs the parse of the contents of the…
-
2
votes2
answers65
viewsQ: Convert milliseconds to 16-digit hexadecimal
I am implementing an algorithm to generate an access key to a given system, however the need to convert a numerical value to 16-digit hexadecimal. Consider the number of milliseconds elapsed since…
phpasked Filipe Moraes 8,737 -
2
votes1
answer184
viewsQ: Extract private key from file with extension . DER
I need to extract the private key from a file .DER, however analyzing the function openssl_pkey_get_private I identified that it is necessary to pass as parameter a file with extension .PEM. I tried…
-
0
votes1
answer52
viewsA: Applying the principle of single liability in methods using subscribe
I solved the problem by creating a control function, for example: export class TesteComponent { //... public onSubmit() { this.invokeChain('checkA'); } private invokeChain(operation: string) {…
-
0
votes1
answer52
viewsQ: Applying the principle of single liability in methods using subscribe
Consider the following class: export class TesteComponent { //... public onSubmit() { this.checkA(); } private checkA(): void { this.service.checkA(value) .subscribe(response => { if(response) {…
-
4
votes1
answer292
viewsA: Parse error: syntax error, Unexpected ','
Use stitch . for concatenate in PHP and not the comma ,: $strqury = "SELECT * FROM ". $config->ContasTable ." WHERE Login = ? AND ". $config->PasswdColumn ." = ? AND ".…
phpanswered Filipe Moraes 8,737 -
2
votes1
answer251
viewsA: Error: That is not Equal to the supplied origin
According to the bug, the domain making the request is not allowed to do so. localhost:4200 The browser validates this information via the header Access-Control-Allow-Origin sent in response to the…
-
0
votes1
answer277
viewsA: Laravel Defender Trying to get Property 'name' of non-object
Look at your code, the method attachRole expects an object and not a number. public function attachRole() { if(!$this->hasRole($role->name)) { $this->roles()->attach($role); } } The…
-
1
votes1
answer262
viewsA: Formgroup Required conditioning
The Input is built through a Property Binding: <ss-endereco #endereco [endereco]="cliente?.endereco" [required]="false"> </ss-endereco> In the component script, you can initialize the…
angularanswered Filipe Moraes 8,737 -
0
votes2
answers1816
viewsA: Calling function after opening Modal
According to the example, the variable increment totalClicks is outside the scope of the anonymous function, just when the event occurs submit the value is not incremented. The right thing would be:…
-
2
votes1
answer892
viewsA: Redirect to external link in Laravel
According to the image inserted in the question, it is possible to see that the value of $location->url is "www.google.pt". The value does not contain the protocol, that is, it does not inform if…
-
1
votes1
answer99
viewsA: Sending JWT without Framework
In the example (link also inserted in question), the token is saved into a cookie, correct? localStorage.setItem('token', token); The next step is to implement a function that intercepts the request…
-
0
votes1
answer73
viewsQ: How do one query depend on the result of the other?
Consider the following table: +----+----------------+----------------+--------+ | ID | fk_resource_id | fk_language_id | value | +----+----------------+----------------+--------+ | 1 | 1 | 1 |…
mysqlasked Filipe Moraes 8,737 -
0
votes0
answers120
viewsQ: Error Property 'Collection' does not exist on type 'Profile'
There is the following variable declared in the script: private profile: Profile; See that it is a variable of type Profile. When trying to assign a value to the variable, returns the following…
-
0
votes1
answer53
viewsA: canLoad does not work with Behaviorsubject
The solution was to change the BehaviorSubject for AsyncSubject in the service AuthenticationManagerService: private loggedIn: AsyncSubject<boolean> = new AsyncSubject(); //...…
angularanswered Filipe Moraes 8,737 -
0
votes1
answer53
viewsQ: canLoad does not work with Behaviorsubject
The service AuthenticationManager has the following code: private loggedIn: BehaviorSubject<boolean>; constructor( private http: ApplicationHttpClient, private router: Router, private a:…
angularasked Filipe Moraes 8,737 -
1
votes0
answers172
viewsQ: The use of the triple exclamation mark (!!!)
Consider the following code: if (!!!window.customElements) { execPolyfill(); } What is the function of the 3 exclamation points before the expression window.customElements where only 1 would have…
-
1
votes1
answer392
viewsQ: The element is generated with an attribute and the respective CSS with another attribute
I created the component toolbar with the following developer: @Component({ selector: 'app-toolbar', templateUrl: './toolbar.component.html', styleUrls: ['./toolbar.component.scss'] }) Note that the…
-
0
votes1
answer169
viewsQ: Change the project root directory
I have the following file Vagranfile: # -*- mode: ruby -*- # vi: set ft=ruby : VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu/trusty64"…
-
2
votes2
answers893
viewsA: Retrieve label value from select HTML
In pure Javascript, such as the question tag, change the select to execute a function when the value is changed, via the event onchange: <select name="Distrito" size="1" width="180"…
-
0
votes0
answers99
viewsQ: Why is it necessary to use "result as T" in the return of a generic method?
Consider the following method: private handleError<T> (operation = 'operation', result?: T) { return (error: any): Observable<T> => { this.log(`${operation} failed:…
-
1
votes0
answers31
viewsQ: Property is not recognized when using @Input in a directive
Consider the following directive: import {Directive, HostListener, HostBinding, Input} from '@angular/core'; @Directive({ selector: '[myHighlight]' }) export class HighlightDirective {…
angularasked Filipe Moraes 8,737 -
3
votes1
answer48
viewsA: Overlapping elements with padding
By default, the element span owns the property display with the value inline. Properties such as padding and margin do not function in elements inline. To solve the problem, change the value of the…
css3answered Filipe Moraes 8,737 -
6
votes1
answer104
viewsQ: Why does the server send 2 public keys on TLS Handshake?
During the exchange of information on TLS Handshake, the server sends a public key along with the certificate. The server also sends a second public key (Server Key Exchange) if the customer accepts…
-
5
votes1
answer77
viewsQ: How to solve the code duplication problem?
In Wordpress I am creating a custom screen in the administration area. That’s why I’m extending my class customProductsListTable the class WP_List_Table: class customProductsListTable extends…
-
0
votes3
answers166
viewsA: Get String Snippet with Regular Expression
I found a reply in the Soen: Using the regular expression .*youtube.com/./(.*?)%.* with the Matcher: Example: String mydata = "<STRING_COM_O_CODIGO_EMBED_DO_YOUTUBE>"; Pattern pattern =…
javaanswered Filipe Moraes 8,737 -
2
votes3
answers166
viewsQ: Get String Snippet with Regular Expression
In the code there is a string that contains HTML. Inside this HTML there is a embed of a Youtube video: <embed type="application/x-shockwave-flash"…
javaasked Filipe Moraes 8,737 -
1
votes1
answer1783
viewsA: "SQLSTATE[HY093]: Invalid Parameter number: no Parameters Were bound"
Probably the problem is on the following line: $pdov = "PDO::".$arrPDO[$k+1]; This is a string and method bindValue needs an integer as the 3rd parameter. The value can be obtained through a…
-
2
votes2
answers1285
viewsQ: Number of simultaneous requests a PHP server supports
Let’s say I have a server with a 4-core/8 i7 processor threads. In an architecture multi-threaded, assuming that a thread by request, only 8 simultaneous requests will be allowed, since the…
-
0
votes1
answer221
viewsQ: CPU-intensive application blocks competing requests
In a web application it is common for each request to create a new thread that handles all processing and if for some reason the thread is blocked by executing a heavy task, the resource is…
node.jsasked Filipe Moraes 8,737 -
6
votes3
answers1676
viewsA: Check if there is a field inside Json
You can use the function isset, however there is one however if the assigned value is null: <?php $json = '{ "operacao": { "nome": "João" } }'; $obj = json_decode($json); if( isset(…
phpanswered Filipe Moraes 8,737 -
5
votes1
answer64
viewsQ: Function generator returns Undefined
Consider the following function: function* gerador() { let foo = yield "a" let bar = yield "b" let baz = yield "c" return `${foo} ${bar} ${baz}` } let gen = gerador(); console.log(gen.next());…
-
0
votes3
answers2723
viewsA: Domain without www does not work
After having access to the control panel in Godaddy, I found that some DNS settings were missing in Godaddy. The added settings were: A (host): @ -> point to its IP meusite -> point to its IP…
-
2
votes1
answer842
viewsQ: How to change the message from a commit sent to the remote repository
I did 3 commits in the local repository and uploaded them to the remote repository using push. I noticed that one of the commits message was wrong. How do I change the message in the following…
gitasked Filipe Moraes 8,737 -
1
votes1
answer28
viewsA: Is targeting page for frame system recommended?
See what it says to specification W3C dealing with obsolete Features, see Section 11.2 Non-conforming Features: Either use iframe and CSS Instead, or use server-side includes to generate complete…
-
2
votes1
answer43
viewsA: Code is not being read in full
You have a return in the first line of the function naocadastrado: return View('/naocadastrado'); Any code following that line will not be executed. See what it says to documentation of PHP: The…
-
3
votes1
answer336
viewsQ: Implementation of Abstract Factory, Factory Method and Adapter standards
I read the following sentence: Abstractfactory defines an interface for creating a family of related or dependent products without you having to explicitly specify the classes. Consider the…
-
1
votes1
answer28
viewsQ: How to delete the original image after Crop?
Through the area media Wordpress, it is possible to add images. The problem is that the client does not know how to crop the images using an editing program, such as Photoshop, then it uses the tool…
wordpressasked Filipe Moraes 8,737 -
2
votes3
answers732
viewsA: Recursive function with for
We call recursion or recursion when a function calls itself. In a recursive function, each call is created in memory a recurrence of the function with "isolated" commands and variables from previous…
-
13
votes1
answer4028
viewsQ: What does Handshake mean?
While studying about Websocket, I read the following sentence: Its only relation to HTTP is that its Handshake is interpreted by HTTP servers as a request for upgrade. In this context, what…
-
2
votes1
answer62
viewsA: How to take string values by reference using PHP
Analyzing the following line: $.post("autosave.php", {'meus_dados': dados}); The Form Data HTTP request will be sent as: meus_data:title=sr&body=test That is, in PHP will only be available the…
-
1
votes2
answers19501
viewsA: error: "failed to open stream: No such file or directory"
The archive FitaController.php does the file include FitaDao.php which in turn does include the file Conexao.php, however the path must be relative to the first include, ie in relation to the…
phpanswered Filipe Moraes 8,737 -
5
votes2
answers261
viewsA: How can a Function expect the result of $http?
The service $http is a function that takes a single argument - a configuration object - that is used to generate an HTTP request and returns a promise (source code). $http({ //objeto de configuração…
-
0
votes0
answers79
viewsQ: What procedures should be adopted to implement the semantic interoperability of a REST Web Service?
Semantic interoperability is something optional in the REST standard, there are no rules defined as occurs in SOAP with WSDL - for example, but I understand that in REST it is important to keep it…
restasked Filipe Moraes 8,737 -
1
votes2
answers184
viewsA: Do data received via Request using Doctrine need to be processed?
Completing @Virgilio Novic’s reply, what says to documentation of the Doctrine: In general you should assume that Apis in Doctrine are not safe for user input. There are However some exceptions.…