Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / .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 / 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 / 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"}
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)
function OutputStatus($message){
try {
[Console]::SetCursorPosition(0,0)
Write-Host $message.PadRight([Console]::BufferWidth)
}
catch [System.IO.IOException] {
## IO Exception when unable to set position
}
}
$messages = @()
@stuartleeks
stuartleeks / OpenUiSideLoad.ps1
Last active February 18, 2016 12:42
Marketplace helper scripts
param(
[parameter(Mandatory=$true, ValueFromPipeline)]
[object[]] $blobs,
[parameter()]
$uiDefinitionFilename = "createUiDefinition.json"
)
process{
$uiBlob = $blobs | ?{ $_.Name -eq $uiDefinitionFilename} | select -First 1
if ($uiBlob -ne $null){
@stuartleeks
stuartleeks / Gert-Lush.ps1
Created January 22, 2016 08:41
Gripping powershell fun ;-)
get-command Get* | %{ set-alias -name ($_ -replace "^Get","Gert") -Value $_ }
@stuartleeks
stuartleeks / GenerateTemplateParameters.ps1
Created January 14, 2016 21:05
Generate parameters for Azure Resource Manager template
param(
$templateFile,
[switch] $includeParametersWithDefaults
)
$template = Get-Content $templateFile | ConvertFrom-Json
function getDefaultValue($type){
switch ($type){
"bool" {'false'}
"int" {0}