Skip to content

Instantly share code, notes, and snippets.

@ShawInnes
ShawInnes / MetadataHealthCheck.cs
Last active November 18, 2021 07:10
Add Metadata to ASP.NET Project
public class MetadataHealthCheck : IHealthCheck
{
private readonly string? _commitHash;
private readonly string? _product;
private readonly string? _version;
private readonly string? _commonVersion;
private readonly string? _fileVersion;
private readonly string _timeZoneName;
private readonly string _currentCulture;
private readonly string _machineName;
@ShawInnes
ShawInnes / AppInsights.ts
Created February 15, 2021 03:58
ReactCorrelation
import { ApplicationInsights, ITelemetryItem } from '@microsoft/applicationinsights-web';
import { ReactPlugin } from '@microsoft/applicationinsights-react-js';
import { createBrowserHistory } from 'history';
const reactPlugin = new ReactPlugin();
const browserHistory = createBrowserHistory({ basename: '' });
const createApplicationInsights = () => {
if (process.env.REACT_APP_ApplicationInsights_InstrumentationKey && process.env.REACT_APP_ApplicationInsights_InstrumentationKey !== '') {
const ai = new ApplicationInsights({
@ShawInnes
ShawInnes / MaskString.cs
Created November 16, 2020 00:06
Mask a string, works for various lengths
public static string MaskString(string inputString)
{
string pattern = "^(.{2}?)(.+)(.{2}?)$";
char maskChar = '*';
if (string.IsNullOrEmpty(inputString))
{
return inputString;
}
if (inputString.Length <= 4)
@ShawInnes
ShawInnes / gist:9e6e7efe341d901be3593d522da1339d
Created October 19, 2020 01:22
Analyze results from dotnet dump in a docker container
docker run -it --entrypoint /bin/bash -v `pwd`/memorydumps:/memorydumps mcr.microsoft.com/dotnet/core/sdk:3.1.101
dotnet tool install -g dotnet-dump
dotnet tool install -g dotnet-symbol
export PATH="$PATH:/root/.dotnet/tools"
dotnet-dump analyze core_20201018_213815
@ShawInnes
ShawInnes / docker-compose.yml
Created May 5, 2020 11:39
Run requestbin and ngrok for local webhook debugging
version: '3.3'
services:
ngrok:
image: wernight/ngrok
ports:
- '4040:4040'
links:
- httpbin
command: ngrok http httpbin:80
httpbin:
@ShawInnes
ShawInnes / windows_setup.ps1
Last active April 25, 2020 10:23
Windows Development Laptop Setup
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
choco install googlechrome
choco install netfx-4.5.2-devpack
choco install netfx-4.6.1-devpack
choco install netfx-4.7-devpack
choco install dotnetcore-sdk
choco install linqpad
@ShawInnes
ShawInnes / IncludeSpa.csproj
Created October 12, 2019 10:42
How to include a SPA build in asp.net core
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
<SpaRoot>../../webapp/</SpaRoot>
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
@ShawInnes
ShawInnes / README.md
Created July 15, 2019 00:07 — forked from larenelg/README.md
Brisbane Tech Meetup Code of Conduct

Brisbane Tech Meetup Code of Conduct

This meetup is dedicated to providing a respectful, harassment-free community for everyone. We do not tolerate harassment or bullying of any community member in any form. This does not only extend to members to local meetup communities, but to anyone who chooses to become involved in the larger meetup community of users, developers and integrators through events or interactions.

Harassment includes offensive verbal/electronic comments related to personal characteristics or choices, sexual images or comments in public or online spaces, deliberate intimidation, bullying, stalking, following, harassing photography or recording, sustained disruption of talks, IRC chats, electronic meetings, physical meetings or other events, inappropriate physical contact, or unwelcome sexual attention. Participants asked to stop any harassing or bullying behavior are expected to comply immediately.

If a participant engages in harassing behavior, representatives of the community may take

@ShawInnes
ShawInnes / Program.cs
Last active April 21, 2019 05:48
Using AWS Services in .net core console application
namespace Project
{
public static partial class Program
{
private static readonly AmazonS3Client _s3Client;
private static async Task Main(string[] args)
{
var profileName = "awsprofile"; // from ~/.aws/credentials
@ShawInnes
ShawInnes / shutdown_ec2.sh
Last active January 18, 2019 01:59
Auto-shutdown
#!/usr/bin/env bash
export EC2_HOME=/opt/aws/apitools/ec2
export JAVA_HOME=/usr/lib/jvm/java
PATH=/bin:/usr/bin::/usr/local/bin
source /usr/local/bin/jenkins-backup /var/lib/jenkins s3://${{self:custom.s3BucketName}}/jenkins-`date +%Y%m%d%H%M.tar.gz` >> ~/jenkins.cron.log 2>&1
asijson="$(aws autoscaling --region ap-southeast-2 describe-auto-scaling-instances --instance-ids `wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`)"
asgn="$(echo $asijson | jq -r '.AutoScalingInstances[] | @text "\(.AutoScalingGroupName)"')"