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.

19 February 2018

Mac: Create Bootable High Sierra

Find the USB mount point:
mount
Look for:

/dev/disk5s1 on /Volumes/Install macOS Sierra
or similar

sudo /Applications/Install\ macOS\ High\ Sierra.app/Contents/Resources/createinstallmedia --volume "/Volumes/Install macOS Sierra" --applicationpath /Applications/Install\ macOS\ High\ Sierra.app

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