Skip to content

Instantly share code, notes, and snippets.

function Get-KeyState([uint16]$keyCode)
{
$signature = '[DllImport("user32.dll")]public static extern short GetKeyState(int nVirtKey);'
$type = Add-Type -MemberDefinition $signature -Name User32 -Namespace GetKeyState -PassThru
return [bool]($type::GetKeyState($keyCode) -band 0x80)
}
$VK_SHIFT = 0x10
function OutputStatus($message){
try {
[Console]::SetCursorPosition(0,0)
@stuartleeks
stuartleeks / cloudSettings
Last active June 24, 2020 08:12
Visual Studio Code Sync Settings GIST
{"lastUpload":"2020-06-24T08:12:00.857Z","extensionVersion":"v3.4.3"}
@stuartleeks
stuartleeks / HeaderTelemetryInitializer.cs
Created November 3, 2016 19:56
Application Insights - Capture Headers
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;
using System.Collections.Generic;
using System.Web;
namespace AppInsightsHeaders
{
public class HeaderTelemetryInitializer : ITelemetryInitializer
{
public List<string> RequestHeaders { get; set; }
@stuartleeks
stuartleeks / .gitconfig
Last active November 22, 2021 08:32
My notes for my .gitconfig
[core]
editor = code --wait
[diff]
tool = default-difftool
[difftool "default-difftool"]
cmd = code --wait --diff $LOCAL $REMOTE
[alias]
amendcommit = "!git commit --amend --reuse-message \"$(git rev-parse --abbrev-ref HEAD)\""
branches = branch -a --color -v
wip = !git add -A && git commit -qm "WIP"
@stuartleeks
stuartleeks / photo-utils.ps1
Created April 13, 2017 06:48
photo-utils.ps1
[reflection.assembly]::loadfile( "C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Drawing.dll")
function BytesToString($bytes) {
return [System.Text.Encoding]::ASCII.GetString($bytes)
}
function StringToBytes($string) {
return [System.Text.Encoding]::ASCII.GetBytes($string)
}
function GetImageTakenDate($filename) {
@stuartleeks
stuartleeks / quantum-notes.md
Last active February 28, 2018 11:38
Quantum notes

Quantum notes

These are my personal notes from reading up on Quantum Computing. There's a great series of posts here, including a more comprehensive cheat sheet that you should probably use instead!

Dirac notation and vectors

Using (a,b) to represent the column vector: (a)
@stuartleeks
stuartleeks / alias
Last active July 5, 2018 09:52
.azure/alias
[group-kill {{rg}}]
command = group delete -g {{rg}} --yes --no-wait
[get-subscription-id]
command = account show --query id -o tsv
#subscriptionId=$(az get-subscription-id)
[deployment-operation-summary {{rg}} {{name}}]
command = group deployment operation list -g {{rg}} -n {{name}} --query "[].{operationId:operationId, state:properties.provisioningState, resourceType: properties.targetResource.resourceType, resourceName:properties.targetResource.resourceName}"
@stuartleeks
stuartleeks / Verify-DeploymentGuid.ps1
Last active January 19, 2021 10:13 — forked from bmoore-msft/Verify-DeploymentGuid.ps1
Fetch the resources tagged in a pid-[GUID] deployment
<#
This is an update of the original script to work with the Az PowerShell module: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-1.0.0
Use this script to retrieve the resources that were deployed with a pid-[GUID] tag
Select-AzSubscription before running the script - it must be run within the subscription context of the deployment
The GUID and resourceGroup name of the deployment are required params
#>
Param(
[GUID][Parameter(Mandatory=$true)]$guid,
[string][Parameter(Mandatory=$true)]$resourceGroupName
@stuartleeks
stuartleeks / trip-status.sh
Created April 10, 2019 14:50
DevOpsOpenHack
#!/bin/bash
blue="\e[1;34m"
green="\e[1;32m"
no_colour="\e[1;0m"
PROD=$(kubectl get service api-trip-svc-prod --output=jsonpath={.spec.selector.slot})
echo -e "ProdColour: ${!PROD}$PROD$no_colour"
echo
@stuartleeks
stuartleeks / Links.md
Last active July 7, 2021 15:23
Build 2019 - BRK3037 - From dev to production: Container lifecycle, monitoring, logging and troubleshooting