NewsArticle Schema: The attribute logo.itemtype has an invalid value.

You may find Google’s structured data tool reports the error:

(The attribute logo.itemtype has an invalid value.)

For some reason, the logo attribute a publisher of a NewsArticle doesn’t take a straight url like Organization does. As such, what you need is similar to this:

“logo”:{“@type”: “ImageObject”,”url”: “”}

Hope this helps!


Create a user in mysql (shell)

Nothing groundbreaking, but for my copying and pasting convenience:

CREATE USER 'peter'@'localhost' IDENTIFIED BY 'password';

And if I want to make this user a superuser who can read and write to every database:

GRANT ALL PRIVILEGES ON *.* TO 'peter'@'localhost';

For a specific database:

GRANT ALL PRIVILEGES ON theirdatabase.* TO 'peter'@'localhost';


To make the changes active:




Resize Ubuntu Virtual Machine (VirtualBox) on Windows host

There are many tutorials for doing this, but many have unnecessary steps. While there seem to be many here also, most are simple. Here it is distilled.

  1. Release the Virtual Machine from VirtualBox. Inside VirtualBox, File>Virtual Media Manager>Select the correct vdi>Release
  2. Backup and copy your virtual machine elsewhere. Things can go wrong, so you want an untouched backup. You can just copy the whole folder that contains the vbox, and vdi file ( the latter being the most important file!)
  3. Open the Command Prompt from the Start Menu, and change directory to the Virtual Box directory. That is the VirtualBox application directory, not the virtual machine/vdi file’s location. By default on Windows, this is
    cd C:\Program Files\Oracle\VirtualBox
  4. Run VBoxManage to resize the virtual machine with the following command:
    .\VBoxManage modifyhd "C:\Users\yourname\VirtualBox VMs\Ubuntu\MyVM.vdi" --resize 50000 # e.g. resize to 50GB

    You should see: 0%…10%…20%…30%…40%…50%…60%…70%…80%…90%…100% if it’s resized correctly.

  5. I see this step skipped all the time, as the storage controller will have been removed when releasing. Right click on your Virtual Machine > Settings > Storage > Choose “Controller: SATA” > Add Hard Disk (small green plus on top of blue rectangle) > Choose Existing Disk> Choose the appropriate vdi. Failure to do this gives the “fatal: could not read from the boot medium! System halted” error.
  6. Launch the VM from VirtualBox.
  7. Open terminal
  8. Install gparted with
    sudo apt-get install gparted
  9. Run gparted
    sudo gparted
  10. You will need to remove the partition containing the linux-swap, as its position is in between /dev/sda1 and the unallocated space, means sda1 cannot be extended into the unallocated space. To start doing this, right click on the swap partition (in my case /dev/sda5 within /dev/sda2) and click “Swapoff”. Take a note of how large it is if you want to keep the size.
  11. Now click “Delete”
  12. Apply all operations — press the green tick
  13. Right click on the partition that once contained the swap, and press delete. In my case, /dev/sda2.
  14. Right click the main partition, and then click “Resize/Move”
  15. In Free Space following (MiB), choose the size of the new swap partition.
  16. Click on New Size, and it will automatically have the new size fill the rest of the free space.
  17. Press Resize
  18. Right click on the unallocated space at the end on the right, and choose New> Create as: Extended Partition. Press Add
  19. Right click on the new unallocated space in the New Partition, press New, then change setting to File system: linux-swap
  20. Press the tick to apply
  21. Right click on the partition you just changed to linux-swap, and choose ‘Swapon’.

You’re done!


fatal: index file smaller than expected – Git error

Getting this in response to a git pull, git fetch or git status? Not to worry, this can actually be fixed fairly painlessly.

In the terminal, from the project’s root directory, type the following:

mv .git/index ./git/index_backup
git add .

Alternatively, you could rm .git/index, but it is generally safer to rename the file as a backup (with mv), as above.

You will find that everything is back to, hopefully, how it was.

Good luck!


Typing Backslash (and Pipe) on a Keyboard With No Backslash Key

Just in case anyone else finds themselves in a similar predicament, I have mapped a physically US keyboard to a UK layout (I have no patience for having to search for quote marks!), and this means the backlash (and pipe) is seemingly unmapped.

Fortunately, you can still use this key using the Alt Gr key (or Right Alt key) :

Alt Gr + – (dash) will produce \ (backslash)

Alt Gr + Tilde (the key to the immediate left of 1) will produce | (pipe or vertical bar)


XDebug on Ubuntu 16.04

For some reason, the usual XDebug tailored instructions were not flying with the combination of Ubuntu 16.04 and PHP 7.1, and I have trouble understanding exactly why, as they worked fine with previous versions.

While I’m sure there is an issue I’m missing, there is another very pain-free way of adding the module. This is more of a public service announcement than any sort of instructions…


sudo apt-get install php-xdebug

Restart (assuming you are running Apache):

sudo service apache2 restart


Create a file that calls the function phpinfo(), and then access that in your web browser. You should now see that the XDebug module has been loaded. Happy days.


Freeing Up Space on Ubuntu From Update Bloat

If you have any small Ubuntu installations or virtual machines, you can often find that over time your machine starts running out of space even if you’re not using it up, with space seemingly “disappearing”. The reason is that when Ubuntu updates, it doesn’t necessarily remove the old dependencies.

To remove these unneeded dependencies, run:

sudo apt autoremove


Reset lost MySQL root password

Just installed mysql? Didn’t get issued your temporary password? Can’t log in with a blank password? Looks like you may need to reset your root password. An alternative to the mysql-init method is using mysql’s safe mode.

Type below in bold into your terminal.

  1. sudo su          (We want to operate as root here)
  2. service mysql stop      (Stop the server)
  3. mysqld_safe --skip-grant-tables --user=mysql & (We run mysql server in safe mode, and tell it to forget about the user authentication stuff) 3a. You get the error "mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.". In this case, type the following, and then re-run step 3:
    • mkdir -p /var/run/mysqld
    • chown mysql:mysql /var/run/mysqld
  4. Once it starts up (you will have your prompt available again, and it won't say anything like 'pid ended', else it didn't launch correctly), type mysql -u root
  5. USE mysql (to select database)
  6. UPDATE user SET password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
    • If you see: "ERROR 1054 (42S22): Unknown column 'password' in 'field list" then use step 6.
  7. UPDATE user SET authentication_string=PASSWORD("YOUR_NEW_PASSWORD_HERE") where User='root'; (only needed if step 5 doesn't work -- the password column name is not the same across all versions)
  9. exit (we want to restart the server normally now)
  10. killall mysqld mysqld_safe (stop the mysqld process)
  11. service mysql start
  12. mysql -u root -p
  13. Enter your new password to test. Hopefully: Voila!

Sticky Navbar Covering In-Page Anchor Links Solution

You may often find yourself with the issue of your sticky navbar covering the top of your content after being moved there by clicking an in-page anchor link. This is due to the browser not considering the bottom of the navbar as the top of the window. This snippet of javascript solves this, by instructing your window to scroll up by 50 pixels in such a situation to accommodate the height of your navbar. Obviously you may wish to change the number depending on how thick this navbar is.

var shiftWindow = function() { scrollBy(0, -50) };
if (location.hash) shiftWindow();
window.addEventListener("hashchange", shiftWindow);

However, if you’re using jquery for some smooth scrolling, then this works:

    $('html, body').animate({
        scrollTop: $( $(this).attr('href') ).offset().top-50
    }, 500);
    return false;


Hope this helps!