Posts by Rodrigo Rigotti • 12,139 points
344 posts
-
2
votes1
answer879
viewsA: How do I set up apache HTTPS for a specific page and HTTP for the others?
You have to set up the domain on two Vhosts: one on port 80 and one on port 443. This will cause the site to respond both in HTTP and HTTPS on any page. After that just restrict in your application…
-
2
votes5
answers7129
viewsA: Number of weeks in a month
This is a problem that has several ways to implement a solution. My idea would be to take the amount of days a month has, split by seven (the amount of days in a week) and take the entire amount of…
-
22
votes2
answers10072
viewsA: How to rename a local branch in Git?
To rename a branch, you use the following command: git branch -m <nome antigo do branch> <nome novo do branch>
gitanswered Rodrigo Rigotti 12,139 -
1
votes1
answer42
viewsA: Conversion of parameters with Symfony2
It is not necessary to use Annotations for the ParamConverter, contrary to what I had said before. First you need to create a class that implements the interface ParamConverterInterface, according…
-
1
votes1
answer39
viewsQ: EC2 instance not loading Apache envvars file
Today at dawn I had a small problem with one of the instances of my application. I saw that the Apache was using a lot of memory, and I decided to restart it with a /etc/init.d/apache2 restart.…
apacheasked Rodrigo Rigotti 12,139 -
0
votes2
answers890
viewsA: Direct upload to Amazon S3
The ideal would be exactly that, allow the user to upload files directly to your Bucket on S3. After that just use a Bundle or a lib to be able to read the files that are there. This text takes a…
-
3
votes1
answer834
viewsA: How to customize Symfony CRUD generated form?
There is no need to change the framework files. To customize how form elements are rendered, you need to copy the template files into your application’s files. Read this documentation article to…
-
1
votes1
answer201
viewsA: How to work with I18N in PHP and Symfony?
Symfony itself has an internationalization component, and XML or YAML files are used for this. You can still read the translation of a database. Take a look at their documentation regarding:…
-
1
votes1
answer473
viewsA: Relationship in the Doctrine
For me, the class Carro would have an attribute $motorista, as well as the class Motorista would have the attribute $carro (resulting in a one-to-one, bidirectional relationship). Both attributes…
-
2
votes1
answer861
viewsA: Doctrine 2 - Does not recognize class mapped with $entityManager->getRepository()
You have to put the full name of the class, with the namespace: $gruposRepository = $entityManager->getRepository('Projeto\Core\Model\Grupos');
-
4
votes6
answers1555
viewsA: How to do the following query without using INNER JOIN?
Use the following query: SELECT PAIS_ENVIO.NOME_PAIS, PAIS_RECIBO.NOME_PAIS FROM A INNER JOIN B PAIS_ENVIO on A.ID_PAIS_ENVIO = B.ID INNER JOIN B PAIS_RECIBO on A.ID_PAIS_RECIBO = B.ID…
-
3
votes1
answer898
viewsA: Automatically e-mail in PHP?
Suppose you’re using Linux: Schedule a daily task on cron. Make this daily task run a PHP script that connects to your banks and performs the task you want - in this case, send emails.…
-
2
votes2
answers6065
viewsA: How to add 3 columns of different tables
I think the following query, using Subqueries, works: SELECT b.ban_saldoInicial + ( SELECT sum(rp.valor) FROM receitas r INNER JOIN receitas_parcelas rp ON rp.id_receita = r.id_receita WHERE…
-
3
votes2
answers277
viewsA: Query using INNER JOIN with problem
Exchange the INNER JOIN for LEFT JOIN.
mysqlanswered Rodrigo Rigotti 12,139 -
1
votes1
answer90
viewsQ: How to integrate Slmqueuesqs and Slmmail into a ZF2 application?
I am maintaining an application developed in Zend Framework 2 and accurate, in that order: Send jobs to a queue in AWS SQS. Process queue jobs via an application command that will use AWS SES. I…
-
8
votes2
answers3712
viewsA: Preventing data forwarding when updating page (F5) in ASP.NET
I already answered an equivalent question in PHP, but the same goes for any other language because what is in question is an HTTP request. Come on: When you make a POST in a form, it is incorrect…
-
3
votes3
answers9148
viewsA: Query in two tables without INNER JOIN
It makes no difference. The only difference is that in the first query you have a implicit JOIN and, in the second, a Explicit JOIN. In the past there was some difference in performance yes (it was…
-
5
votes2
answers633
viewsA: Sort array by a property
The error is in the function. Each element of $arrayPaginas is an array, not an object. Make the following correction: function ordenaPorPeso($a, $b) { if ($a['peso'] == $b['peso']) { return 0; } if…
-
2
votes3
answers3657
viewsA: How to group records by time range?
If you want to find out the peak time according to all your site’s visit history: SELECT HOUR(data) AS hora, COUNT(*) AS acessos FROM acessos_site GROUP BY hora ORDER BY acessos DESC; If you want to…
-
5
votes2
answers155
viewsA: Questions about using Git
You need to first pull the changes that other people have made (with git pull), integrate them into your project and then upload your changes (with git push). Another thing: this procedure applies…
-
0
votes1
answer2283
viewsA: API Google Drive PHP
In the links you posted, there is a link to the Google API documentation in PHP. The lib you are looking for, in its latest version, is here. Then just unzip the library and use it in your project.…
-
3
votes2
answers703
viewsA: Select an array based on the value of an internal key
I think what you can do is something like: function getParentArrays($parentPath, $arrayToSearch = array()) { $parentArrays = array(); foreach ($arrayToSearch as $key => $value) { if…
-
0
votes1
answer70
viewsA: Integrating articles to a slider
Your problem is in this code snippet: foreach ($articles as $article) { for ($articles=0; $articles <= count($articles); $articles++) { $id = 1; echo ("<p id…
-
3
votes5
answers6608
viewsA: Capture dates of a text using regular expression in javascript
Use regular expressions. var datas = texto.match(/\b(\d+\/\d+\/\d+)\b/g); console.log(datas); // output: [ "01/01/2014", "11/03/2014" ] In this particular case you take all strings that contain…
-
4
votes2
answers559
viewsA: Error query php/codeigniter
The problem is in the variable $this->db, which is not an object. Probably this variable receives an instance of the connection to the database, the connection should not be happening and…
-
2
votes2
answers182
viewsQ: Should old tags and branches be deleted from the remote repository?
One of the main products of my company already has about 4 years of life. In the meantime many branches and tags have been created, and the repository has been migrated from SVN to GIT. Because of…
gitasked Rodrigo Rigotti 12,139 -
3
votes1
answer102
viewsA: How do BETWEEN in CAKEPHP?
According to the Cakephp’s own documentation, your condition would be as follows: $imovel = $this->Imovel->find( 'all', array( 'conditions' => array('valor BETWEEN ? AND ?' => array(…
-
42
votes3
answers1787
viewsA: What does the code below (written by a Cracker) do?
The code snippet actually responsible for the "theft" of the data is the last line. Basically it is a preg_replace containing the flag e, which means that any functions within the regular expression…
-
1
votes3
answers1672
viewsA: Overwrite file snippet with php?
It would be interesting if you used regular expressions for this. You said your text file is composed of lines in the following format: 20 characters each the first 10 characters are dates,…
phpanswered Rodrigo Rigotti 12,139 -
1
votes4
answers3989
viewsA: How the relationship between the same table works
There is no performance impact when a table references itself. This is very common in hierarchical structures, for example, when a node references a parent node that is contained in the same table.…
-
1
votes2
answers231
viewsA: Removing comments in the HTML sent by the server
The solution I think you could implement would be minify your HTML. That way, you "prepare" your HTML for client requests by clearing extra spaces, removing line breaks (this just isn’t done within…
-
3
votes3
answers1927
viewsA: PHP: filter_input with REQUEST
The variable $_REQUEST is a supervariable that contains the variables $_GET, $_POST and $_COOKIE, in the order defined by Directive request_order of PHP. So I don’t see the need to use the constant…
-
4
votes8
answers7818
viewsA: Check if variable contains a well formatted PHP email address
The best way to check if a text is within a predefined pattern is by using regular expressions. On one occasion a perl script was developed to generate an expression that validated an e-mail…
-
1
votes2
answers646
viewsA: How do I convert an Html string into an image file?
Try to use the Pechkin, which is a wrapper of wkhtmtopdf. This, in turn, uses the Webkit, standard engine of some browsers, to generate the PDF. The result is practically true to what is seen in the…
-
1
votes2
answers392
viewsA: Page does not stop loading when using exec in WAMP
According to the job documentation exec(), PHP waits for the execution of the command, because the value returned by the function exec() is the last line of that implementation.…
-
3
votes4
answers650
viewsA: Return multiple arrays using a buffer without overloading memory
Implement a pagination on queries, that is, collect the result of 1000 in 1000 lines (for example) using the clause LIMIT mysql. SELECT ... LIMIT 0, 1000 SELECT ... LIMIT 1000, 1000 SELECT ... LIMIT…
-
-2
votes3
answers1814
viewsA: Installation of Laravel
You can install Laravel on any machine using the command: composer create-project laravel/laravel --prefer-dist If the composer not globally available, you can download it in the current folder to…
-
0
votes3
answers1702
viewsA: Is encapsulating the properties file in a class a good practice?
I’ll say the impression I get when working with Symfony that despite being a PHP framework, it is quite known for forcing its developers to adopt good practices (encapsulation, dependency injection,…
javaanswered Rodrigo Rigotti 12,139 -
5
votes2
answers183
viewsA: Error while removing stack item
You decrease the value of pilha->size twice. It is right to do it only once.
-
1
votes2
answers3137
viewsA: Error while uploading image in Wordpress
Give write permissions to the web server user in the folder wp-content/uploads/.
-
4
votes2
answers903
viewsA: Is it possible to upload files without using php, just with jquery?
No. An application on the server side has to receive the file and do something with the file - for example, save it to the file system. Now, if you want an application javascript only, it is…
-
2
votes1
answer119
viewsA: How to authenticate on a server site?
What you need is to develop a web Crawler. You can develop a Crawler in two different ways: With a Webkit-based solution (the browser engine like Chrome, Safari and Opera), such as CasperJS, which…
-
1
votes1
answer193
viewsA: How to check if a transaction was started in Zend
The method beginTransaction() in class Zend_Db_Adapter_Abstract is as follows: public function beginTransaction() { $this->_connect(); $q = $this->_profiler->queryStart('begin',…
-
3
votes1
answer751
viewsA: Shell send error message
Any error messages will be sent to stderr, which is the standard shell error output. The strerr is identified by the number 2 when one wants to do some action with these mistakes. So, suppose your…
-
2
votes5
answers61683
viewsA: Using line break " n" in Java
In the case of PHP, we have a constant PHP_EOL which means line breaking, because for some systems it is right to break lines with \r\n and in other systems it is simply \n. In the case of Perl,…
javaanswered Rodrigo Rigotti 12,139 -
0
votes4
answers264
viewsA: Why does Cakephp set _method to PUT instead of POST?
Cakephp POST in the form and arrow the attribute _method as PUT because the method PUT, in general, it is not natively supported by browsers. Symfony2 framework does the same thing, and see what…
-
1
votes3
answers4083
viewsA: Running jar in client from browser
The jar at all times will run on the server side. What you have to do is capture the execution output and send it to the client side. I think the wisest, in this case, would be to put your jar…
-
1
votes3
answers491
viewsA: Logica de Distribuição Igualada
This problem reminds me of the problem of graph coloring, in which you have to color a number k of vertices using a number n colors, and neighboring vertices cannot have the same colors. I wouldn’t…
algorithmanswered Rodrigo Rigotti 12,139 -
4
votes2
answers1338
viewsA: How to increase the size of the GET request to put parameters greater than 10KB in NGINX and PHP?
Amend the Directive large_client_header_buffers. Directive assigns the Maximum number and size of buffers for large headers to read from client request. The request line can not be Bigger than the…
-
3
votes4
answers41617
viewsA: Sign of different Query
Your query is wrong in this passage: ... AND AlvaraValidade is != '0000-00-00' The right thing would be: ... AND AlvaraValidade = '0000-00-00'…