This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
brew list | xargs brew reinstall |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
brew services list | grep started | cut -f 1 -d ' ' | xargs -n 1 brew services restart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {collectDefaultMetrics, register} from 'prom-client'; | |
collectDefaultMetrics({ register }); | |
export async function GET() { | |
const metrics : string = await register.metrics(); | |
return new Response(metrics, { | |
status: 200, | |
headers: { | |
"Content-Type": register.contentType, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openssl s_client -showcerts -connect SERVER_NAME:443 -showcerts </dev/null 2>/dev/null|openssl x509 -outform PEM >mycertfile.pem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
brew upgrade | tee /tmp/brew.log | |
cat /tmp/brew.log | grep "brew services restart" | xargs -n 4 -L 1 -I {} sh -c "{}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
kubectl label --overwrite ns --all pod-security.kubernetes.io/audit=baseline pod-security.kubernetes.io/warn=baseline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# remove kubernetes CRDs matching a certain string | |
# | |
for crd in `k get crds -oname | grep PUT_FRAGMENT_HERE | awk -F / '{print $2}'`; do kubectl delete crd $crd; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class PropertyChecker | |
{ | |
// usage: PropertyChecker.CheckInitOnly(() => foo.Bar); | |
public static void CheckInitOnly(Expression<Func<object>> expression, bool allowEmptyStrings = false) | |
{ | |
if (expression.Body is not UnaryExpression { Operand: MemberExpression memberExpression }) | |
{ | |
if (expression.Body is not MemberExpression tmp) | |
{ | |
throw new InvalidOperationException($"Expected a {nameof(MemberExpression)}."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ObjectExtensions | |
{ | |
public static IDictionary<string, object> AnonymousTypeToExpando( this object obj ) | |
{ | |
IDictionary<string, object> retVal = new ExpandoObject( ); | |
if ( obj != null ) | |
{ | |
foreach ( PropertyDescriptor prop in TypeDescriptor.GetProperties( obj.GetType( ) ) ) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Make a copy of your existing config | |
cp ~/.kube/config ~/.kube/config.bak | |
# Merge the two config files together into a new config file | |
KUBECONFIG=~/.kube/config:/path/to/new/config kubectl config view --flatten > /tmp/config | |
# TEST |