Yii2: crud com dropdown llist em foreing key

http://stackoverflow.com/questions/30394109/yii2-foreign-key-dropdown

fev13

Linux Procurar String em Arquivo

Busca recursivamente a partir do caminho em que você está.

grep -rnw ‘/caminho/da/pasta/’ -e ‘String que você procura’

Show!

jan30

Magento problema Login local

had the same problem….

The answer is that your theme does not supply a variable called form_key.

Just as stated above I have to add:

you add it right after

    to each one of my login.phtml files for the theme.

    You may also have problems with update quantity of cart items

    Take a look at http://iamvikram.com/magento-form-keys-in-version-1-8/ for more information

    Here is the importance of form_keys:

    Since the beginning of time, Magento’s backend contained a form key that protected against XSS attacks [1]. With Magento 1.8 the form key has entered the frontend for pretty much the same reason: to protect against form submission from another website, using your browser. a malicious attacker can add stuff to your cart while you’re in a different browser tab or even complete an order for you. This relies on predictable URLs, because the site will not have access to the actual HTML content in the browser tab where you have your Magento order waiting. Everything sent to the Magento store will however submit your cookies and thus use your session.

    By adding a unique key to each form or to each link that generates an action on the server, the URL or form content becomes no longer predictable. The form key is stored in the session data and validated upon submission to the server. If they don’t match, you get a form key error and the action is not completed.

    Fonte: http://magento.stackexchange.com/questions/31933/customer-login-doesnt-work-in-1-9

jan30

Magento limpar logs

You can either configure the shell utility log.php as a cron job or run manually to clean on-the-fly.

From the Magento root directory, type the command:
php -f shell/log.php clean

2. Use the –days switch to specify how many days of history to save.

- See more at: https://docs.nexcess.net/article/how-to-perform-magento-database-maintenance.html#sthash.wWuO1HRQ.dpuf

jan30

MySQL: alterar senha root

https://www.rackspace.com/knowledge_center/article/mysql-resetting-a-lost-mysql-root-password

Not the Server root user

A common issue is confusing the Server root user with the MySQL root user.

The Server root user is the server’s main user. The MySQL root user has complete control over MySQL only. The two ‘root’ users are not connected in any way.

Stop MySQL

The first thing to do is stop MySQL. If you are using Ubuntu or Debian the command is as follows:

sudo /etc/init.d/mysql stop

For CentOS, Fedora, and RHEL the command is:

sudo /etc/init.d/mysqld stop

Safe mode

Next we need to start MySQL in safe mode – that is to say, we will start MySQL but skip the user privileges table. Again, note that you will need to have sudo access for these commands so you don’t need to worry about any user being able to reset the MySQL root password:

sudo mysqld_safe --skip-grant-tables &

Note: The ampersand (&) at the end of the command is required.

Login

All we need to do now is to log into MySQL and set the password.

mysql -uroot

Note: No password is required at this stage as when we started MySQL we skipped the user privileges table.

Next, instruct MySQL which database to use:

use mysql;

Reset Password

Enter the new password for the root user as follows:

update user set password=PASSWORD("mynewpassword") where User='root';

and finally, flush the privileges:

flush privileges;

Restart

Now the password has been reset, we need to restart MySQL by logging out:

quit

and simply stopping and starting MySQL.

On Ubuntu and Debian:

sudo /etc/init.d/mysql stop ... sudo /etc/init.d/mysql start

On CentOS and Fedora and RHEL:

sudo /etc/init.d/mysqld stop ... sudo /etc/init.d/mysqld start

Login

Test the new password by logging in:

mysql -u root -p

You will be prompted for your new password.

jan17

Linux: Encontrar arquivos por extensão.

find . -name ‘*.php’ | xargs ls -lh

find . -name ‘*.php.suspected’ | xargs ls -lh

nov10

Linux: tamanho de pasta e espaço disponível

Por vezes, quando se está trabalhando em um servidor, é necessário saber o tamanho de uma pasta, bem como o espaço disponível em disco. Se você estiver acessando o server via ssh (99,9% das vezes) você faz isso num terminal.

Para estas duas necessidades, temos estes dois comandos:

  • Listar espaço disponível em disco:
 df -h
  • Listar tamanho de pasta:
 du -hs

Simples como deve ser! :)

set21

Linux: Melhor Fonte para Terminal

Encontrei uma fonte top para terminais no Linux.

É Unifont Medium, no tamanho 12.

Agregado com o fundo preto e cor de fonte amarelo (o que ouvi dizer ser o melhor contraste que existe), proporcionou uma excelente experiência no uso dos terminai.

Segue screenshot da tela.

ago22

Linux: comando SCP

Exemplo:

scp /path/to/source-file user@host:/path/to/destination-folder/

Só isso.

ago18

Magento: editar página de sucesso

Rápidinho:

  1. Você terá que editar o core, mas apenas para editar a página de sucesso. Depois reverta. Aliás, faça isso por sua conta e risco! :)
  2. Abra o arquivo app/code/core/Mage/Checkout/controllers/OnepageController.php
  3. Comente a seguinte linha: $session->clear(); (Linha 291 no Magento 1.9.0.1
  4. Pronto! Agora faça uma compra e ao chegar na página de sucesso, você pode dar refresh na página que os dados continuarão ali e você não será redirecionado para o carrinho vazio.
  5. Importante: Após suas edições, reverta o arquivo app/code/core/Mage/Checkout/controllers/OnepageController.php.

jul12