Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Bateman taxilian

View GitHub Profile
@taxilian
taxilian / backup_cluster.sh
Created Sep 8, 2021
Bash script to export all kubernetes resources as YAML files in a directory structure
View backup_cluster.sh
#!/bin/bash
allCRDs=$(kubectl get crd -o name | cut -d '/' -f 2)
nsCRD=""
clusterCRD=""
for crd in $allCRDs; do
scope=$(kubectl describe crd $crd | grep "Scope" | cut -d ':' -f 2 | sed 's/^ *//g')
if [ "$scope" == "Namespaced" ]; then
@taxilian
taxilian / testCall.sh
Created Aug 4, 2021
Tool for testing how often a command succeeds
View testCall.sh
#!/bin/bash
CMD="$@"
declare -i COUNT
declare -i SUCCESS
SUCCESS=0
COUNT=0
for i in {1..100}; do
@taxilian
taxilian / ExampleSourceComponent.vue
Last active Jul 9, 2021
Dialog abstraction example
View ExampleSourceComponent.vue
<script lang="ts">
import {showDialog} from './dialogMgr';
@Component()
export default class MyOtherComponent extends Vue {
markdown = '(some loaded markdown here)';
async openDialog() {
@taxilian
taxilian / app.ts
Last active Apr 7, 2021
My attempt at implementing a node.js server with kubernetes best practices for closing gracefully
View app.ts
const dbConnections: Array<MongoClient> = [];
export type startupMiddleware = ReturnType<typeof initMiddleware>;
let failCase: Error;
export function setUnrecoverableError(err: Error) {
failCase = err;
console.warn(`Unrecoverable error set:`, err, err.stack);
}
@taxilian
taxilian / README.md
Created Mar 28, 2021
Bootstrapping a kubeadm cluster on ubuntu 20.04
View README.md
@taxilian
taxilian / arrlVeList.ts
Last active Mar 14, 2021
Get ARRL ve lists for each state
View arrlVeList.ts
// Originally written by Jason Sweeney, refactored by Richard Bateman
// 2021
import axios from "axios";
import cheerio from "cheerio";
const stateListUrl = "http://www.arrl.org/ve-session-counts";
const stateUrl = "http://www.arrl.org/ve-session-counts?state=";
type PromisedReturnType<T extends (...args: any) => any> = T extends (...args: any) => Promise<infer R> ? R : ReturnType<T>;
@taxilian
taxilian / README.md
Created Jan 4, 2021
macOS set up yubico-piv-tool
View README.md

Why?

Homebrew build doesn't work -- dunno why. I should figure out why and fix it then submit a PR, but I'm lazy.

Prep

brew install cmake libtool pkg-config check gengetopt help2man pcsc-lite openssl
@taxilian
taxilian / .zshrc
Last active Jul 19, 2021
Easily switch between different SSH agents on mac, probably easy to adapt to any linux
View .zshrc
function showAgent() {
echo The current SSH agent is $(readlink ~/.ssh-agent-link)
}
function updateSshAgentSock() {
NEWSOCK=$2
if [ -z "$NEWSOCK" ]; then
echo -n "No socket found for ${1}; not changing agents. "
return 1
elif [ ! -S "$NEWSOCK" ]; then
@taxilian
taxilian / compress.yaml
Last active Sep 16, 2020
Traefik kubernetes configuration that I use
View compress.yaml
# Enable gzip compression
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: gzip-compress
spec:
compress: {}
@taxilian
taxilian / common.ts
Created Sep 14, 2020
Example typescript pattern for defining a view using 'mongoose-decorators-ts'
View common.ts
export const readOnlyExcludeKeysModel = <const>[
'watch', 'bulkWrite', 'create', 'createCollection',
'syncIndexes', 'listIndexes', 'ensureIndexes',
'createIndexes', 'findByIdAndRemove', 'findByIdAndDelete',
'findByIdAndUpdate', 'findOneAndRemove', 'findOneAndDelete',
'findOneAndUpdate', 'insertMany', 'remove', 'deleteOne',
'deleteMany', 'replaceOne', 'update', 'updateMany', 'updateOne',
];
export type readOnlyExcludeKeysModel = typeof readOnlyExcludeKeysModel[number];
export const readOnlyExcludeKeysDoc = <const>[