Skip to content

Instantly share code, notes, and snippets.

View gertd's full-sized avatar

Gert Drapers gertd

View GitHub Profile
@gertd
gertd / auth.go
Created September 3, 2020 04:18 — forked from ogazitt/auth.go
Auth0 PKCE flow for a CLI built in golang
package auth
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
@gertd
gertd / git-pull
Last active August 9, 2019 01:22
git-pull - pull all repos in current directory helper script
#!/usr/bin/env bash
basedir=$PWD
for dir in $(find "$basedir" -mindepth 1 -maxdepth 4 -type d); do
[ -d "$dir/.git" ] && echo $dir && cd $dir && git pull && cd ..
done
@gertd
gertd / mssql-ctl
Last active January 10, 2020 03:58
MS SQL Server container helper script
#!/usr/bin/env bash
name="sql2017"
volume=sqlvolume
function initService {
if [ ! "$(docker ps -q -f name=$name)" ]; then
echo -n "SQL Server SA password: "
param (
[Parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[ValidateSet('Install', 'Uninstall', 'Start', 'Stop', 'Status', 'Info', 'Open', 'Deploy', 'Upgrade', 'Help')]
[String]$rootCmd
)
function Download-File{[CmdletBinding()]param($url, $targetFile, $proxy)
Write-Verbose "Downloading '${url}' to '${targetFile}'"
$uri = New-Object "System.Uri" "$url"
@gertd
gertd / IndexSize.sql
Created January 17, 2017 22:08
SQL Server Index Size
if object_id('dbo.IndexSize', 'FN') is not null
begin
drop function dbo.IndexSize
end
go
create function [dbo].[IndexSize](@object_id int)
returns float
as
begin
declare @PageSize float
@gertd
gertd / DataSize.sql
Last active January 17, 2017 22:01
SQL Server Get Datasize of Table
if object_id('dbo.DataSize', 'FN') is not null
begin
drop function dbo.DataSize
end
go
create function dbo.DataSize(@object_id int)
returns float
as
begin
declare @PageSize float
@gertd
gertd / GetQueueCount.sql
Created January 17, 2017 20:45
SQL Server Service Broker Queue Depth (number of rows enqueued)
create function dbo.GetQueueCount()
returns table
as
return
select q.name,
p.rows
from sys.objects as o
inner join sys.partitions as p
on p.object_id = o.object_id
inner join sys.objects as q
@gertd
gertd / FastCount.sql
Last active January 17, 2017 22:09
SQL Server Fast Row Count function
if object_id('dbo.FastCount', 'FN') is not null
begin
drop function dbo.FastCount
end
go
create function dbo.FastCount(@object_id int)
returns bigint
as
begin
declare @fastcount bigint = 0
# Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
#!/bin/bash
cat > ./internal-sc.json <<EOL
[
{
"protocol": "all",
"destination": "172.16.0.0/16"
}
]