Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
Staycation

Lawrence Gripper lawrencegripper

🌴
Staycation
View GitHub Profile
@lawrencegripper
lawrencegripper / dsc_config.ps1
Last active Mar 17, 2021
Azure Windows Container in VNET Powershell DSC
View dsc_config.ps1
<#
.SYNOPSIS
Uses PowerShell DSC to configure the machine to run the container
.PARAMETER Image
Docker Image to run complete with tag
.PARAMETER Command
Command to run in the docker image
.PARAMETER RegistryUrl
Azure container registry url
@lawrencegripper
lawrencegripper / .Dockerfile
Last active Mar 15, 2021
Azure Devops Agent inside a DevContainer
View .Dockerfile
# Very basic devcontainer, see line 15 copying in build agent start script
# https://github.com/Azure/azure-functions-docker/blob/master/host/3.0/buster/amd64/dotnet/dotnet-core-tools.Dockerfile
FROM mcr.microsoft.com/azure-functions/dotnet:3.0-dotnet3-core-tools
# To make it easier for build and release pipelines to run apt-get,
# configure apt to not require confirmation (assume the -y argument by default)
ENV DEBIAN_FRONTEND=noninteractive
RUN echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes
# Install system tools
@lawrencegripper
lawrencegripper / main.tf
Last active Mar 9, 2021
Funcs Keys listing
View main.tf
terraform {
required_providers {
shell = {
source = "scottwinkler/shell"
version = "1.7.7"
}
}
}
resource "azurerm_function_app" "functions" {
@lawrencegripper
lawrencegripper / storagediagnosticlogs.tf
Created Feb 10, 2021
Enable Diagnostic logs on an Azure storage account with terraform
View storagediagnosticlogs.tf
resource "random_string" "random" {
length = 5
special = false
upper = false
number = false
}
resource "azurerm_log_analytics_workspace" "core" {
name = "corelaw${random_string.random.result}"
location = "westeurope"
@lawrencegripper
lawrencegripper / run.ps1
Created Nov 12, 2020
Parallel Pester Tests
View run.ps1
Install-Module -Name Pester -RequiredVersion 4.6.0 -force
$testFilePath = "./tests"
# Start a jobs running each of the test files
$testFiles = Get-ChildItem $testFilePath
$resultFileNumber = 0
foreach ($testFile in $testFiles)
{
$resultFileNumber++
$testName = Split-Path $testFile -leaf
@lawrencegripper
lawrencegripper / buildyamlsnippet.yaml
Last active Nov 22, 2020
Trigger Job on file changes in Azure Devops
View buildyamlsnippet.yaml
- job: ciml
displayName: "Machine Learning CI"
pool:
vmImage: 'Ubuntu 20.04'
steps:
- task: PowerShell@2
displayName: 'Run CI Task from make.ps1 in Devcontainer'
inputs:
targetType: 'inline'
script: 'Install-Module -Name PSake -Force && Invoke-psake ./make.ps1 ciml'
View starship.toml
# Which is equivalent to
format = """
$username\
$hostname\
$shlvl\
$kubernetes\
$directory\
$git_branch\
$git_commit\
$git_state\
@lawrencegripper
lawrencegripper / main.tf
Created Jul 20, 2020
Azure VPN Gateway OpenVPN
View main.tf
resource "random_string" "random" {
length = 8
special = false
upper = false
number = false
}
resource "azurerm_public_ip" "vpn_ip" {
name = "vpn-ip"
@lawrencegripper
lawrencegripper / trap.sh
Last active May 11, 2020
Cleanup in Bash script
View trap.sh
#!/bin/bash
set -e
function cleanup()
{
echo -e "----> Trap caught! Do cleanup here"
}
trap cleanup EXIT
# imagine some stuff happens here
@lawrencegripper
lawrencegripper / togglemute.sh
Created Apr 12, 2020
Mute and unmute mic Ubuntu
View togglemute.sh
#!/bin/bash
pacmd list-sources | \
grep -oP 'index: \d+' | \
awk '{ print $2 }' | \
xargs -I{} pactl set-source-mute {} toggle
MUTED=$(pacmd list-sources | grep "muted: no" | wc -l)
if (( $MUTED > 0 )); then