Skip to content

Instantly share code, notes, and snippets.

View MarkWarneke's full-sized avatar
🐒
lounging

Mark Warneke MarkWarneke

🐒
lounging
View GitHub Profile
@MarkWarneke
MarkWarneke / boxstarter.ps1
Last active August 7, 2018 19:12 — forked from davidpeterh/boxstarter.ps1
Boxstarter Commands for a new Windows box.
# Description: Boxstarter Script
# Author: Mark Warneke
# Based on Boxstarter script by David Peter Hansen
# Last Updated: 2018-07-08
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
@MarkWarneke
MarkWarneke / synchronize-extensions.ps1
Created May 14, 2019 06:57
Synchronize extensions across Visual Studio Code with PowerShell
$code = code --list-extensions
$codeinsiders = code-insiders --list-extensions
Compare-Object -ReferenceObject $code -DifferenceObject $codeinsiders -PassThru | %{ code-insiders --install-extension $_ }
@MarkWarneke
MarkWarneke / Makefile
Created June 18, 2020 12:25
Makefile for python code
# Makefile for python code
#
# > make help
#
# The following commands can be used.
#
# init: sets up environment and installs requirements
# install: Installs development requirments
# format: Formats the code with autopep8
# lint: Runs flake8 on src, exit if critical rules are broken
@MarkWarneke
MarkWarneke / gh-pages.yaml
Created July 1, 2020 13:28
Gist to publish docs branch as Github pages. By CompositionalIT/farmer
name: gh-pages
on:
push:
branches: [ docs ]
jobs:
deploy:
runs-on: ubuntu-18.04
steps:
@MarkWarneke
MarkWarneke / BillableDataMBytes_by_sourceNamespace_piechart.kql
Last active January 18, 2021 09:24
A Kusto query to display BillableDataMBytes by sourceNamespace as a piechart. See https://markwarneke.me/2020-07-07-K8S-Azure-Log-Analytics-Cost/
let startTime = ago(31d);
let containerLogs = ContainerLog
| where TimeGenerated > startTime
| where _IsBillable == true
| summarize BillableDataMBytes = sum(_BilledSize)/ (1000. * 1000.) by LogEntrySource, ContainerID;
let kpi = KubePodInventory
| where TimeGenerated > startTime
| distinct ContainerID, Namespace;
containerLogs
| join kpi on $left.ContainerID == $right.ContainerID
@MarkWarneke
MarkWarneke / New-CloneServicePrincipal.sh
Last active July 23, 2020 13:42
Create a Clone Service Principal https://markwarneke.me/2020-04-02-Clone-AzureAd-Service-Principal/ you can run the following automation steps. Make sure the authenticated user executing the steps has at least the Application Administrator Azure AD role - as this role is needed for the last step to grant permissions.
# Make sure we are connected using a user principal that has Azure AD Admin permissions.
az logout
az login
# Name of the Clone Service Principal
appName="CloneServicePrincipal"
# Retrieve the teannt it
tenantId=$(az account show --query tenantId -o tsv)
@MarkWarneke
MarkWarneke / BlamelessPostMortemTemplate.md
Last active July 8, 2020 07:29
Make it easy to document post-mortems. You can use tools or other easy to use system. The easier the system is, the more people will record and detail the outcomes. See https://markwarneke.me/2019-08-27-Blameless-Post-Mortems/

<Title>

Meeting Value
Date
Contact
Created by
Facilitated by

Timeline

@MarkWarneke
MarkWarneke / New-AzTemplateReadme.ps1
Last active March 23, 2021 13:01
As Markdown is very light weight we can leverage simple strings to create our documentation. To better visualize the parameters, resource and outputs of an ARM template a table might be a feasible option for display. https://markwarneke.me/2019-08-26-Gererate-Infrastructure-As-Code-Documentation/
# New-Readme.ps1
param (
$Path = (Join-Path $PSScriptRoot "azuredeploy.json")
)
# Test for template presence
$null = Test-Path $Path -ErrorAction Stop
# Test if arm template content is readable
$text = Get-Content $Path -Raw -ErrorAction Stop
# New-ParameterFile.ps1
<#
Parameter File
Plain PowerShell Object that implement the schema of a parameter file
#>
class ParameterFile {
# https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-parameter-files
[string] $schema = "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#"
[string] $contenVersion = "1.0.0.0"
@MarkWarneke
MarkWarneke / Test-AzTemplate.spec.ps1
Created July 8, 2020 07:47
We want to ensure we have consistency and best practices checked when testing our ARM templates. The output should be human readable and easy to understand. See https://markwarneke.me/2019-08-21-static-code-analysis-for-infrastructure-as-code/
#azuredeploy.Tests.ps1
param (
$Path = (Join-Path $PSScriptRoot "azuredeploy.json")
)
Describe "[$Path] should be valid" -Tag Unit {
# Test for template presence
$null = Test-Path $Path -ErrorAction Stop