Skip to content

Instantly share code, notes, and snippets.

View GenesisCoast's full-sized avatar

Harry Sanderson GenesisCoast

  • Avanade
  • United Kingdom
View GitHub Profile
<#
.SYNOPSIS
Configures the repo permissions to restrict branch names.
.DESCRIPTION
Branches should be master, release/, hotfix/, feature/ etc
This script ensures that they are.
.PARAMETER CollectionName
Name of the Azure DevOps organization/collection.
.PARAMETER ProjectName
Name of the project in the Azure DevOps organization to configure.
@GenesisCoast
GenesisCoast / Azure DevOps Built-In Styles
Created July 26, 2022 13:13
Built-In variable styles for Azure DevOps. Will change with the Azure DevOps theme.
--palette-primary-darken-6: rgba(0, 103, 181, 1);
--palette-primary-darken-10: rgba(0, 91, 161, 1);
--palette-primary-darkened-6: 0, 103, 181;
--palette-primary-darkened-10: 0, 91, 161;
--palette-primary-shade-30: 0, 69, 120;
--palette-primary-shade-20: 0, 90, 158;
--palette-primary-shade-10: 16, 110, 190;
--palette-primary: 0, 120, 212;
--palette-primary-tint-10: 43, 136, 216;
--palette-primary-tint-20: 199, 224, 244;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
namespace GenesisCoast.Tests.Fakes
{
/// <summary>
@GenesisCoast
GenesisCoast / SNow-StringifyGr.js
Created August 28, 2019 10:51
Converts a ServiceNow glide record into a JSON string.
function stringifyGr(record) {
var result = ["{"];
var multiline = false;
for (var key in record) {
if(record.hasOwnProperty(key)) {
var value = record[key].toString();
switch (typeof value) {
case "undefined":
@GenesisCoast
GenesisCoast / PropertyTestHelper.cs
Created March 6, 2019 17:52
Helper methods to convert the specified property in a class to an Action object which can then be UnitTested.
using System;
using System.Linq.Expressions;
using System.Reflection;
/// <summary>
/// Helper methods to convert the specified property in a class to an Action object which can then be UnitTested.
/// </summary>
public class TestHelper
{
/// <summary>
@GenesisCoast
GenesisCoast / Scaffold.Old.ps1
Last active September 15, 2020 14:35
Powershell Script scaffolding for isolating the script logic, allowing for more effective Pester unit tests.
<#
.SYNOPSIS
Here is an example of how your script most-likely looks.
.NOTES
Version : 1.0
Author : Harry Sanderson
Date : 02/01/2019
#>
param(
@GenesisCoast
GenesisCoast / Batch-Pipe.ps1
Last active October 11, 2018 14:27
Example of how to batch process an array using a PowerShell pipeline.
# Implementation
function Batch-Pipe {
[CmdletBinding()]
[OutputType('System.String')]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[ValidateNotNull()]
$InputArray
)
@GenesisCoast
GenesisCoast / Common-RxJs.ts
Last active August 28, 2018 16:43
Example of implementing common behaviour accross multiple RxJS requests.
// Original - Usage and Implementation
httpClient
.get("https://google.com")
.pipe(
share(),
retry(2),
catchError((err, caught) => {
console.log(`${fileName} - ${err.statusText} (HTTP ${err.status})`, err, caught, optionalParams);
return throwError(err);
@GenesisCoast
GenesisCoast / Field-Initializers.ts
Created August 13, 2018 14:49
Typescript Field Intializers
// Method 1 - Implementation
export class Person {
public name: string = "default"
public address: string = "default"
public age: number = 0;
public constructor(init?:Partial<Person>) {
Object.assign(this, init);
}
@GenesisCoast
GenesisCoast / Using.ts
Created August 9, 2018 10:51 — forked from dsherret/Using.ts
Typescript Disposable (using statement)
interface IDisposable {
dispose();
}
function using<T extends IDisposable>(resource: T, func: (resource: T) => void) {
try {
func(resource);
}
finally {
resource.dispose();