Skip to content

Instantly share code, notes, and snippets.

View petervandivier's full-sized avatar
🌶️
Why is it spicy?

Peter Vandivier petervandivier

🌶️
Why is it spicy?
View GitHub Profile
#!/usr/bin/env bash
wd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
pushd "$wd" > /dev/null
pattern=$1
suites=$(kitchen list --bare $pattern) || exit 1
kitchen verify $pattern
@petervandivier
petervandivier / Get-WaybackUrl.ps1
Last active January 4, 2021 21:27
Not dead yet! (ms connect)
$urllist = Import-Csv QueryResults.csv
$urllist | ForEach-Object {
$url = $_.url
$network,[int]$id=($url.Substring(30) -split '/')[0,3]
$wayback = Invoke-WebRequest "http://archive.org/wayback/available?url=$($url)"
$wayback_url = ($wayback.Content | ConvertFrom-Json).archived_snapshots.closest.url
@petervandivier
petervandivier / ConvertFrom-CkList.ps1
Created September 18, 2020 11:00
ConvertFrom-CkList
function ConvertFrom-CkList {
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline)]
[string]
$InputObject
)
$NewLine = [Environment]::NewLine
@petervandivier
petervandivier / Import-ConfigFile.ps1
Created September 16, 2020 10:31
Import-ConfigFile.ps1
function Import-ConfigFile {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[ValidateScript({Test-Path $_ -PathType Leaf})]
[string]
$Path,
[string]
#!/usr/bin/env bash
#
# this script deploys the sql scripts in the colocated subdirectories
# it supports 3 usages
# 1. docker@docker - when running `docker-compose up -d postgres`,
# the docker/config/postgres directory is mounted inside the image
# and ./deploy.sh runs locally inside the image
# 2. local@docker (debug mode) - you may make edits to the files in
# docker/config/postgres and re-run deploy.sh from your workstation.
# it will determine that there is a postgres docker instance running
@petervandivier
petervandivier / ordinal-param-Invoke-DbaQuery.ps1
Created July 2, 2020 13:54
ordinal-param-Invoke-DbaQuery.ps1
$args = @(
"ARTHUR\vagrant"
"login"
)
$query = "exec sp_whoisactive "
$params = @{}
$i = 0
$args | % {
#!/usr/bin/env pwsh
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
$Database,
[switch]
$AllowClobber,
@petervandivier
petervandivier / set-pgAdmin-encoding-on-start.md
Last active August 21, 2020 13:42
set pgAdmin encoding on-start
@petervandivier
petervandivier / get-vars-docker.sh
Last active May 4, 2020 12:21
bash expansion - string literal troubles
#!/usr/bin/env bash
PG_URL=127.0.0.1
PG_PORT=54320
PG_DATABASE=postgres
PG_SERVICE_ACCOUNT=deploy
PG_CONN=" -h $PG_URL \
-d $PG_DATABASE \
-p $PG_PORT \
-U $PG_SERVICE_ACCOUNT "
@petervandivier
petervandivier / demo.sql
Created April 24, 2020 16:10
#BestWorstCode
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1;
GO
-- To update the currently configured value for advanced options.
RECONFIGURE;
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1;
GO
-- To update the currently configured value for this feature.