08 December 2017

MySQL on Mac

The install instructions are all there but a bit detailed.

These are just shortcuts:

  1. Install from the DMG
  2. Set alias for the commands:
    alias mysql=/usr/local/mysql/bin/mysql
    alias mysqladmin=/usr/local/mysql/bin/mysqladmin
    or add to your PATH
  3. Set the root password:
    mysql -u root -h 127.0.0.1 -p
    Enter password: (enter the random password here)
  4. Use the Visual Studio Code MySQL Extension to connect to 127.0.0.1 and run queries

19 September 2017

Enable Yum Repositories on CentOS

NB: This may break your install if they've been disabled for a reason e.g. on a bespoke Linux

If the yum repos containing the packages you need are disabled by default:
  1. Find the version of CentOS:
    cat /etc/issue
  2. List the installed repos:
    yum repolist all
  3. Enable the repository in the config file e.g.:
    1. Copy original:
      cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.orig
    2. Edit file:
      vi /etc/yum.repos.d/CentOS-Base.repo
    3. Initiate INSERT mode: i
    4. Make necessary changes in the first repo:
      Uncomment (remove #) from baseurl=http
      Replace centos/$releasever with the version e.g. centos/7.2.1511
      enabled=1
  4. Update the repositories:
    yum update
    1. Install yum-utils:
      yum install yum-utils

    05 September 2017

    Favicons

    Favourite Icons aka Favicons

    Using Gimp

    Create the Original High Res PNG

    You can use whatever size you like but remember it's going to be reduced to a poultry 16px.
    • Create or download from ClipArt e.g. Clipart Library
    • Ensure you have transparency (alpha channel, represented by grey check squares)

    Save as Gif

    • Resize the image to the highest size you need e.g. 64, 48, 32, 16 px square.
    • Export as Gif e.g. favicon-64.gif, favicon-48.gif etc

    Layer the Files

    NB: If the colours are messed up in the new layers, change the image mode to RGB (Image, Mode, RGB)
    • Open the highest res gif e.g. favicon-64.gif
    • "Open as Layers" the other files (48, 32, 16)

    Export as Favicon

    • Export As and choose Microsoft Icon
    • Optionally compress them further at this stage

    30 April 2017

    Node.js Install Secific from NPM or Git

    Whilst carrying out an upgrade of an Angular2 to v4 andfollowing  instructions on the Angular blog "Updating to 4.0.0" I ran the npm install command to update Angular2 to 4:
    npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest typescript@latest --save

    However you get the error:
    npm WARN @angular/core@4.1.0 requires a peer of zone.js@^0.8.4 but none was installed.

    Trouble is the latest version of zone.js on Git was v0.8.9 when we need 0.8.4

    Install Specific Version From NPM

    You can install a specific version from npm:
    npm install <package>@<version>
    npm install zone@0.8.4 --save

    Install Specific Version from Git

    To install the specific tag from Git directly run:
    npm install git+https://github.com/angular/zone.js.git#v0.8.4 --save

    Note the format: git+; then the github normal clone url; a hash; a v; the tag name; and --save to set it in project.json

    12 April 2017

    Windows: Clear Disk Space

    Left to its own devices, Windows will happily fill up whatever drive you put it on. Latest versions are better, but still leave unnecessary bloat around e.g. Windows Updates. Cleaning up these files is particularly important when you are running virtuals.

    Where Is Space Being Used

    Use a program like TreeSize Free to find where your space is used up.

    Clean Up Disk

    Use "Disk Cleanup" program included in Windows to clear space on drive C. 
    NB You'll need to run it twice: once as normal used, then select 'Clean up System Files' to run it again and review the options.

    Clean Up WinSxS

    Windows keeps removable files in C:\Windows\WinSxs which is often quite large.
    Using a command prompt as admin:
    Dism.exe /online /Cleanup-Image /StartComponentCleanup

    13 March 2017

    Mac: Dual Boot With Windows 10

    NB: This procedure has the potential to render your machine useless. Make sure you have external backups of your data and OSX install media before you begin.

    Run Disk Utils Disk First Aid

    You need to do this to check for errors. If there are any you'll have to fix them first.
    In my case that meant:
    • Running at boot time via restart with Cmd R held down. 
    • Restoring from my Airport Extreme Time machine backup
    • Re-installing MAC OSX from the local backup as I'd excluded Applications from the TM backup.
    Boring but still, after all that my machine was back up.

    Free Up Space

    You may want to split the drive halfway but find you don't have enough space due to 'Purgable' files. These are files that MacOS has marked as deletable if the space is needed. A reboot might free up sufficient space but in my case it didn't.

    Essentially you need to create a fake file thats large enough to fill up the disk and then delete it:

    1. Install watch so you can watch the file you're creating's size:
      brew install watch
    2. Create a temp large file:
      dd if=/dev/random of=~/tempfile.tmp bs=20m
    3. Watch it's size:
      watch ls -alh ~/tempfile.tmp
    4. Once it gets to 20gb then duplicate it using Finder: Cmd d
    5. Once you get 'disk full' check the purgeable size in Disk Utility
      Repeat until the purgeable section is reduced sufficiently
    6. Turn off 'Optimize Mac Storage' in System Preferences/iCloud:
      1. Preferences, iCloud, Options next to iCloud Drive
      2. Turn off Optimize Mac Storage
    7. Delete the temp files:
      rm -f ~/*.tmp

    Install Windows

    • Open Bootcamp and run through the procedure to 
      • Download and create a bootable Windows USB drive
      • Introduce a new Windows partition
    • Once that's done, you can boot from the USB (Power on with Alt/Option key held down)
    • Install Windows, delete the Bootcamp partition and create new partitions using Windows' Setup (create's two: Drive 0 Partition 4 and Drive 0 Unallocated Space). See the note below.
    A note on partitions: After installing Windows I found the install failed with a message about being unable to write to the Boot partition. Some people online suggest doing the procedure twice: Bootcamp partition, install, fail to write, 2x PRAM reset, destroy the partition using Bootcamp, re partition. I can't be sure as I had to repeat the process anyway.

    Sound

    I had an issue whereby the Windows sound will play out of the headphone jack but not the speakers. In addition the headphone jack light was permanently on.
    I installed Realtech Audio drivers to try and fix this.

    You could also try an NVRAM reset:
    restart whilst holding Command Option (alt) P R

    Enable Virtualization in Windows

    If you need HyperV then you might find you don't get it on the Windows side:
    Hardware assisted virtualization and data execution protection must be enabled in the BIOS. See https://docs.docker.com/docker-for-windows/troubleshoot/#virtualization-must-be-enabled

    Ensure you have Virtualization is Enabled in Task Manager, Performance tab:


    You can try one of these methods:

    Restart in Windows

    Mac OS Preferences, Startup Disk, Select Bootcamp and reboot. This seems to set it correctly.

    Powershell

    To enable Hyper-V that is disabled or Hypervisor agent not running:
    1. Using PowerShell as administrator
    2. Enable Hyper-V:
      dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
      or
      bcdedit /set hypervisorlaunchtype auto

    Boot Loader

    You may need to amend the boot loader.
    To avoid: "Could not set boot device property: 0xe00002bc":
    Back in OSX:
    • Download and extract rEFind
    • Edit the config: sudo vi refind/refind.conf-sample
      • Un-comment enable_and_lock_vmx and set to true
      • You might want to reduce the timeout
    • Install it: sudo ./refind-install
    Re-enable SIP: csrutil enable

    12 March 2017

    Mac: Create Bootable SD from ISO

    Using Ubuntu as an example: https://www.ubuntu.com/download downloaded to Downloads folder.

    Download Ubuntu and Create img file


    Create Bootable SD from img file

    • Disk Utility: Erase the SD Card (not sub partition) select:
        Name: (Optional) e.g. UBUNTU
        Format: MS-DOS (FAT)
        Scheme: GUID Partition Map
    • Unmount any partitions, but leave the drive itself mounted
    • Terminal: cd to location of downloaded img
      cd Downloads (ls to check)
    • List disks:
      sudo diskutil list
    • Note identifier of SD card found by disk size e.g. disk3s2
    • Unmount:
      sudo umount disk3 && sudo umount disk3s1 && sudo umount disk3s2
    • Copy image across:
      sudo dd bs=4m if=ubuntu-16.04.2-desktop-amd64.img of=/dev/disk3
    • WAIT: It could take around 20 minutes with little indication it's happening.
    Now try your boot: Reboot and hold down Alt/Option key to select the boot disk.