Category Archives: Guides

Overwrite Selected Tree View Item Styles – Material UI ReactJS

Hi everyone,

Just a quick post on how to overwrite the styles of a selected tree item using material ui and ReactJS:

treeItem: {
paddingTop: theme.spacing(1),
‘&[aria-selected=”true”][aria-expanded=”true”] > div:nth-of-type(1)’: {
backgroundColor: ‘red’,

This will make the background color red for ONLY the selected item:


.Net Core Web Api Returning Binary File with No Headers Instead of Expected Response

Hey everyone,

A small issue I’ve run into while setting up a .net core web api microservice that also utilises a number of gRPC services. Symptoms were as follows:

Response Read via Fiddler
– HTTP/1.0 200 This buggy server did not return headers
– Value was binary and unable to be read

Server logs

03:59:23 DBG] Connection id “0HM01U963EUAR” accepted.
[03:59:23 DBG] Connection id “0HM01U963EUAR” started.
[03:59:23 DBG] Connection id “0HM01U963EUAR”: HTTP/2 connection error.
Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2ConnectionErrorException: HTTP/2 connection error (PROTOCOL_ERROR): Invalid HTTP/2 connection preface.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2Connection.ParsePreface(ReadOnlySequence`1& buffer, SequencePosition& consumed, SequencePosition& examined)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2Connection.TryReadPrefaceAsync()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2Connection.ProcessRequestsAsync[TContext](IHttpApplication`1 application)
[03:59:23 DBG] Connection id “0HM01U963EUAR” is closed. The last processed stream ID was 0.
[03:59:23 VRB] Connection id “0HM01U963EUAR” sending GOAWAY frame for stream ID 0 with length 8 and flags 0x0
[03:59:23 DBG] Connection id “0HM01U963EUAR” stopped.
[03:59:23 DBG] Connection id “0HM01U963EUAR” sending FIN because: “The Socket transport’s send loop completed gracefully.”

The issue turned out to be that in appSettings.json the default kestrel endpoint had been set to utilise http2. Removing this immediately resolved the issue. It may also be worth double checking your launch settings, startup.cs and program.cs to ensure that nothing’s been overridden.

I expect that any similar routing issues would result in similar symptoms so hopefully this post will be able to save a few people a bit time!


OpenXml Validation Spreadsheet Value Between Two Numbers – C#

Hi everyone,

Just a quick post on how to validate a numeric cell to ensure that the value is between two numbers when using OpenXml:

// Restrict min and max values
var dataValidations = new DocumentFormat.OpenXml.Spreadsheet.DataValidations { Count = 0 };
DocumentFormat.OpenXml.Spreadsheet.DataValidation dataValidation;
dataValidation = new DocumentFormat.OpenXml.Spreadsheet.DataValidation {
Type = DataValidationValues.Decimal,
AllowBlank = false,
SequenceOfReferences = new ListValue() { InnerText = $”{columnName}2:{columnName}1048576″ },
Operator = DataValidationOperatorValues.Between,
Formula1 = new Formula1 { Text = “10 “},
Formula2 = new Formula2 { Text = “20 “},

The snippet above will ensure that any values are between 10 and 20. I didn’t come across any examples for this while searching, so hopefully this will be able to help someone else out!


View Raw SQL in EF Core – Simple Option

Hi everyone,

I’ve been looking for a simple way of viewing the raw output of sql in my local environment without having to make code changes and came across the following config setup:

“Logging”: {
“LogLevel”: {
“Default”: “Debug”,
“System”: “Information”,
“Microsoft”: “Information”

This will show the sql statements in your output window without requiring any additional code:

Thanks to this stackoverflow post for the answer:

Simple React-Leaflet Location Picker Setup

Hi everyone,

Just thought I’d share a very simple react-leaflet setup in case it’s able to help anyone.


Add the css and javascript for leaflet to public > index.html:">

Install react-leaflet via npm or yarn, also add the dependencies:

npm install react-leaflet # npm
npm install leaflet react react-dom # npm

yarn add react-leaflet # Yarn
yarn add leaflet react react-dom # Yarn

Create the map component:

import React, { useState } from 'react'
import { Map, TileLayer, Marker, Popup } from 'react-leaflet'

const MapSimple = () => {

    const [location, setLocation] = useState({
        lat: 51.505,
        lng: -0.09,
        zoom: 13,
    const position = [, location.lng];
    const setMarkerPosition = e => {
        setLocation({ ...e.latlng, zoom: 19 });
        console.log(`My location is: ${JSON.stringify(e.latlng, null, 3)}`)

    return (
                attribution='© OpenStreetMap contributors'
                   A sample popup.

export default MapSimple;

NetTopologySuite Circular Reference with .net core 2.2

Hey everyone,

Testing out a spatial project with .net core and I ran into the following error:

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException : The best overloaded method match for ‘Xunit.Assert.Equal(string, string)’ has some invalid arguments

at CallSite.Target(Closure , CallSite , Type , Nullable`1 , Object )
at UpdateDelegates.UpdateAndExecuteVoid3[T0,T1,T2](CallSite site, T0 arg0, T1 arg1, T2 arg2)
at DiscussionsControllerIntegrationTests.CreateTestDiscussion(HttpClient client, ApplicationDbContext db, DiscussionCreateWebRequest payload) in DiscussionsControllerIntegrationTests.cs line: 56
at DiscussionsControllerIntegrationTests.b__1_0(ApplicationDbContext db) in DiscussionsControllerIntegrationTests.cs line: 27
at IntegrationTestBase.RunTest(Func`2 testToExecute) in IntegrationTestBase.cs line: 54
at DiscussionsControllerIntegrationTests.CreateDiscussionIsSuccessful() in DiscussionsControllerIntegrationTests.cs line: 25
at — End of stack trace from previous location where exception was thrown —

Thankfully the solution is pretty straight forward. Install GeoJSON:

Install-Package NetTopologySuite.IO.GeoJSON

Then merge the following with your existing addMvc call in startup.cs:

services.AddMvc(options =>
                // Prevent the following exception: 'This method does not support GeometryCollection arguments'
                // See:
                options.ModelMetadataDetailsProviders.Add(new SuppressChildValidationMetadataProvider(typeof(Point)));
                options.ModelMetadataDetailsProviders.Add(new SuppressChildValidationMetadataProvider(typeof(Coordinate)));
                options.ModelMetadataDetailsProviders.Add(new SuppressChildValidationMetadataProvider(typeof(LineString)));
                options.ModelMetadataDetailsProviders.Add(new SuppressChildValidationMetadataProvider(typeof(MultiLineString)));
                .AddJsonOptions(options =>
                    foreach (var converter in NetTopologySuite.IO.GeoJsonSerializer.Create(new GeometryFactory(new PrecisionModel(), 4326)).Converters)

String to Color – Avatar Helpers

Hi everyone,

A quick post on a helper function I came across for generating avatars. This function generates a random color for the specified string:

export const stringToColor = string => {

let hash = 0;
let i;

for (i = 0; i < string.length; i += 1) {
hash = string.charCodeAt(i) + ((hash << 5) - hash);

let colour = '#';

for (i = 0; i > (i * 8)) & 0xff;
colour += `00${value.toString(16)}`.substr(-2);

return colour;

Thanks to oliviertassinari:

Move Selection to Single Line – Visual Code

Hi everyone,

A quick post on how to merge a multiline block into a single line using Visual Studio Code:

-- From this
    post_id INT IDENTITY(1,1) PRIMARY KEY,
    title VARCHAR(100),
    description VARCHAR(MAX),
    user_id VARCHAR(255) NOT NULL,
    created DATETIME NOT NULL,
    updated DATETIME NOT NULL,
    version INT NOT NULL,
    up_votes INT NOT NULL,
    down_votes INT NOT NULL,

-- To this
CREATE TABLE posts ( post_id INT IDENTITY(1,1) PRIMARY KEY, title VARCHAR(100), description VARCHAR(MAX), user_id VARCHAR(255) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, version INT NOT NULL, up_votes INT NOT NULL, down_votes INT NOT NULL, updated DATETIME NOT NULL )

Simply highlight your code block, press F1, and then type “join lines”. Pressing enter will join everything. If you’re on a mac you can also use ctrl+j.

Overriding Global Variables – AWS SAM Local

Hi everyone,

Today I’ve added local overrides to the global variables in my template.yml file. This was pretty finicky – a lot of conflicting suggestions out there unfortunately. These are the settings that ended up working for me.


    "Parameters": {
        "RDS_HOSTNAME_TEST": ""


          Type: String
          Default: 'DEFAULT'

aws sam local command:

sam local start-api --env-vars "local-env-var-overrides.json"


exports.createTrapHandler = async (event, context, callback) => {

	try {

        console.log("RDS_HOSTNAME_TEST: " + process.env.RDS_HOSTNAME_TEST)
        // Outputs:

This link ended up being pretty useful:

Get User Id in Lambda node.js

Hi everyone,

A quick post on where to find the user id (sub) in a lambda requested that has been authenticated with a congito authorizer.

You’ll be able to find everything you need in the event object under requestContext > authorizer > claims:

exports.viewContextHandler = async (event, context, callback) => {

"requestContext": {
    "resourceId": "XXXXX",
    "authorizer": {
        "claims": {
            "at_hash": "XXXXX",
            "sub": "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX",
            "aud": "XXXXX12341234512345XXXXX",
            "email_verified": "true",
            "token_use": "id",
            "auth_time": "1547371205",
            "iss": "",
            "cognito:username": "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX",
            "exp": "Sun Jan 13 10:20:05 UTC 2019",
            "iat": "Sun Jan 13 09:20:05 UTC 2019",
            "email": "XXXXX@XXXXX.XXXXX"