Install and use drush in a shell

Go to a destination which you can create folder. Execute the command:

wget --quiet -O - http://ftp.drupal.org/files/projects/drush-7.x-5.6.tar.gz | tar -zxf - -C ./

Then, you have drush in your hand.

./drush/drush status

Advertisements

Latitude and Longitude In Google map. How to.

Paste in browser:

javascript:void(prompt('',gApplication.getMap().getCenter()));

Render a Views in Drupal 6

Code copied from og module:

  $closerview = views_get_view('viewscloser');
  $closerview->is_cacheable = FALSE;
  $closerview->set_display('default');
  // TODOL: not working
  $closerview->override_path = "node/$node->nid";
  $closerview->set_arguments(array($node->nid));  
  $closerview->display_handler->set_option('style_options', array('description' => $node->og_description));
  print $closerview->render();

DB backup restore command line

Backup

mysqldump -u dbuser -p db_name | gzip -9 > db.sql.gz

Restore

New DB:
gunzip < db.sql.gz | mysql -u dbuser -p dbname
Existed DB:
mysqlimport -u dbuser -p dbname db.sql
// Sorry this version is not in compressed

Find files contains text Linux

find . -type f -exec grep -il "Text to find" {} \;

Bonus:  Search command in WinSCP

find . -type f -exec grep -il "!?prompt?!" {} \;

Backup and Restore in UBUNTU

Backup:
cd targetfolder
tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz ./

Backup with split

cd targetfolder
tar -cvpz backup.tar.gz --exclude=/backup.tar.gz ./ | split -d -b 3900m - ./backup.tar.gz. 

Export:

tar -xvpzf backup.tar.gz -C targetfolder

Export with concat:

cat *tar.gz* | tar -xvpzf - -C targetfolder

List all cron jobs by crontab in UBUNTU

Command line:

 for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done