Skip to content

Instantly share code, notes, and snippets.

Avatar

Lawrence Gripper lawrencegripper

View GitHub Profile
@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
@lawrencegripper
lawrencegripper / 1_gen_image_sizes.sh
Last active Feb 24, 2020
Generate docker images of specific size
View 1_gen_image_sizes.sh
#!/bin/bash
set -e
set -x
# Push 200mb image
dd if=/dev/urandom of=./file.bin bs=1M count=200
docker build -t lawrencegripper/big:200mb .
docker push lawrencegripper/big:200mb
rm ./file.bin
View 1_devcontainer.json
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/go
{
"name": "Go",
"dockerFile": "Dockerfile",
"runArgs": [
// Uncomment the next line to use a non-root user. On Linux, this will prevent
// new files getting created as root, but you may need to update the USER_UID
// and USER_GID in .devcontainer/Dockerfile to match your user if not 1000.
// "-u", "vscode",
View Makefile
KIND_CLUSTER_NAME ?= "opa-rego-teammapping"
WAIT_FOR_KIND_READY = '{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'
WAIT_FOR_OPA_READY = '{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'
.PHONY: all build test integration
all: test kind-integration
build: test
View test.rego
# patch we expect to be generated
expectedPatch = {
"op": "add",
"path": "spec/nodeSelector",
"value": {
"agentpool": "pool1"
}
}
# Helper to check patch is set
You can’t perform that action at this time.