Enable Clean Url in Drupal 8 Ubuntu

Enable mod_rewrite for Apache

a2enmod rewrite

Now edit the 000-default.conf located at /etc/apache2/sites-available/

Sudo gedit /etc/apache2/sites-available/000-default.conf

Add the below mentioned lines just under DocumentRoot /var/www/html

    DocumentRoot /var/www/html
    <Directory /var/www/html>
        AllowOverride All
        Order Allow,Deny
        Allow from all

This will add AllowOverride within the default website configuration

Make sure .htaccess is in the default web directory!

ls /var/www/html/.htaccess

Roles and permissions system for Nodejs

ACL / Roles + Permissions

https://github.com/djvirgen/virgen-acl Simple and elegant, create your own checks. No middleware?

https://github.com/OptimalBits/node_acl Use as middleware, create your own roles and access. Great choice.

https://github.com/tschaub/authorized Similar to connect roles… but a bit more robust? you can create roles and action, and associate many roles with that action

https://github.com/scottkf/ability-js Like canCan for rails. This is a traditional controller / function type permission system. May be too abstract.

https://github.com/dresende/node-roles More traditional setRole() hasRole() based checking. Last activity 2 years ago.

https://github.com/carlos8f/node-relations Natural language style roles. Looks very promising and is in active development

https://github.com/ForbesLindesay/connect-roles Simple and closer to action / natural language based. Requires writing your own checks for each.

https://github.com/ajlopez/SimplePermissions Maybe too simple? Makes sense for assigning roles but then its hard to check against roles!

https://npmjs.org/package/entitlement Not ideal but here for reference sake.

Mongoose Field Access Control

https://github.com/codedoctor/mongoose-plugins-accessible-by Set access per field of mongoose Schema. Not supported or maintained, and noted as not a perfect fit in all cases… but worth considering as a simple way to control access to fields.

Redis and Predis configuration for Drupal 7

Install redis module (http://drupal.org/project/redis) and put https://github.com/nrk/predis into ‘sites/all/libraries’ and put these settings into settings.php file


define('PREDIS_BASE_PATH', DRUPAL_ROOT . '/sites/all/libraries/predis-0.8/lib/');

$conf['redis_client_interface']  = 'Predis';
$conf['cache_backends'][] = 'sites/all/modules/contrib/redis/redis.autoload.inc';
$conf['cache_class_cache'] = 'Redis_Cache';
$conf['cache_class_cache_form'] = 'Redis_Cache';
$conf['cache_class_cache_views'] = 'Redis_Cache';
$conf['cache_class_cache_page'] = 'Redis_Cache';
$conf['cache_class_cache_menu'] = 'Redis_Cache';
$conf['cache_class_cache_path'] = 'Redis_Cache';
$conf['cache_class_cache_entity_node'] = 'Redis_Cache';
$conf['cache_class_cache_entity_taxonomy_term'] = 'Redis_Cache';
$conf['cache_class_cache_entity_taxonomy_vocabulary'] = 'Redis_Cache';
$conf['cache_class_cache_entity_file'] = 'Redis_Cache';
$conf['cache_class_cache_entity_user'] = 'Redis_Cache';
$conf['cache_class_cache_filter'] = 'Redis_Cache';
$conf['cache_class_cache_admin_menu'] = 'Redis_Cache';
$conf['cache_class_cache_bootstrap'] = 'Redis_Cache';
$conf['lock_inc'] = 'sites/all/modules/contrib/redis/redis.lock.inc';
$conf['redis_client_base'] = 1;
$conf['cache_class_cache_field'] = 'Redis_Cache';

Drupal – Alter Views Exposed Filter Form and change textfield to select option in drupal 7

 * Implements hook_form_alter().
function my_module_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'tutor_search_block' && $form_state['view']->current_display == 'block') {
    // Only show published nodes as options for the exposed filter.
	$form['combine_2']['#type'] = 'select';
	$form['combine_2']['#default_value'] = '';
	$form['combine_2']['#validated'] = TRUE;
    $form['combine_2']['#options'] = array(
	'preschool' => 'Preschool'
        'primary' => 'Primary'
        'sec' => 'Sec'
        'jc' => 'JC'
        'music' => 'Music'
        'others' => 'Others'