Skip to content

Instantly share code, notes, and snippets.


Richard Bateman taxilian

View GitHub Profile
View consumer.schema.json
"type": "object",
"title": "Consumer",
"properties": {
"_id": {
"bsonType": "objectId",
"tsType": "ObjectId"
"uniqueSlug": { "type": "string" },
"name": { "type": "string" },
taxilian / stringTpl.ts
Created Aug 2, 2022
Typescript string template literal function creator
View stringTpl.ts
* Use this with a template literal in order to create reusable string template;
* use interpolation to add strings for each variable you want to use in the template.
* e.g.:
* const reUsableStringTemplate = stringTpl`${'name'} and ${'otherName'} are going to ${'place'}`;
* You can then call it with:
taxilian / MongoProxy_CollectionConfig.ts
Last active Aug 1, 2022
Tool to watch for .schema.json files and compile them as mongodb interfaces using json-schema-to-typescript, also proxy wrapper to use this for creating doc/model thingies
View MongoProxy_CollectionConfig.ts
// Collection wrapper, used as an easy way to configure things and a place to put simple helpers,
// also the basis for making a "Model" object
import * as mongodb from 'mongodb';
import { JSONSchema4 } from 'json-schema';
import camelCase from 'lodash/camelCase';
interface IndexSpecification {
[key: string]: mongodb.IndexDirection;
taxilian / config.ts
Created Feb 3, 2022
Env overrides for config
View config.ts
import _ from 'lodash';
function setEnvOverrides(cfg: Config) {
const foundVars = Object.keys(process.env).filter(name => name.startsWith(ENV_PREFIX));
for (const v of foundVars) {
const actualName = v.substr(ENV_PREFIX.length);
// console.log(`Processing ENV var ${actualName}`);
taxilian /
Created Sep 8, 2021
Bash script to export all kubernetes resources as YAML files in a directory structure
allCRDs=$(kubectl get crd -o name | cut -d '/' -f 2)
for crd in $allCRDs; do
scope=$(kubectl describe crd $crd | grep "Scope" | cut -d ':' -f 2 | sed 's/^ *//g')
if [ "$scope" == "Namespaced" ]; then
taxilian /
Created Aug 4, 2021
Tool for testing how often a command succeeds
declare -i COUNT
declare -i SUCCESS
for i in {1..100}; do
taxilian / ExampleSourceComponent.vue
Last active Jul 9, 2021
Dialog abstraction example
View ExampleSourceComponent.vue
<script lang="ts">
import {showDialog} from './dialogMgr';
export default class MyOtherComponent extends Vue {
markdown = '(some loaded markdown here)';
async openDialog() {
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 /
Created Mar 28, 2021
Bootstrapping a kubeadm cluster on ubuntu 20.04
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 = "";
const stateUrl = "";
type PromisedReturnType<T extends (...args: any) => any> = T extends (...args: any) => Promise<infer R> ? R : ReturnType<T>;