Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View gavincampbell's full-sized avatar

Gavin Campbell gavincampbell

View GitHub Profile
@gavincampbell
gavincampbell / DispDev2019Notes.md
Last active October 10, 2019 14:39
Resources for talk on Disposable Development Environments from SQL Relay 2019
@gavincampbell
gavincampbell / WinRM-HTTPS.ps1
Created February 19, 2019 10:12 — forked from TechIsCool/WinRM-HTTPS.ps1
A simple Powershell WinRM-HTTPs setup
Write-Output "Disabling WinRM over HTTP..."
Disable-NetFirewallRule -Name "WINRM-HTTP-In-TCP"
Disable-NetFirewallRule -Name "WINRM-HTTP-In-TCP-PUBLIC"
Get-ChildItem WSMan:\Localhost\listener | Remove-Item -Recurse
Write-Output "Configuring WinRM for HTTPS..."
Set-Item -Path WSMan:\LocalHost\MaxTimeoutms -Value '1800000'
Set-Item -Path WSMan:\LocalHost\Shell\MaxMemoryPerShellMB -Value '1024'
Set-Item -Path WSMan:\LocalHost\Service\AllowUnencrypted -Value 'false'
Set-Item -Path WSMan:\LocalHost\Service\Auth\Basic -Value 'true'
@gavincampbell
gavincampbell / InstallHaProxy.sh
Last active November 23, 2018 11:15 — forked from jrouleau/InstallHaProxy.sh
Amazon Linux AMI Install HAProxy From Source (1.7.0 release pre configured). chmod +x InstallHaProxy.sh then ./InstallHaProxy.sh
#!/bin/bash
### VARIABLES ###
PRE_PACK="openssl-devel pcre-devel make gcc"
VER="1.8.14"
# Setup Colours
black='\E[30;40m'
red='\E[31;40m'
green='\E[32;40m'
@gavincampbell
gavincampbell / packer-iam-policy.json
Last active October 9, 2018 18:42
AWS policy for Packer including S3 access
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"ec2:AttachVolume",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:DeregisterImage",
@gavincampbell
gavincampbell / Jenkinsfile
Last active November 16, 2017 03:48
Branching in the Jenkinsfile
node{
checkout scm
def the_one_to_run
if (env.BRANCH_NAME == "master"){
the_one_to_run = load 'master.groovy'
}
else{
the_one_to_run = load 'not-master.groovy'
}
@gavincampbell
gavincampbell / DeleteSpecifiedResourceGroup.ps1
Created September 8, 2017 00:54
Azure Automation Runbook to parse a VSTS merge commit hook and delete the resource group corresponding to the source branch identified therein.
[CmdletBinding()]
param([object]$WebhookData)
if ($WebhookData){
$requestBody = (ConvertFrom-Json -InputObject $WebhookData.RequestBody)
$refspec = $requestBody.resource.SourceRefName
$branchName = $requestBody.resource.SourceRefName.Split("/")[-1]
@gavincampbell
gavincampbell / test insert image
Last active April 21, 2017 10:16
Insert an image with tsql
IF NOT EXISTS (SELECT * FROM testIMAGE where ID = 2)
BEGIN
INSERT INTO testIMage VALUES
(2,
0x89504E470D0A1A0A0000000D49484452000001480000014808060000003214673300000006624B474400FF00FF00FFA0BDA793000000097048597300000048000000480046C96B3E000038034944415478DAED9D779C5D55B9B09F5DCE39FBF439D36B32E93D19121242092D14814B0B28E5A2A05CAEE2FDB8D8BB5851E4AAD7AE572F227A45400101E98890400209E999F4C964D233BD9CDEF6F7C749A4972453CEDEFB7D7E3FFF904C3267AFBDD673DEB5D6BBDEA59BA66922088220BC095D9A4010044104290882208214044110410A822088200541104490822008224841100411A4200882085210044104290882208214044110410A822008224841100411A4200882085210044104290882208214044110410A822088200541104490822008224841100411A4200882085210044110410A822088200541104490822008224841100411A4200882085210044104290882208214044110410A82208820054110449082200882085210044104290882208214044110410A822088200541104490822008224841100411A4200882085210044104290882208214044110449023409E54324F3C6792CE9B28AFF913435308E92AB85578DD9FD88B64264B2A9B239DCD9248675194B77956D304452168B
node {
stage('git checkout'){
git 'file:///C:/Projects/Chinook.JenkinsDemo'
}
stage('Build Dacpac from SQLProj'){
bat "\"${tool name: 'Default', type: 'msbuild'}\" /p:Configuration=Release"
stash includes: 'Chinook.JenkinsDemo\\bin\\Release\\Chinook.JenkinsDemo.dacpac', name: 'theDacpac'
}
stage('Deploy Dacpac to SQL Server')
{
@gavincampbell
gavincampbell / CreateDateAzureSQLDW.sql
Last active November 7, 2016 23:02 — forked from mlongoria/CreateDateAzureSQLDW.sql
Creates a calendar table in Azure SQL Data Warehouse
--Creates a table called Dim.Calendar. Change the table name on line 69. Change date range on line 2.
DECLARE @StartDate DATE = '20000101', @NumberOfYears INT = 30;
-- prevent set or regional settings from interfering with
-- interpretation of dates / literals
CREATE TABLE #dimdate
(
[date] DATE,
[day] tinyint,
@gavincampbell
gavincampbell / oops.sql
Last active March 6, 2016 16:03
Transact-SQL script to drop all user-defined objects accidentally created in the SQL Server master database
DECLARE @dropStatements TABLE (dropStatement varchar(1000), dropOrder tinyint);
DECLARE @dropStatement varchar(1000);
INSERT INTO @dropStatements
select
CONCAT(
'DROP',' ',
typename,' ',
OBJECT_SCHEMA_NAME(object_id),
'.',
OBJECT_NAME(object_id),';'),