Skip to content

Instantly share code, notes, and snippets.

@jackawatts
jackawatts / AAD v 2.0 auth protected Web API with REACT SPA end-to-end.md
Last active August 29, 2024 00:24
AAD v 2.0 auth protected Web API with REACT SPA end-to-end

A WIP (work in progress), collected from a variety of sources...

Securing the Web API

Create an App registration

eg. my-app-api

We will refer to it as {nameOfAppRegistration} from this point forward. (This can be pretty much anything but adding the suffix -api may help distinguish it from the spa registration at a later stage.)

  1. no redirect is required as there is no interactive user sign-in
@jackawatts
jackawatts / Uninstalling Visual Studio Extensions via the command line.md
Last active August 29, 2024 00:26
Uninstalling Visual Studio Extensions via the command line

Find the VSIX identifier by:

  1. Renaming the VSIX to .zip
  2. Opening the .manifest file
  3. Copy the ID from the ID attribute

Then:

vsixinstaller  /q /a /u:"<VSIX Identifier Here>"
@jackawatts
jackawatts / Vscode as default merge tool for git.bat
Created January 16, 2019 22:54
Vscode as default merge tool for git
git config --global merge.tool vscode
git config --global mergetool.vscode.cmd "code --wait $MERGED"
git config --global diff.tool vscode
git config --global difftool.vscode.cmd "code --wait --diff $LOCAL $REMOTE"
@jackawatts
jackawatts / Working with Azure AD and Graph API.md
Last active January 25, 2019 04:08
Working with Azure AD and Graph API

Access to the GraphAPI requires an auth token best collected via ADAL.NET MSAL.NET is an alternative but it does not handle caching elegantly

Configure Azure AD to have the correct permissions

  1. Login to portal.azure.com
  2. Azure AD
  3. Visit the app registration
  4. Settings => Required Permissions
  5. Add Graph API if it does not already appear in the list
  6. Add the appropriate permissions (as an app typically)
@jackawatts
jackawatts / Add an Azure Resource Manager service connection.md
Last active March 13, 2025 14:30
Adding an Azure Resource Manager Service Connection in AzureDevOps

Taken from: https://blogs.msdn.microsoft.com/mihansen/2018/03/31/granular-vststfs-deployment-privileges-using-service-principals/

AzureDevOpsAR is simply the name of the app registration AzureDevOps will be associated with, don't like the name? Simply change the references below.

  1. Create an App Registration to act as a Service Principal:
    1. Log in to portal.azure.com
    2. Azure Active Directory => App Registrations => New Application Registration
    3. Name: AzureDevOpsAR, Type: Web app/API, Url: http://azuredevopsar (Url isn't important as it won't be used)
    4. Copy the Application ID as this will be the Service principal client ID
  2. Settings => Keys => Add
  1. Only show important fields so that people don't have to spend more time filling out the form than they need to
  2. Top align fields so that the form is suitable for a mobile view
  3. Design for fat fingers so people aren't penalized for using a smaller device
  4. Collapse menus and dropdowns so that the form isn't harder to navigate through
  5. Use predictive text so that the user has to type less
  6. Use single inputs where possible so that they user has less fields to fill out
  7. Make submit buttons standout, have meaningful names & possibly 1/3 so it is clear what the user must do and they know how close they are to completing the section
@jackawatts
jackawatts / Sonarqube Quickstart for .NET.md
Last active July 17, 2018 23:08
Getting up and running with Sonarqube
  1. Install Java Runtime Environment (http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html)
  2. Download and extract sonarqube (https://www.sonarqube.org/downloads/)
  3. Launch sonarqube: C:\sonarqube\bin\windows-x86-xx\StartSonar.bat
  4. Browse to localhost:9000 to validate
  5. Install the SonarScanner for MSBuild (https://docs.sonarqube.org/display/SCAN/Install+the+SonarScanner+for+MSBuild) Edit the SonarQube.Analysis.xml file in the directory the scanner for MSBuild was installed to:
  • Ensure the sonar.host.url element points to localhost:9000
  • Ensure the directory the scanner was extracted to is added to:
  • WKT: Well-Known Text
  • SRID: a unique identifier for the co-ordinate system to be used defined by EPSG. All Geography types in SQl Server have an associated SRID. Geography instances with different SRIDS cannot be compared without additional transformation.

Note: SRIDS must be the same when performing opertations on multiple geography instances*

SqlGeometry is 2D while SqlGeography is 3D+. It is worth considering deafaulting to SqlGeometry simply unless 3D measuements or localised geography systems are used. Many 3rd parties provide data in 2D and it is easier to transform geometries to difference co-ordinate systems.

Converting KML to WKT

Try SharpKml (https://github.com/samcragg/sharpkml) great library for manipulating KML

  1. Load your KML:
@jackawatts
jackawatts / ts-jest.md
Last active June 14, 2023 08:09
Getting started with Typescript, React and Jest

Getting Started

  1. Install:
  • jest: npm install --save-dev jest
  • ts-jest: npm install --save-dev ts-jest @types/jest
  1. Modify package.json
"jest": {
  "transform": {
 "^.+\\.tsx?$": "ts-jest"