03 December 2018

Update packages for Ubuntu 18.04

Default package list is a bit short, so if you want to use standard packages you'll need to amend it:
  • Confirm it's release (you'll need this in the next step)
    cat /etc/*-release
  • For 18.04 Package isn't included in the default sources.
  • Search for it e.g. https://packages.ubuntu.com/search?keywords=xen-hypervisor&searchon=names
  • Modify the package sources list to include it's source:
    • sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
    • vi /etc/apt/sources.list
    • Add:
      deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
      deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
      deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
      deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
      deb http://archive.canonical.com/ubuntu bionic partner
    • sudo apt-get update

01 December 2018

Install XenProject

UPDATE: In the end I just went with Citrix XenServer as I found the open source version too difficult to get working:

  • Documentation out of date, instructions no longer apply to the Host
  • Unable to get guest OS installed
  • Unable to reattach previous guest OS installs
  • Conflicting information about toolsets and Host OS


Additional notes supplementing:

Install Host (Dom0) and XenServer

  • Install Ubuntu (see previous post Ubuntu install checklist)
  • Install Xen:
    • sudo apt-get install xen-hypervisor-amd64
      If package isn't found see below (Update packages)
    • reboot
  • Setup Network as bridged:
    • sudo systemctl stop network-manager
      (it may not be in use)
    • If your system is using netplan backup the conf:
      sudo cp /etc/network/interfaces /etc/network/interfaces.backup
    • Install ifupdown
      sudo apt install ifupdown
    • Set the config for ifupdown:
      vi /etc/network/interfaces (then see below)
    • The default timesout at 5mins (boot) so reduce that:
      cp /lib/systemd/system/networking.service /lib/systemd/system/networking.service.backup
      vi /lib/systemd/system/networking.service
      TimeoutStartSec=30sec

/etc/network/interfaces

auto lo eth0 xenbr0
iface lo inet loopback

iface xenbr0 inet dhcp
  bridge_ports eth0

iface eth0 inet manual

Troubleshooting

25 October 2018

Autopost Blogger to Twitter

Back in 2012 I wrote about sharing posts to other social media via Google+ (Auto post Google+ to Twitter, Facebook, LinkedIn etc.) but now that that service is shutting down it can't operate as a central hub.

I've instead switched to using IFThisThenThat (IFTTT). There are many 'recipes' on there but I went with what appeared to be the most popular: Share your new Blogger posts to Twitter by dude3966.

Its laughably simple: sign up with IFTTT, authenticate with Blogger and Twitter then turn it on.

23 October 2018

LF would be replaced by CRLF

Introduction

When collaborating across environments with Git you'll often get the insanely annoying:
"Fatal: LF would be replaced by CRLF in..."

To my mind this message is both backwards and lacking information:
If you check it out/or clone to another folder with your current core.autocrlf configuration, LF will be replaced by CRLF

The file will have its original line endings in your (current) working directory.

Ultimately it all comes down to the line endings used by both systems explained in detail on the pages:

Fixing The Problem

Convert individual files' line endings:

  • Windows: Notepad++
    Edit
    EOL Conversion: choose the one you want.
  • Mac: dos2unix
    CRLF to LF: unix2dos [filename]
    LF to CRLF: dos2linx [filename] 

Set autocrlf setting

Default is false which won't change anything BUT this won't work cross platform: if you create a file on Windows it will be left as CRLF.
  • Check the setting: git config --global core.autocrlf
  • Ensure you have line endings in the repo:
    • git config --global core.autocrlf input
  • Add guard comparing if the reversed newline transformation would result in the same file:
    • git config --global core.safecrlf warn

Add a .gitignore file

Convenient list of files by alexkaratarakis here
Example for a c# project:
text=auto

# These files are text and should be normalized (convert crlf => lf)
*.cs      text diff=csharp
*.xaml    text
*.csproj  text
*.sln     text
*.tt      text
*.ps1     text
*.cmd     text
*.msbuild text
*.md      text

# Images should be treated as binary
# (binary is a macro for -text -diff)
*.png     binary
*.jepg    binary

*.sdf     binary

Reset the Git repository

If you've got a repository with mixed line endings. you'll need to reset all the files to use LF:
  • Linux: 
    • git config --global core.safecrlf warn
    • dos2unix **
    • git add -u
  • GitHub for Windows has dedicated "normalize your repo's CRLF" setting
See also:

Check Your Editor Settings

  • VSCode: "files.eol": "\n"

12 March 2018

NPM Missing from Path: X

If you get a message similar to:
'X'  is not recognized as an internal or external command,
operable program or batch file.

Your npm path might be missing from the system PATH. To correct this:

  • Edit the Environment Variables
  • Add a new entry: %USERPROFILE%\AppData\Roaming\npm

20 February 2018

Mac Parallels Unable to Start Virtual Windows

On Sunday morning, my Windows VM blue screened. I was able to get it working again witht he following procedure:

  • In Mac Recovery mode (Apple R + Power), Terminal: csrutil disable
  • Relaunch OSX, shoudl be able to start Parallels virtual
  • Upgrade Parallels to v13
  • Check can run VM
  • Back in Mac Recovery, Terminal: csrutil enable
  • Relaunch OSX, Should still be able to run VM

This KB article by parallels:
http://kb.parallels.com/124294
Which suggests using csrutil disable to re-gain access to the VM. This worked for me.

Also found this one by VMWare which has a similar vein:
https://kb.vmware.com/s/article/2151780

Python on a Mac

Don't use the default Python installation: it isn't the latest and can result in permissions issues and pacakges being wiped after an OSX update.


  1. Install it from Homebrew:
    brew install python
  2. Check which version of Python you're using:
    which python
    If it responds '/usr/bin/python' you're using the system one. Read on.
  3. Edit the paths to include your Homebrew Python install:
    sudo vi /etc/paths
  4. Prepend /usr/local/bin to the list of locations
  5. Check the result:
    python
    Should result in the Homebrew version.