14 February 2017

Digital Life: How to store your Photos, Files and Music

As a professional software engineer I'm often asked socially about computer problems. Most of them stem from not having their systems set up properly in the first place or a lack of understanding of the importance of doing that, hence this post.

Why

If you only have files (photos, music, spreadsheets etc) on your computer then you will ultimately loose them: hard drives have a fixed life span and one day it will fail: its not 'if', its 'when'. So you need to use an alternative place to store them. Previously we used to use 'local' backups: large disks at home that the computer will backup to, however, with the advent of smartphones and tablets it makes much more sense to use online services that are then available to all your devices.

Cloud Storage

All your files, e.g. letters written in Word or spreadsheets should all be kept in a secure online storage solution e.g. Google Drive (https://drive.google.com). In the same way as for the photos, there is an application to install on your computer to keep a folder in sync with this online storage:
https://www.google.com/drive/download/
In this way. when your computer dies, you still have all your files.
If you're neurotic, there are solutions like ownCloud that keep your files away from Google etc.


Backup

NB: Cloud Storage solutions like GDrive or Dropbox are a syncing solutions NOT a backup, so when you delete the file on your computer its deleted online too. For backup, other cloud services like https://www.crashplan.com exist.

Passwords

Passwords should not be re-used: if one service is compromised (hacked) as we see in the press almost weekly, then its likely your email/password combination will be traded online with everyone else's, and then used to try defraud you e.g. steal your identity. Once this happens its very difficult/costly to 'go back'.
I recommend using a 'Password Safe' program in which to store your credentials. This is then a single password to enter that 'safe' and all your passwords are within. You can store this on a cloud storage (e.g. Google Drive see 'Cloud Storage') and access it from all your devices (phone, ipad, computer)
KeePass: http://keepass.info/download.html
An alternative is to use an online service where you store all your passwords like http://www.lastpass.com/ The advantage is it's easier to setup and use, the disadvantage is that all your passwords are on their servers so you are trusting that they are keeping them securely, will stay in business and won't be hacked.

Photos

If you're using mixed 'platforms' (e.g. Windows and Mac) then Apples iCloud won't work for you: it only really works within the Apple systems. Most alternatives offer some kind of application that you download to your computer which then uploads all your photos over time. You'll need to leave it on for a week or so for this to happen, depending on how many photos you have.

As most people have a gmail account you'll already have access to Google Photos and they offer an app to download here:
https://photos.google.com/apps
You'll likely need to tell it which folders to include/ignore and also to set it to 'upload original' not a reduced size version. There will likely be a cost implication (a few dollars a year) but the alternative is loosing your photos.



09 February 2017

.Net Core Project Files

I've spent he last few weeks playing around with the new project format (csproj) and VS2017 RC2 seeing if its possible to work with this format AND allow for Cross Platform development i.e. using VS2017 on Windows, [Visual Studio Code](https://code.visualstudio.com/) on a Mac and also [VS2015](https://www.visualstudio.com/) or command line (Windows, Mac, Linux). Here are my notes from this work.

Project File Format

As of writing (9/2/2017) there are three possible formats:
* csproj: The new project format of csproj files BUT cannot be built on Mac [see this issue](https://github.com/Microsoft/vsts-tasks/issues/3311). The tooling just isn't there yet.
* xproj: project.json replacement using in VS2015. We can have project.json and xproj in same project, although not ideal as obviously they need to be kept in sync.
* project.json: Less features than the other two (e.g. not full msbuild support) and will be deprecated in favour of csproj
NB: As of writing if you open a project.json or xproj in VStudio2017 it will transform the project files into csproj moving the old to a 'backup' folder. Not all the tooling supports csproj yet.

Building

* dotnet restore
* dotnet build (optional, build will also happen when it's run)

Testing

* VSCode: Run individual tests using the C# Extension OmniSharp
* Command line: dotnet test [path/project Name NOT project file]

Running

* VSCode: Use the Debug Panel
* Command line:
  * dotnet build */**/project.json
  * [Project path] > dotnet run [path/project Name NOT project file]

NodeJs Notes

NodeJS notes for working with client side.

Installation/Setup Node.js

NPM is used for installing Node js modules i.e. client side or dev dependencies.

Install NodeJs


  • Windows: Open Command Prompt as admin in Project root.
    • Chocolatey: @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
    • Node.js NPM: choco install nodejs
  • Mac: Use the installer from Homebrew:
    • brew install node

Initialise DotNet Project

Use Yoman to create new project
* npm install -g generator-aspnet
* yo aspnet

Initialise

* Node.js: to create project.json: npm init --yes

Install NodeJs Packages

* npm search [package name]
* npm install [package name] [--no-optional]

Add Client Side Dependencies

* [TypeScript](https://www.typescriptlang.org/): npm install typescript --save-dev

JSPM

[JavaScript Package Manager](http://jspm.io/docs/getting-started.html)
* npm install jspm --save-dev
* jspm init
* Install from jspm, github or npm:
  * jspm install npm:lodash-node
  * jspm install github:components/jquery
  * jspm install jquery
NB: Got github you can use any source like owner/repo:
jspm install bulma=github:jgthms/bulma

Typings

These have been replaced by e.g:
npm install --save @types/systemjs

Add Client Side Dependency

To add a new client side dependency e.g. requirejs:
* JSPM:
    * jspm search requirejs
    * jspm install requirejs --save
* Types:
    * npm install --save @types/systemjs

Update npm

https://docs.npmjs.com/misc/semver
npm update <package name> --save

Cleaning node_modules

Sometimes the node_modules folder in particular contains too many sub-folders and the resulting folder structure is too long for Windows Ui tools to delete. To overcome this you can use a third party tool like rimraf:
* cd to node_modules's parent directory
* npm install rimraf -g
* rimraf node_modules

Develpment on Different Platform

It's possible to run the NPM part of apps on Android:
* Install Termux from Google Play
* apt update && apt upgrade
* apt termux-settup-storage
* set the environment variables: TMPDIR, TMP or TEMP

.Net Core and Docker

Docker Notes taken from Building Docker Images for .NET Core

Install

* Install: npm install -g yo generator-aspnet generator-docker
* Help: docker help


Starting New Project

See: https://docs.microsoft.com/en-us/aspnet/core/tutorials/your-first-mac-aspnet
* npm install -g yo generator-aspnet
* yo aspnet
* Select application type e.g. Web Application Basic [without Membership and Authorization]
* Enter a name


Setup API project 

Run on localhost:5000 by default


Add Docker Support

* yo docker
* Answer:
  * Language: .Net Core
  * Version: rtm
  * WebServer: y
  * Port: 5000
  * Image Name: [ProjectName]
  * Service: [ProjectName]
  * Compose: [ProjectName]
  * Overwrite: Y

Adds the following files:
* Dockerfile.debug - based on the microsoft/dotnet:1.0.0-preview2-sdk
  Used for development/debug
* Dockerfile - based on microsoft/dotnet:1.0.0-core
  Used for Release

Build Docker Images

NB: I had to:

  • Amend the standard .sh file to use .NetCore1.1 (not 1.0)
  • Amend the Dockerfile.debug:
    • Use 1.1:
      FROM microsoft/dotnet:1.1.0-sdk-projectjson
    • Include a line to install unzip:
      RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*
      before RUN curl
  • Amend DockerFile to use 1.1:
    FROM microsoft/dotnet:1.1.0-runtime
*  Build Debug image from Dockerfile.debug
   ./dockertask.sh build debug
*  Build Release image from Dockerfile
  ./dockertask.sh build release

Run

* docker run -d -p 5000:5000 [image name]:[tag name]
* Load in browser: e.g. http://localhost:5000/api/values

Docker Images/Containers

* Cleanup:
  docker system prune

Images
* List:
  docker images
* Delete
  docker rmi [the image ID]
* Delete 'Dangling' i.e. without tags:
  docker rmi $(docker images -qf "dangling=true")

Containers
* List:
  docker ps -a
* Remove all existing containers (not images!):
  docker rm $(docker ps -a -q)
* Kill all containers and remove them:
  docker rm $(docker kill $(docker ps -aq))

01 February 2017

JIRA Startup Fix: The following plugins are required

Problem

On Windows:

JIRA Startup Failed

The following plugins are required by JIRA, but have not been started:

Atlassian Navigation Links Plugin (com.atlassian.plugins.atlassian-nav-links-plugin)
Gadget Directory Plugin (com.atlassian.gadgets.directory)
Atlassian JIRA - Plugins - Gadgets Plugin (com.atlassian.jira.gadgets)
Atlassian JIRA - Plugins - Global Issue Navigator (com.atlassian.jira.jira-issue-nav-plugin)
Atlassian JIRA - Plugins - Quick Edit Plugin (com.atlassian.jira.jira-quick-edit-plugin)

Atlassian JIRA - Plugins - REST Plugin (com.atlassian.jira.rest)


Workaround

  1. Get the Service name and run directory from the JIRA Service properties
  2. Change to JIRA bin directory:
    cd "C:\Program Files\Atlassian\JIRA\bin\"
  3. Load the properties tab:
    C:\Program Files\Atlassian\JIRA\bin>tomcat8w //ES//JIRASoftware010217094719
  4. In Atlassian JIRA Properties, Java tab, add the following Java Option on a new line:
    -Datlassian.plugins.enable.wait=300

30 January 2017

Windows 10 - Remove Mail and Calendar

When setting up in built Mail app you may have:
"You must make your PC more secure to connect to this server...
Enforce these policies"

Removing the suspect email account may result in an Error with no further useful information.

Remove the Mail (and Calendar) app:
Powershell as admin:
Get-AppxPackage *windowscommunicationsapps* | Remove-AppxPackage

To re-install:
Get-AppxPackage -AllUsers| Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”}

10 January 2017

Windows 10 - Remove Mail and Calendar

When setting up in built Mail app you may have:

"You must make your PC more secure to connect to this server...

Enforce these policies"

Removing the suspect email account may result in an Error with no further useful information.

Remove the Mail (and Calendar) app:

Powershell as admin:

Get-AppxPackage *windowscommunicationsapps* | Remove-AppxPackage

To re-install:

Get-AppxPackage -AllUsers| Foreach {Add-AppxPackage -DisableDevelopmentMode -Register “$($_.InstallLocation)\AppXManifest.xml”}