Skip to content

Instantly share code, notes, and snippets.

View gjonespf's full-sized avatar

Gavin Jones gjonespf

  • Power Farming New Zealand
  • Morrinsville, New Zealand
View GitHub Profile
@gjonespf
gjonespf / workitem-poster.yml
Created October 28, 2020 19:43 — forked from GerryWilko/workitem-poster.yml
Azure Pipelines Task to Post Comment to Linked Work Items (Bash)
- bash: | # Access Token should need Build Read, Work Item Read & Write, Member Entitlement Management Read
curl -u [email protected]:access-token-xxxxxxxxxxx https://dev.azure.com/{organisation}/{project}/_apis/build/builds/$(build.buildId)/workitems?api-version=6.0 | jq '.value[] | .id' |
while IFS=$"\n" read -r c; do
wid=$(echo $c | tr -dc '0-9')
echo
echo Posting status to work item: $wid
echo
curl -u [email protected]:access-token-xxxxxxxxxxx https://dev.azure.com/{organisation}/{project}/_apis/wit/workItems/$wid/comments?api-version=6.0-preview.3 -X POST --data '{"text": "Build $(Build.BuildNumber) completed with status: $(Agent.JobStatus)"}' -H 'Content-Type: application/json'
echo
done
@gjonespf
gjonespf / ExportSchema.ps1
Created June 11, 2020 04:01 — forked from cheynewallace/ExportSchema.ps1
Export MSSQL schema with PowerShell. This script will export your schema definitions for tables, stored procs, triggers, functions and views to .sql files
# Usage: powershell ExportSchema.ps1 "SERVERNAME" "DATABASE" "C:\<YourOutputPath>"
# Start Script
Set-ExecutionPolicy RemoteSigned
# Set-ExecutionPolicy -ExecutionPolicy:Unrestricted -Scope:LocalMachine
function GenerateDBScript([string]$serverName, [string]$dbname, [string]$scriptpath)
{
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
@gjonespf
gjonespf / SQLPackageDeploy.ps1
Created May 19, 2020 06:36
Script to publish SQL Server database dacpac using PowerShell and SQLPackage.exe
#=================================================================================
# Designed to deploy a database from a dacpac
#
# Usage:
# .\sqlPackageDeploymentCMD.ps1 -targetServer "LOCALHOST" -targetDB "IamADatabase" -sourceFile "C:\ProjectDirectory\bin\Debug\IamADatabase.dacpac" -SQLCMDVariable1 "IamASQLCMDVariableValue"
#
# So, why would you do this when you could just call the sqlpackage.exe directly?
# Because Powershell provides a higher level of orchestration; I plan to call this script from another script that
# first calls a script to build the dacpac that is then used in this script.
#=================================================================================
@gjonespf
gjonespf / download-latest-release.ps1
Created May 10, 2020 22:30 — forked from Splaxi/download-latest-release.ps1
Download latest GitHub release via Powershell
# Download latest dotnet/codeformatter release from github
$repo = "jgm/pandoc"
$filenamePattern = "*x86_64.zip"
$pathExtract = "C:\Tools\pandoc"
$innerDirectory = $true
$preRelease = $false
if ($preRelease) {
$releasesUri = "https://api.github.com/repos/$repo/releases"
@gjonespf
gjonespf / protips.js
Created November 17, 2019 20:35 — forked from nolanlawson/protips.js
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
# Usage: powershell ExtractInitialDatabaseScript.ps1 "SERVERNAME" "DATABASE" "C:\<YourOutputPath>"
function GenerateDBScript([string]$ServerName, [string]$Database, [string]$scriptpath)
{
$outFile = "$scriptpath\$($Database)_Inital_setup.sql"
if (-not (Test-Path $scriptpath)) {
[System.IO.Directory]::CreateDirectory($scriptpath)
}
If (Test-Path $outFile) {
Remove-Item $outFile
@gjonespf
gjonespf / deploy.ps1
Created April 12, 2018 02:48 — forked from piers7/deploy.ps1
General purpose Octopus Deploy -> Install.ps1 bootstrapper
<#
.Synopsis
General-purpose Octopus Deploy boostrapper
Binds Octopus variables directly on to parameters on an install script, passing the rest as a hashtable
This means your Install script can itself have 'proper' parameters, making local testing easier
#>
param(
$entryPoint = '.\Install.ps1'
)
@gjonespf
gjonespf / README.md
Created November 29, 2017 19:37 — forked from harshavardhana/README.md
REX-Ray with Minio

Getting Started

The following command will install the latest version of REX-Ray to /usr/bin/rexray on Linux systems:

$ curl -sSL https://dl.bintray.com/emccode/rexray/install | sh

Depending on the Linux distribution REX-Ray will be registered as either a SystemD or SystemV service.

Configure

REX-Ray requires a configuration file for storing details used to communicate with storage providers. This can include authentication credentials and driver specific configuration options. After REX-Ray has been installed, copy and paste the contents below to a new file on the host at /etc/rexray/config.yml to configure s3fs storage driver.

@gjonespf
gjonespf / swap.service
Created November 28, 2017 02:27 — forked from joshix/swap.service
Adding swap on CoreOS
[Service]
Type=oneshot
Environment="SWAP_PATH=/var/vm" "SWAP_FILE=swapfile1"
ExecStartPre=-/usr/bin/rm -rf ${SWAP_PATH}
ExecStartPre=/usr/bin/mkdir -p ${SWAP_PATH}
ExecStartPre=/usr/bin/touch ${SWAP_PATH}/${SWAP_FILE}
ExecStartPre=/bin/bash -c "fallocate -l 1024m ${SWAP_PATH}/${SWAP_FILE}"
ExecStartPre=/usr/bin/chmod 600 ${SWAP_PATH}/${SWAP_FILE}
ExecStartPre=/usr/sbin/mkswap ${SWAP_PATH}/${SWAP_FILE}
ExecStartPre=/usr/sbin/sysctl vm.swappiness=10
@gjonespf
gjonespf / docker-compose-coreos.sh
Last active March 19, 2017 23:23 — forked from powareverb/docker-compose-coreos.sh
Install docker compose on coreos
sudo su -
compose_version=1.11.1
mkdir -p /opt/bin
echo "Installing compose $compose_version"
curl -L https://github.com/docker/compose/releases/download/$compose_version/docker-compose-`uname -s`-`uname -m` > /opt/bin/docker-compose
chmod +x /opt/bin/docker-compose
echo "Done"