Skip to content

Instantly share code, notes, and snippets.

View gavincampbell's full-sized avatar

Gavin Campbell gavincampbell

View GitHub Profile
@gavincampbell
gavincampbell / Install-Latest-Pester.ps1
Created February 28, 2017 11:45
Powershell script to download and extract the latest version of [Pester](https://github.com/pester/Pester)
$latestRelease = Invoke-WebRequest https://github.com/pester/Pester/releases/latest -Headers @{"Accept"="application/json"}
$json = $latestRelease.Content | ConvertFrom-Json
$latestVersion = $json.tag_name
$url = "https://github.com/pester/Pester/archive/$latestVersion.zip"
$download_path = "$env:USERPROFILE\Downloads\pester-master.zip"
Invoke-WebRequest -Uri $url -OutFile $download_path
Get-Item $download_path | Unblock-File
@gavincampbell
gavincampbell / Vagrantfile
Last active February 10, 2022 03:19
Vagrantfile for SQL Server on Linux with WideWorldImporters sample database and tSQLt framework included
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "forwarded_port", guest:1433, host:1433
config.vm.provider :libvirt do |libvirt|
libvirt.memory = "4096"
end
config.vm.provision "shell",
inline: <<-SHELL
@gavincampbell
gavincampbell / .env.example
Last active November 23, 2021 18:52
Post-deployment configuration of WordPress in Azure App Service, notes at https://gavincampbell.dev/post/post-deployment-configuration-azure-web-apps/
LOCATION=uksouth
RESOURCE_GROUP_NAME=webapp-config-demo
SERVICE_PLAN_NAME=app-service-plan-free-wp
SERVICE_PLAN_SKU=FREE
WEB_APP_NAME=mywpsite-ahfdskf
MARIADB_SKU=B_Gen5_1
MARIADB_SERVER_NAME=dbserver-ahfdskf
MARIADB_ADMIN_USER=BOSS_HOGG
MARIADB_ADMIN_PASSWORD=R05coePColtrane
WORDPRESS_DB_NAME=wpdb
@gavincampbell
gavincampbell / devcontainer.json
Created March 10, 2021 08:15
Files from post on running jupyter-pyspark in vscode
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.163.1/containers/debian
{
"name": "pyspark",
"image": "jupyter/pyspark-notebook",
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
@gavincampbell
gavincampbell / misc.ps1
Last active September 2, 2020 08:26
Powershell Aides-Mémoire
#Creating a pscredential from a username:password pair in a single line:
$Creds = New-Object System.Management.Automation.PSCredential ($User, $(ConvertTo-SecureString $Password -AsPlainText -Force))
#Self signed wildcard certificate
New-SelfSignedCertificate -Subject *.my.domain -DnsName my.domain, *.my.domain -CertStoreLocation Cert:\LocalMachine\My -NotAfter (Get-Date).AddYears(10)
# trusting the PS gallery so we can install packages unattended, e.g. for DSC
Install-PackageProvider NuGet -Force -Scope CurrentUser
Import-PackageProvider NuGet -Force
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
#generating Random String
# source: https://devblogs.microsoft.com/scripting/generate-random-letters-with-powershell/
@gavincampbell
gavincampbell / gist:72a485049ab2b0dba3ea34655607b5c3
Last active June 25, 2020 11:25
Update a markdown file to use hugo figure shortcode instead of markdown img links
sed -i 's/!\[\(.*\)\] \?(https:\/\/.*\/\(.*\))/{{< figure src="\2" caption="\1" >}}/g' index.md
@gavincampbell
gavincampbell / steps.md
Last active June 19, 2020 12:55
setting up minikube on a new Centos 7.8 VM
  1. set up network with nmcli/nmtui/whatever
  2. sudo yum update
  3. sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
@gavincampbell
gavincampbell / azuredeploy.json
Last active June 1, 2020 17:23
Example code and tests for creating conditional NSG rules using optional parameters
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json",
"contentVersion": "0.0.0.1",
"parameters": {
"vnetName": {
"type": "string"
},
"vnetAddressPrefix": {
"type": "string"
},
{
"variables": {
"build_location": "uksouth",
"build_vm_size": "Standard_DS2_v2",
"sp_client_id": "{{env `PACKER_CLIENT_ID`}}",
"sp_client_secret": "{{env `PACKER_CLIENT_SECRET`}}",
"sp_tenant_id": "{{env `PACKER_TENANT_ID`}}",
"sp_subscription_id": "{{env `PACKER_SUBSCRIPTION_ID`}}",
"output_resource_group" : "packer-vm-images",
"output_image_name_prefix" : "sql-2019-win-2019"