Posts by Filipe Moraes • 8,737 points
259 posts
-
2
votes2
answers520
viewsA: Taking the total in pixels of an element passed in variable in percentage
The method width gets the current computed width of the element in question (read documentation jQuey). Then the value of $('.video-item-first').width() will be in px and not in percentage. Chrome…
-
27
votes5
answers1106
viewsQ: Is SOAP safer than REST?
When implementing online billing software, I asked the responsible company if there was a REST version of the API. The answer was that they did not use REST due to security, that SOAP would be safer…
-
12
votes9
answers12142
viewsA: Search via ajax during input text ( autocomplete )
You can do something like that: var cache = {}; $(document).ready(function() { addKeyupEvent($('#termo_busca')); } function addKeyupEvent(element) { element.keyup(function(e) { var keyword =…
-
7
votes1
answer126
viewsQ: Why are the padding and margin properties calculated in relation to the width of the parent element?
The declared percentage values are calculated, for the four sides, relative to the width (width) of the parent element. See the following HTML: <div class="pai"> <div…
cssasked Filipe Moraes 8,737 -
3
votes2
answers101
viewsA: Set a random return to a function
By directly answering your question, it is possible to return a random value. The following solution reorders the array randomly and returns the first item. function funcao(){ $result =…
phpanswered Filipe Moraes 8,737 -
0
votes3
answers145
viewsA: Avoid editing in the field
To disable select, you can use the following code: $('#selectID').prop('disabled',true); To re-activate it, simply remove the property disabled: $('#selectID').removeAttr('disabled'); Just change…
-
1
votes1
answer3471
viewsA: Javascript POST Request
The alert is triggered because the POST request was successfully completed and the server response was 422, that is, there was a server response although the 422 code represents an error. The error…
-
1
votes2
answers108
viewsA: Taking Dropdown’s Name and ID
From what I read in the papers, json sent in response to a request POST does not own the property id and yes CidadeID, then in your code just replace where you have: value.id For: value.CidadeID…
javascriptanswered Filipe Moraes 8,737 -
1
votes0
answers285
viewsQ: ERR_BAD_SL_CLIENT_AUTH_CERT error while trying to access WSDL
I have a PHP script running on my local machine. The script is consuming a SOAP web service. However I can’t access the WSDL. When trying to open the link to the WSDL directly in the browser, I get…
-
0
votes1
answer35
viewsA: Doubt with facebook API
I found the same doubt in Soen. Change the classes in your CSS: .fb-comments, .fb-comments iframe[style] { width: 100% !important; } Also try to: .fb_iframe_widget, .fb_iframe_widget iframe[style],…
-
1
votes1
answer173
viewsA: Graph facebook with comment counter no longer works
You cannot remove the function json_decode. This function is required to convert the string contained in $filecontent an object. After that, you can access the property comment_count. See this line…
-
1
votes1
answer2251
viewsA: Use if/Else condition inside a while
Just add the if within the cycle while and concatenate the data according to the result of the operation using the concatenation assignment operator .=. To documentation PHP teaches you how to use…
-
7
votes2
answers1189
viewsQ: What is an output parameter?
Consider the following example: appendFooter(s); Analyzing the function signature, we have the following: public void appendFooter(StringBuffer report) The parameter s is considered in the above…
-
2
votes4
answers1430
viewsA: Check if object already exists in the array by id
Every time the user searches for the CPF, a connection with the server will be established, even if it is a CPF already searched and this is unnecessary, because this information can be saved on the…
javascriptanswered Filipe Moraes 8,737 -
2
votes1
answer293
viewsQ: Copy Gitlab backup files to an external drive by setting up crontab
I set the server to run a cronjob and run the script that backs up Gitlab. Gitlab in turn generates the files .tar in the briefcase var/opt/gitlab/backups The first problem is that to access the…
-
13
votes1
answer38536
viewsA: How to take the blue color out of links by ultializing CSS?
In principle it is enough to inherit the colour: a { color: inherit; } This will make the element have your father’s color (which is what I think you’re looking for). But if it’s not that, then just…
-
6
votes2
answers104
viewsA: Mysql connection error
The problem is in the following 2 lines: //... $return = mysql_fetch_assoc($sql); while($row = $return) { ?> //... The function mysql_fetch_assoc must be within the while, that is, like:…
-
2
votes1
answer141
viewsA: Inheritance does not work when using angular-ui-router state
In the documentation of lib ui-router found the solution. Just add the state in the view name by separating by an arroba (content@app), see: .state('app.common.dashboard', { public: false, url:…
-
1
votes1
answer141
viewsQ: Inheritance does not work when using angular-ui-router state
I have the following configuration for the routes: $stateProvider .state('login', { public: true, url: '/login', templateUrl: 'app/src/components/bo/areas/login/login.view.html', controller:…
-
0
votes1
answer37
viewsQ: Generate entity using a given connection
Consider the following configuration file: config.yml doctrine: dbal: default_connection: slqX45 connections: slqX44: driver: pdo_mysql host: "%database_host%" port: "%database_port%" dbname:…
-
3
votes2
answers390
viewsQ: Function returns a string instead of a prefix
The code below returns a promise: function getDealerships(region) { return $.ajax({ method: "GET", url: "/api/v1/dealerships?region=" + region }); } So I can wait for the server reset and process…
-
0
votes1
answer66
viewsQ: Use two fields in a Manytoone relation
There is the following relationship between two entities: class Clients { //... /** * Dealership id * * @ManyToOne(targetEntity="Dealerships", inversedBy="clients", fetch="EXTRA_LAZY") *…
-
1
votes3
answers399
viewsA: Check instance values of a php class
I suggest studying more deeply object orientation, the example below is something very superficial and teaches little. First we need to create a class with the name pais. namespace lib /** * Classe…
phpanswered Filipe Moraes 8,737 -
0
votes1
answer114
viewsQ: Generate a minified file for each file inside a folder
I set the following task to generate a minified file: gulp.task('frontend-js', function () { return gulp.src([ 'bower_components/jquery/dist/jquery.js', 'bower_components/jquery-ui/jquery-ui.js',…
-
0
votes1
answer29
viewsQ: Change form before submitting it
There are 2 entities: Client and Apps. The association between client and app is made in the entity Client as follows: class Clients { /** * App id * * @ManyToOne(targetEntity="Apps",…
symfony-2asked Filipe Moraes 8,737 -
2
votes1
answer58
viewsQ: Why do we use the Containerinterface when injecting @service_container as argument?
In the archive services.yml I have the following service configured: services: api.response_factory: class: AppBundle\Api\ResponseFactory arguments: ['@service_container'] In class ResponseFactory I…
-
6
votes1
answer1324
viewsQ: How to authenticate the application and authorize it to consume a restful API
In a given project, it was necessary to create a restful API that receives data from various forms spread across multiple sites hosted on different servers. The API was created to solve the…
-
0
votes2
answers57
viewsQ: Using Innerjoin with Limit
I have the table A with a relationship OneToMany with the table B. The table A is small, has 10 records. The table B has N records for each record in the table A. From X to X minutes a script is…
-
0
votes1
answer41
viewsQ: Use the __get method inside the controller
In my entity I have the following magic method: public function __get($key) { return null; } On my controller I have the following code: $clients = $this ->getDoctrine()…
-
1
votes1
answer290
viewsQ: Use like in the findby method to filter records?
I have the following code in my controller: $shares = $this ->getDoctrine() ->getRepository('AppBundle:Shares') ->findBy( $where, $orderBy, $paginator->getPerPage(),…
-
1
votes0
answers458
viewsQ: Instagram API requires access token to get public data
I need to consume the Instagram API to search for posts with a hashtag set and extract the following information: User Number of Ikes Number of followers Date of the post However from Jul/2016 it…
-
1
votes0
answers75
viewsQ: How to render the contents of an array
In the application, there is a menu that is represented in PHP in the form of an array: $menu = [ ["title" => "Home", "path" => "/home", "children" => []], ["title" => "Secção", "path"…
-
1
votes0
answers237
viewsQ: ". js" file generated by Gulp returns the error "require is not defined"
I installed Gulp to concatenate and minify my files .js, but the following error occurs in the browser when I test the application: Uncaught ReferenceError: require is not defined I have the…
-
0
votes1
answer20
viewsA: Use the same Preview for multiple forms
First I changed the property check_path of the 2 firewalls: check_path: security_login_check This worked but if the administrator enters the wrong credentials, it will be redirected to the client…
-
0
votes1
answer20
viewsQ: Use the same Preview for multiple forms
In the application there are 2 login forms, one for customers and another for administrators. The two forms use the same Prior: security: providers: form_login: entity: { class:…
-
7
votes1
answer1859
viewsQ: Difference between a blocking language and a non-blocking language
In practice, what is the difference between a blocking language and a non-blocking language? What differences can we see in both front-end and back-end? Using an example, let’s imagine an endpoint…
-
2
votes1
answer53
viewsA: Delete a certain value from a comma-separated database field and reinsert again
You can convert your string into an array and remove the specific value. //Converte a string em um array. Nesse caso o delimitador é a vírgula $array = explode(",", $referencia); //[44,45,46]…
phpanswered Filipe Moraes 8,737 -
4
votes2
answers307
viewsA: As only receive gets from a certain IP
It is possible yes, PHP allows checking which is the IP of the machine that made the request, however if this is some "security" system, do not do so because the user can simulate an IP using a…
phpanswered Filipe Moraes 8,737 -
3
votes1
answer2573
viewsA: Why is the GET method considered safe and the POST method unsafe? And in what situations should I use them?
I see many answers explaining when we should use the method GET and when using the method POST of the HTTP protocol and basically the answers are limited to explaining advantages and disadvantages…
-
0
votes1
answer2573
viewsQ: Why is the GET method considered safe and the POST method unsafe? And in what situations should I use them?
I read that the method GET is considered "safe" and the method POST is considered "unsafe". Shouldn’t it be the other way around? The method POST does not expose the data sent in the URL, so it…
-
3
votes2
answers902
viewsA: Pick up radio value and pass to an Hidden input with same name
Instead of using the property disabled, do the event onclick returns false, so the normal action will not be executed and the user will not be able to uncheck the option. With this solution, your…
-
6
votes3
answers1172
viewsA: How to make change in order sequence with SQL statement
The technique for this is to make a Join to get the 2 lines to be exchanged and then do a simple update, see: UPDATE tabela AS tabela1 JOIN tabela AS tabela2 ON ( tabela1.ordem = 1 AND tabela2.ordem…
-
2
votes1
answer499
viewsA: Pass Post method to function
From what I understand, your class doesn’t have a magic method or a method that defines the value of the variable sql. You see, your method executar depends on this variable: //... $query =…
phpanswered Filipe Moraes 8,737 -
1
votes2
answers70
viewsQ: How Symfony 2 manages route conflicts with the same name
I am using Annotations in the project. In the archive routing.yml I have the following configuration: acme_store: resource: "@AcmeStoreBundle/Controller/" type: annotation prefix: /acme teste_blog:…
symfony-2asked Filipe Moraes 8,737 -
0
votes1
answer1349
viewsA: How to consume 4shared REST API using PHP?
There are parameters that are required for the Oauth 1.0 authentication flow to work properly: oauth_signature oauth_signature_method oauth_timestamp oauth _nonce Either you fill them all in…
-
8
votes2
answers3664
viewsA: How to prevent CSRF attack without PHP frameworks?
I believe it is necessary to protect all your forms against CSRF attacks, even those that need authentication to gain access, since the attacker can create an account, log in and attack. Every type…
-
2
votes1
answer263
viewsA: PHP does not send email and no error appears
Your code enviar_mensagem.php has a if verifying whether the field nomeand the countryside mensagem was sent. That one if does not have a else, soon if one of these indexes is missing in the array…
-
6
votes2
answers7486
viewsA: An Exception PDO occurs when localhost is used as a host
It seems that the problem is related to the connection of PHP with Mysql. From what I understand, when we use localhost as host, PHP uses socket to connect to Mysql, unlike when we use 127.0.0.1…
-
4
votes2
answers7486
viewsQ: An Exception PDO occurs when localhost is used as a host
Consider the following adaptor class DbAdapterMySQL that extends the class PDO: class DbAdapterMySQL extends \PDO implements DbInterface { public function __construct(array $config) { $dsn =…
-
1
votes1
answer1355
viewsA: Compress / compress image after upload
See this script, it converts images to jpeg. The parameter imagemOriginal is the path where the original image is, the parameter imagemFinal is the final name after conversion and the parameter…
phpanswered Filipe Moraes 8,737