Tag Archives: hints

Remove .svn file or folder

find -name '.svn' -type d -print | xargs rm -rf {}
rm -rf `find . -type d -name .svn`

List empty directories on Ubuntu

find your/path -depth -empty -type d

Add PHPUnit to your Include Path (eclipse based IDE)

1 – Choose “Project” -> “Properties” or “Window” -> “Preferences” -> “PHP” (for global usage)
2 – Choose “PHP Include Path”
3 – Click on “Add External Source Folder” (typically PHPUnit is based on /usr/share/php/PHPUnit for linux distro)

Backup / Export users from MySql

put this on your ~/.bashrc

mygrants()
{
  mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
    'SHOW GRANTS FOR ''', user, '''@''', host, ''';'
    ) AS query FROM mysql.user" | \
  mysql $@ | \
  sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
}

usage

mygrants --host=[HOST] --user=[USER] --password=[PASSWORD]

I found this solution on: http://bit.ly/JMFCOd

Output while running (PHP)

ob_start();
for($i=0; $i<3; $i++)
{
   echo 'printing...';
   echo str_repeat(' ', 65536); // set a minimum output
 
   ob_flush();
   flush();
   usleep(300000);
}

Reverse Engineer (Workbench, Doctrine, Symfony2) with annotation

Hi guys!!

First of all you need to create a data model on workbench and update your database

After your database is populated, run this:

php app/console doctrine:mapping:convert xml ./src/[YOUR/BUNDLE]/Resources/config/doctrine/metadata/orm --from-database --force

so run this:

php app/console doctrine:mapping:import [YourBundle] annotation

and this:

php app/console doctrine:generate:entities [YourBundle]

list assume-changed files on git

git ls-files -v | grep "^[[:lower:]]"

routine to backup / restore mysql database

mysqldump -u root --password=[PASSWORD] [DATABASE] --compact -R --skip-lock-tables --default-character-set=utf8 | gzip -c > /path/to/your/$(date +%Y-%m-%d_%H-%M-%S)backup.gz
gunzip -c /path/to/your/backup.gz | mysql -u [USER] --password=[PASSWORD] [-h HOST] [DATABASE] --default-character-set=utf8

adduser ubuntu

useradd -s /bin/bash -m -d /home/[USER] [USER]

Grant Acess to user for any host (MySQL)

GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY 'topsecret';
Page 1 of 512345