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!");
@gjonespf
gjonespf / ReportingServicesWebKitFix.js
Created September 27, 2018 23:14
ReportingServicesWebKitFix
// RS relies on some buggy IE functionality - that overflow should be visible by default (which is not standard)
// So Webkit based browsers don't show the report correctly as they hide overflow by default
// We need to set overflow visible for the report div
var deadman=60;
function makeReportVisible() {
if (typeof($) !== "undefined") {
var div = $('table[id*=_fixedTable] > tbody > tr:last > td:last > div')
if(div) {
div.css('overflow', 'visible');
@gjonespf
gjonespf / hyperv.ps1
Created September 21, 2018 05:22
Query HyperV Hosts for disk space
function Get-HyperVServersInDomain {
[cmdletbinding()]
param(
)
try {
Import-Module ActiveDirectory -ErrorAction Stop
}
catch {
Write-Warning "Failed to import Active Directory module. Exiting"
return
# 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 / docker-compose.yml
Last active December 14, 2017 01:39
Simple Stack
version: "3.2"
# docker stack deploy --compose-file docker-compose.yml build
services:
my-test-server:
image: nginx
ports:
- "80"
volumes:
- my-test-store-s3:/usr/share/nginx/html/s3:ro
networks: