Website Development, Native Apps (Drupal, Flex, Sass, React, Git, Ubuntu)

Vagrant beetbox and ubuntu an host

Beetbox is an amazing for developing all sorts of websites. But installing it on an Ubuntu host at times there can be some small issues.

Extra vagrant packages

Make sure you provision the vagrant machine after adding the plugins as you can get the dreaded "No host IP was given to the Vagrant core NFS helper" (see issue here)

vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-faster
vagrant plugin install vagrant-hostsupdater
vagrant plugin install vagrant-auto_network
Read more

Handy linux comands that you can use from command line

Here is a list of commands the help managed your Linux machine from day to day

Find and kill a linux process from the command line

Need to remove a software process that will not go away. You might need to do it more that once,

ps aux | grep <programs name(eg firefox)> | awk 'NR==1 {print $2}'
kill -9 <number that was printed>

Setup your public ssh key so you can auto login into a server

So pipes your local public ~/.ssh/ and It copies the public key to the remote server 

Read more

Tips that will get the best out of the terminator making him your friend

The Linux terminator is a multi-paneled terminal tool that as some get tricks to speed up your everyday processes while working. As a Web Developer and DevOps administrator, this tool helps from clearing a websites cache to setting up of a server and even using vim as an IDE.  Here are some commands and tips that will help you get best out of the terminator.

1. Grouping (or synchronizing) the terminal commands

When you have multiple terminals open and you need to them to have all the same command the following  keybinding will do this.

Super+G – Group All
Super+Shift+G – Ungroup All
Super+T – Group Tab
Super+Shift+T – Ungroup Tab
Read more

bashrc function that finds file child directory and changes directory

This bash function can find a file in a child directory and change directory to the file it is once found.

function cdf() {

    FILECOUNT=$(find  .  -name $THEFILE | wc -l)

   if [[ $FILECOUNT -gt 0 ]]; then
       CHANGEPATH=$(find . -name $THEFILE  -printf '%h\n');
        echo "Warning file was found $CHANGEPATH";
        cd  $CHANGEPATH;  
          echo "Warning: $THEFILE was not found"
alias cdf=cdf
Read more

Creating a custom content type page twig file in Drupal 8

At times in Drupal 8, a site builder needs to create a custom content type page twig file. In Drupal 8 you can't just create it like you do with other twig files that come with Drupal core , you have to register a suggestion with the theme array. Adding The functions below to your template.theme will give the developer the ability to add a twig file called page--<content_type_name>.html.twig. Overriding the default page twig file in your theme

Read more

Access node machine name in Drupal 8 function

At times you need to know the machine name of the current node. The function below will allow you to access the machine name anywhere on a page load.

 * @return array|null
function _access_current_node_machine_name()
    $nidResult = \Drupal::service('path.current')->getPath();
    $nid = explode('/', $nidResult);
    if ($nid[2] != NULL) {
        $node = \Drupal\node\Entity\Node::load($nid[2]);
        return array(
            'node_id' => $nid[2],
            'node_content_type' => $node->getType(),
    return NULL;

Read more

Adding a global variable to the twig layer on every part of the page in Drupal 8

In Drupal 8 adding a variable so the twig layer can access it on every part of  the page can be done by using the template preprocessor, The word template in this function will be replaced by your theme name.

 * Implements hook_preprocess().
function template_preprocess(&$vars) {

  $vars['global_var_name'] = 'This is my var';


And then in the twig layer(file) where you need to use the variable.

Read more

How to I access an entity (e.g. node) field in Drupal8

This function access an entity field on a node in Drupal8. It works the following way, 
  • Checks to see if node exists
  • Gets the current nodes NID
  • Loads the entity that is attached to the NID
  • Returns the field name of the NID 
 * @param $fieldName
 * @return array of Objects
function _access_a_nodes_field($fieldName) {
    $nid = \Drupal::routeMatch()->getParameter('node');
    $node = \Drupal\node\Entity\Node::load($nid->id());
    return $node->get($fieldName)->getValue();
  return NULL;
Read more

Request a Drupal 8 node NID on page load

This function does exactly what it says, it returns the current Drupal 8 node NID that is being requested by the user. Be careful where you call it if the page is not a node it can break the website.

 * @return string
function _access_node_id() {
  $node = \Drupal::routeMatch()->getParameter('node');
  return $node->id();
Read more

Accessing taxonomy's name and parent TID in Drupal 8

This function allows you to access a taxonomy entity fields and get the following results. The child's parents TID, the TID, and the field's string name of the TID being requested.  The results are placed into an array and custom keys can be used when being iterated over.

It works in Drupal 8 but I have access the fields using name spacing and avoided depreciated Drupal 8 functions and methods so it should be future proofed for Drupal 9 

Read more