Install Compass in OSX El Capitan

After getting this error:

▶ sudo gem install compass
ERROR: While executing gem ... (Errno::EPERM)
 Operation not permitted - /usr/bin/sass

It can be fixed with:

▶ brew install ruby

▶ sudo gem install -n /usr/local/bin compass

Drupal 8 install site with Drush

drush site-install standard install_configure_form.site_default_country=FR my_profile_form.my_settings.key=value

Install MySQL in OSX El Capitan with Brew

brew doctor

brew update

brew install mysql

unset TMPDIR

mysqld -initialize --verbose --user=whoami --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

(only use this last one for El Capitan)

mysql.server start

brew services start mysql

Successfully executed thanks to

Drupal 8 is admin path

To check the path of the current page:

$is_admin = \Drupal::service('router.admin_context')->isAdminRoute();

to check an arbitrary path, you need to create a Request object and obtain its matching Route:

use Symfony\Component\HttpFoundation\Request;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;

$path = '/node/1';
$request = Request::create($path);

$route_match = \Drupal::service('router.no_access_checks')->matchRequest($request);
$route = $route_match[RouteObjectInterface::ROUTE_OBJECT];
$is_admin = \Drupal::service('router.admin_context')->isAdminRoute($route);



Install Node.js & Grunt in Ubuntu 14.04

First you need to add this for add-apt-repository command to work:

$ apt-get install software-properties-common

If not you’ll get this error:

$ sudo: add-apt-repository: command not found

Install Node

$ sudo add-apt-repository ppa:chris-lea/node.js
$ sudo apt-get update
$ sudo apt-get install nodejs

Install Grunt

$ sudo npm install -g grunt-cli

Move up metatag in Drupal 7

* Implements hook_html_head_alter().  
* moving og:title up in head element list  
function mymodule_html_head_alter(&$head_elements) {  
  foreach ($head_elements as $key => $element) { 
    if($key == 'metatag_og:title') { 
      $head_elements[$key]['#weight'] = -999;