Skip to content

Instantly share code, notes, and snippets.

@GuyHarwood
GuyHarwood / purge-blobs.sh
Created April 2, 2024 07:48
Delete multiple storage account blob containers via Azure CLI
#!/bin/bash
set -e
if [ -z "$1" ]
then
echo "storage account name required"
exit 1
fi
if [ -z "$2" ]
@GuyHarwood
GuyHarwood / decorators.ts
Last active October 21, 2022 15:41
Decorator pattern example in Typescript
// decorator example
export interface IWork {
doWork (work: any): void
}
export class ImportantService implements IWork {
doWork (work: any): void {
// important work done here
}
@GuyHarwood
GuyHarwood / sql-server-cdc.md
Created December 8, 2021 14:35 — forked from NISH1001/sql-server-cdc.md
CDC (change data capture) for Microsoft SQL server

MSSQL CLI

github...

UI

https://dbeaver.io/

sqlcmd -S <ip> -d <dbname> -U <username> -P <password> -I
@GuyHarwood
GuyHarwood / machine.js
Created December 21, 2019 17:49
Generated by XState Viz: https://xstate.js.org/viz
const checkMachine = Machine({
id: 'check',
initial: 'untaken',
context: {
restarts: 0
},
states: {
untaken: {
on: {
ALLOCATE: 'allocated'
@GuyHarwood
GuyHarwood / localstorage.wrapper.ts
Created December 16, 2019 15:37
local storage wrapper with key prefix type
export class StorageService {
setItem (key: StorageKey, item: any): void {
localStorage.setItem(key.toString(), item)
}
}
export class StorageKey {
private key: string
#!/usr/bin/env bash
set -x
CWD=$(pwd)
# deploy app1
ADMIN_APP="${CWD}/app1"
TEMP_DIR=$(mktemp -d)
cd ${TEMP_DIR}
cp -a "${ADMIN_APP}" .
cd admin
@GuyHarwood
GuyHarwood / should-it-build.js
Last active July 16, 2018 14:42
leverages github API to determine whether to build a PR request or not. Used in travis to fail builds quickly if they aren't deemed ready for building.
'use strict'
const https = require('https')
// set the id of your github PR label below...
const ciEnabledLabelId = 0
const orgAndRepo = 'yourOrg/yourRepo'
// Example call: 'https://api.github.com/repos/myorg/myrepo/pulls/557?client_id=xxxx&client_secret=yyyy'
const pullRequestId = process.argv[2]
if (!pullRequestId) {
@GuyHarwood
GuyHarwood / create-cosmos-collections-azure-cli.sh
Last active July 16, 2018 14:36
Create collections in CosmosDB from a list of json files in a directory. You can optionally use the json files to determine the expected schema of a document
#!/bin/bash
# exit on error
set -e
# input parameters
# $1 resource group to target
# $2 cosmosDB instance name
# Set variables for the new account, database, and collection

install iterm configure iterm to pick up settings file from iCloud install homebrew install zsh install zpresto

iterm key bindings

@GuyHarwood
GuyHarwood / docker-cheat-sheet.md
Last active February 28, 2018 17:04
Common Docker Commands

Attach to a running container

where container ID is 07a2f64399Af

docker exec -i -t 07a2 /bin/sh

Build image from Dockerfile

docker build -t imageName .