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 | |
# checkout-pull-prune.sh | |
branchName=$(git remote show origin | sed -n '/HEAD branch/s/.*: //p') | |
git fetch origin "$branchName:$branchName" | |
git merge "$branchName" |
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 | |
script -q -c "git --no-pager log --decorate --graph --format='%C(auto,#aa5500) %h %C(auto,#55ff55) (%an %GK %G?) %Creset %s %cr %C(auto,#ffff55) %d' --date=relative --all --remotes=* -n 100" ../graph.txt && \ | |
ansi2html < ../graph.txt > ../graph.html |
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
using System; | |
using System.Reflection.Emit; | |
using System.Reflection; | |
internal static class TypeMaker | |
{ | |
private const string AssemblyNameForType = "DynamicAssemblyExample"; | |
public static Type? Make(string typeName) | |
{ |
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 | |
# NB the result will need cleaned | |
# ADVICE run this from another directory and edit the pathing | |
git ls-files --others --exclude-standard --directory ./YOUR/PATH > .gitignore |
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 |
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
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
#! /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
#! /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
#! /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 "{}" |