Skip to content

Instantly share code, notes, and snippets.

View gertd's full-sized avatar

Gert Drapers gertd

View GitHub Profile
@gertd
gertd / proxy-fix.sh
Last active September 24, 2016 22:31
Fix proxy DNS settings
#!/bin/bash
sudo apt-get install jq --assume-yes
# get namespace
PROXY_NS=$(kubectl get pods --all-namespaces --show-all --output=json | jq -r '.items[] | select(.metadata.name | contains("hsc-proxy")) | .metadata.namespace ' )
# get pod name
PROXY_POD=$(kubectl get pods --all-namespaces --show-all --output=json | jq -r '.items[] | select(.metadata.name | contains("hsc-proxy")) | .metadata.name ' )
echo Current state of /etc/resolv.conf on $PROXY_NS/$PROXY_POD
#!/bin/bash
cat > ./internal-sc.json <<EOL
[
{
"protocol": "all",
"destination": "172.16.0.0/16"
}
]
@gertd
gertd / cleanup-jobpods.sh
Last active October 3, 2016 20:35
Cleanup pods created by jobs
#!/bin/bash
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' jq|grep "install ok installed")
if [ "" == "$PKG_OK" ]; then
sudo apt-get --force-yes --yes install jq
fi
kubectl get pods --all-namespaces --show-all --output=json |\
jq -r '.items[] | select(.metadata.labels.rmJobType == "preflight") | select(.status.phase == "Failed") | .metadata.namespace, .metadata.name ' |\
xargs -n2 > pods.txt
# 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,
@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 / 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 / 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 / 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
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 / 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