Configure Gmail on Drupal 8 and Windows

In order to configure gmail for Drupal 8 on Windows the best way is to install the SMTP Authentication Module from here (I have installed by downloading the zip of the latest dev version). Then you can enable and go to its configuration to set-up the following in case you have a gmail account.

  1. Turn module on
  2. SMTP server: smtp.gmail.com
  3. Leave SMTP backup server empty
  4. SMTP port: 465
  5. Use encrypted protocol: Use SSL
  6. Username and Password as appropriate
  7. e-mail from address complete with your gmail e-mail
  8. e-mail from name fill in the desired name
  9. Check Allow to send html formatted emails
  10. Leave the rest as default

You can ask last for a test email to be sent, this should be working also.

 

Advertisements
Configure Gmail on Drupal 8 and Windows

Adding Virtual Hosts to Apache on CentOS

When adding a new *.conf file in /etc/httpd/conf.d/ folder and trying to restart the httpd service you may find that the service does not due to permission errors. Whatever you may try with file ownership, file permissions and different users starting Apache process nothing seems to work. This is due to a SELINUX security issue.

In order to instruct SELINUX to allow Apache use the .conf to give the following command:

 sudo chcon -t httpd_config_t [filename.conf]

 

 

 

Adding Virtual Hosts to Apache on CentOS

Karma – Spectacular Test Runner for Javascript

karma-logo

Karma is a test-runner javascript tool that executes source code against test code for each of the browsers connected. The results for each test against each browser are examined and displayed via the command line to the developer such that they can see which browsers and tests passed or failed.

Basic Setup without Grunt or Gulp

Karma needs to know about your project in order to test it and this is done via a configuration file karma.conf.js (usually named). Configuration files can be created automatically using the command karma init. An example is shown below with comments for understanding its configuration:


// Karma configuration
// http://karma-runner.github.io/0.12/config/configuration-file.html
// Generated on 2016-02-17 using
// generator-karma 1.0.1

module.exports = function(config) {
 'use strict';
 config.set({
  // enable/disable watching file/executing tests whenever any file changes
  autoWatch: false,

  // base path, that will be used to resolve files and exclude
  basePath: '../',

  // testing framework to use (jasmine/mocha/qunit/...)
  // as well as any additional frameworks (requirejs/chai/sinon/...)
  frameworks: [
    "jasmine"
  ],

  // list of test files / patterns to load in the browser
  files: [
    // bower:js
    'bower_components/jquery/dist/jquery.js',
    'bower_components/angular/angular.js',
    'bower_components/bootstrap/dist/js/bootstrap.js',
    'bower_components/angular-mocks/angular-mocks.js',
    // endbower
    "app/scripts/**/*.js",
    "test/spec/**/*.js"
  ],

  // list of files / patterns to exclude
  exclude: [
  ],

  // web server port
  port: 8090,

  // Start these browsers, currently available:
  // - Chrome
  // - Firefox
  // - PhantomJS
  browsers: [
    "PhantomJS",
    "Chrome"
  ],

  // Which plugins to enable
  plugins: [
    "karma-phantomjs-launcher",
    "karma-jasmine",
    "karma-coverage",
    "karma-chrome-launcher"
  ],

  // Continuous Integration mode
  // if true, it capture browsers, run tests and exit
  singleRun: true,

  //Enable or disable colors in the output (reporters and logs)
  colors: true,

  // level of logging
  // possible values: LOG_DISABLE||LOG_ERROR||LOG_WARN||LOG_INFO||LOG_DEBUG
  logLevel: config.LOG_INFO,

  // Uncomment the following lines if using grunt's server to run the tests
  // proxies: {
  //   '/': 'http://localhost:9000/'
  // },
  // URL root prevent conflicts with the site root
  // urlRoot: '_karma_'


  // progress is the default report (format on how to print test report)
  // For Code Coverage we add karma-coverage that uses Instanbul
  reporters: ['progress', 'coverage'],
  preprocessors: {
    // source files, that you wanna generate coverage for
    // do not include tests or libraries
    // (these files will be instrumented by Istanbul)
    'app/scripts/**/*.js': ['coverage']
   },

   // optionally, configure the reporter
   coverageReporter: {
     type : 'html',
     dir : 'coverage/'
   },
   // to avoid DISCONNECTED messages when connecting to slow virtual machines
   browserDisconnectTimeout : 10000, // default 2000
   browserDisconnectTolerance : 1, // default 0
   browserNoActivityTimeout : 4*60*1000 //default 10000
 });
};

In order to run and install Karma you need firstly to install globally
npm install -g karma-cli
Then in your project root directory add a package.json similar to the following:
(depending on the plugins declared in the config file and their dependencies)

{
  "name": "angular2",
  "devDependencies": {
    "karma-jasmine": "0.3.7",
    "karma": "0.13.21",
    "karma-phantomjs-launcher": "1.0.0",
    "jasmine-core": "2.4.1",
    "phantomjs-prebuilt": "2.1.4",
    "karma-coverage": "0.5.3",
    "karma-chrome-launcher": "0.2.2"
  },
  "engines": {
    "node": ">=5.6.0"
  }
}

and run npm install on the root directory. In order to start your tests give karma start karma.conf.js

Test are written with Jasmine and all the information you need to get started with it, is here. For getting instances of Angular controllers, services etc. you need to include angular-mocks dependency and examples can be found here.

Karma – Spectacular Test Runner for Javascript

Bower – A package manager for the web

Bower logo

Bower is a package manager for the front-end part of your web app. It installs the right versions of the packages (Javascript, html and css libraries) you need and their dependencies.

Bower keeps track of the packages under his watch in a manifest file, bower.json. If multiple packages depend on a package – jQuery for example – Bower will download jQuery just once. This is known as a flat dependency graph and it helps reduce page load.

Install Bower by giving the following command:

npm install -g bower

Then you can create a bower.json file by issuing the command:

bower init

The bower.json file specifications can be found here and below an example is explained:

{
  "name": "projectName",
  "description": "Project Description",
  "version": "0.0.0",
  "appPath": "src/main/webapp",
  "testPath": "src/test/javascript/spec",
  "dependencies": {
    "angular": "1.4.8",
    "bootstrap": "3.3.5",
    "jquery": "2.1.4"
  },
  "devDependencies": {
    "angular-mocks": "1.4.8",
    "angular-scenario": "1.4.8"
  },
  "overrides": {
    "bootstrap": {
        "main": [
            "dist/js/bootstrap.js",
            "dist/css/bootstrap.css",
            "less/bootstrap.less"
        ]
    }
  },
  "resolutions": {
    "angular": "1.4.8",
    "jquery": "2.1.4"
  }
}

name:

Required. Type: String. The name of the package as stored in the registry.

description:

Recommended. Type: String. Any character. Max 140.

resolutions:

It may be needed by a gulp, grunt library in order to override default package entry files, which are declared in their bower.json files.

resolutions:

Type: Object. Dependency versions to automatically resolve with if conflicts occur between packages.

version:

Deprecated. Still it may be needed by a gulp, grunt library.

appPath:

Self-explanatory. It may be needed by a gulp, grunt library.

testPath:

Self-explanatory. It may be needed by a gulp, grunt library.

For versioning you can use node semantic versioning symbols. More specifically based on semver, you can use

  • Hyphen Ranges X.Y.Z – A.B.C
    1.2.3-2.3.4
    Indicates >=1.2.3 <=2.3.4
  • X-Ranges
    1.2.x
    1.X
    1.2.*
  • Tilde Ranges
    ~1.2.3
    ~1.2
    Indicates allowing patch-level changes or minor version changes.
  • Caret Ranges ^1.2.3 ^0.2.5 ^0.0.4Allows changes that do not modify the left-most non-zero digit in the [major, minor, patch] tuple
    • ^1.2.x (means >=1.2.0 <2.0.0)
    • ^0.0.x (means >=0.0.0 <0.1.0)
    • ^0.0 (means >=0.0.0 <0.1.0)

 

Finally another file related to bower configuration found on the root of our web app is .bowerrc. A common use is to declare to which directory the packages are going to be installed as shown below:

{
    "directory": "src/main/webapp/bower_components"
}
Bower – A package manager for the web

Neo4J LOAD CSV Notes

Load CSV is a Cypher Command to import data to a Neo4J Graph Database

In the Neo4J Manual there are two very useful chapters for start using this tool:

  1. Chapter 11.6 with a general description  of the query
  2. Chapter 12.8 with a working example
  3. If you have also the time, there is a great YouTube video on this tool.

Other options to import data on Neo4J is the Import Tool and the Batch Insertion. However I found the  Load CSV Cypher Query to be the most intuitive.

Issues that one may find hard to work out, using this tool, are:

1. Dealing with Boolean values.

In this case we have to use CASE

USING PERIODIC COMMIT 5000
LOAD CSV WITH HEADERS FROM "file:///C:/pepAll.csv"; AS csvLine
CREATE (:Protein { identifier: csvLine.identifier,
typpep: (case csvLine.typpep when "true" then true
else false end)});

2. Dealing with array properties on nodes or relationships.

In this case we have to use SPLIT where you can define the delimiter as well.

USING PERIODIC COMMIT 5000
LOAD CSV WITH HEADERS FROM "file:///C:/pepAll.csv"; AS csvLine
CREATE (:Protein { identifier: csvLine.identifier,
arrayproperty: SPLIT(csvLine.lastcolumn, ",")});

A more complex example can be found here 

3. Create a file with many load csv queries and perform them with neo4j-shell.

On windows from the GUI windows press options and then choose command prompt.

Then issue the command

Neo4jShell -path default.graphdb -file loadcsvfile.cql
Neo4J LOAD CSV Notes

Creating a multilingual site in Joomla 3.4

1) Go to Extensions -> Language Manager

Step1

Choose Install Language by pressing the button on top left corner and on the new page press button Find Language. In the search box you can filter the list with languages shown. In our case we type “Greek”. Then you choose the language pack you are interested in and click install button.

1) Go again back to Extensions -> Language Manager

You see the new installed language and by pressing on the star button you can make it the default. On the left column choose from the menu content and in the new page press New. Fill details accordingly for your language of choice as shown below:

step2

Then save and close.

3) Go to Extensions -> Plugin Manager

In search box type Language. Two disabled plugins appear. Enable them by pressing on their status buttons.

step3

4) In order for Joomla to operate we need to keep the default menu (menu with home icon) and also keep its menu item Home in all languages set as default page (this already there since installation and we do not erase them or modify them). We also need to create menus for each language. Go to Menus -> Menu Manager -> Add New Menu. Fill details accordingly as shown below

step4

5) Go to Menus -> [name of menu created] -> Add New Menu Item. Create a new menu item for each language menu as shown below.

step5

Mind to choose the appropriate language and also very important set it as Default Page not showing in above picture. After saving the second menu item go to its Associations Tab and choose the others language menu item so switching between them is working smoothly.

5) Enable Language Switcher Module in a template module position. Go to Extensions -> Module Manager and press New. Choose Language Switcher, add title and select position in your Template where the module must appear. You are done!!

Creating a multilingual site in Joomla 3.4