regedit HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU “Create” -> “DWORD value (32-bit)” ->NoAutoRebootWithLoggedOnUsers Set to 1 Stop Windows 10, 11 from Restarting: The Best Methods! | DiskInternals Read more →
typescript load a stream
const chunks: string[] = []; stream.on(‘data’, function (chunk: string) { chunks.push(chunk); }); // wait for the stream await new Promise<void>((resolve, reject) => { stream.on(‘end’, resolve); stream.on(‘error’, reject); }); Read more →
typescript array indexes that have a value (filter empty | undefined)
data.map((e, i) => (e ? i : -1)).filter((e) => e >= 0) Read more →
typescript camel case to snake case
// https://stackoverflow.com/a/54246501/1515209 export function camelToSnakeCase(str: string) { return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`); } Read more →
Docker command to keep the container running
Dockerfile FROM node:16-alpine AS builder ENTRYPOINT [“tail”, “-f”, “/dev/null”] Read more →
C# style object initialisation in TypeScript
@RoutingKey(‘abc’) class Foo { public name: string | undefined; public age: number | undefined; public gender: string | undefined; constructor(init?: Partial<Foo>) { if (init) { Object.assign(this, init); } } } const foo = new Foo({ name: ‘something’ }); https://stackoverflow.com/a/72028371/1515209 Read more →
Profile webpack
setup install https://github.com/stephencookdev/speed-measure-webpack-plugin npm install –save-dev speed-measure-webpack-plugin open the webpack config file – for me this was webpack.config.js the file contained the following: module.exports = { // … }; which is changed to const SpeedMeasurePlugin = require(“speed-measure-webpack-plugin”); const smp = new SpeedMeasurePlugin(); module.exports = smp.wrap({ // … }); results for me the biggest win I had this time was with… Read more →
Testing quality gates
Fail Fast Aspiration We achieve a level of automation that would give enough confidence to allow the majority of builds to automatically deploy (via the release pipeline) directly into production. Quality Gate 1: Developer Unit Tests All directly executable behaviour should be fully covered by unit tests, e.g. controller actions public methods shared functions extension methods etc. Unit tests should… Read more →
Unit testing standards
All new code must have a complete set of unit tests. The majority of the following standards stem from the work of Roy Osherove and his book The Art of Unit Testing When is a test not a unit test? A test is not a unit test if: It talks to the database It communicates across the network It touches… Read more →
.net core catch all exception handler
app.UseExceptionHandler(options => { options.Run( async context => { var error = context.Features.Get<IExceptionHandlerFeature>(); if (error is object) { Log.Error( “EXCEPTION {method} {url} {query} => {exception}”, context.Request.Method, context.Request.Path.Value, context.Request.QueryString.Value, error.Error); } }); }); Read more →