Skip to content

Instantly share code, notes, and snippets.

View taxilian's full-sized avatar

Richard Bateman taxilian

View GitHub Profile
@taxilian
taxilian / README.md
Created November 9, 2019 22:13
Mongodb scripts for incremental backup

Introduction

I can't take credit for much of the work here -- I adapted it from this blog post: https://tech.willhaben.at/mongodb-incremental-backups-dff4c8f54d58

My main contribution was to make it a little easier to use with docker as well as numerous little cleanup tasks. I also made it gzip the oplog backups and added support for SSL connections

Note that I havne't yet tested the point in time restore script; it likely needs work, particularly to make things work with the gzipped oplog files

@taxilian
taxilian / .gitconfig
Created November 3, 2011 23:57
my aliases from my .gitconfig
[alias]
unadd = reset HEAD
#co = checkout
co = "!f(){ git checkout \"$@\" && git submodule update --init --recursive; }; f"
cp = cherry-pick
st = status
stat = status
br = branch
info = "!sh -c '[ $# -ne 0 ] && git remote show $1 && exit 0 || [ $# = 0 ] && git remote show origin && exit 0' -"
track = "!sh -c '[ $# = 2 ] && git branch --track \"$1\" \"$2\" && exit 0 || [ $# = 1 ] && git branch --track \"$1\" origin/\"$1\" && exit 0 || echo \"usage: git track <branch> [remote_branch]\\n\\nIf remote branch is not specified, the default is to use origin/<branch>\" && exit 1' -"
@taxilian
taxilian / README.md
Last active January 18, 2024 17:42
OPNSense: Scripts to run as a cron job to enable or disable wireguard based on the CARP status

DEPRECATED

This is no longer needed; OPNSense now has full CARP support in the wireguard plugin which works much better than these hacks ever did =] I'll leave it here as an example of a thing you can do and 'cause why delete it?

Installation

  • Install checkWireguard as /usr/local/opnsense/scripts/OPNsense/Wireguard/checkWireguard
  • Install actions_wireguardCarp.conf as /usr/local/opnsense/service/conf/actions.d/actions_wireguardCarp.conf
  • run service configd restart
@taxilian
taxilian / extractCert.sh
Last active January 9, 2024 19:41
Helper to extract TLS certificates from a kubernetes TLS secret and write them to files, handy for client authentication certs
#!/bin/bash
TMPFILE=$(mktemp)
function cleanup {
echo "Deleting $TMPFILE..."
rm -rv "$TMPFILE"
}
trap cleanup EXIT
function usage {
@taxilian
taxilian / README.md
Last active August 23, 2023 20:20
kubernetes: Brute-force changing the podCIDR directly in etcd / update cluster CIDR

Disclaimer

This seems to have worked for me, but might not work for you!

Before you try this make sure you've updated everything so that the only things referencing your old CIDR range are the node objects. I did this using calico by creating new ippools. I don't know what issues you may hit -- I avoided most of them by BGP peering with my router and doing all interesting stuff there.

Source

@taxilian
taxilian / README.md
Last active March 21, 2023 16:19
This is my working kubernetes sentry configuration using the helm chart

Example configuration for a working sentry config on kubernetes bare metal

Special thanks to Kanadaj from the #self-hosted channel on the sentry discord who helped me with a lot of the servers I hadn't used before

Caveats

This is customized in a number of ways, so you'll probably want/need to change things, but it's working for me and I just set it up from scratch again, so I thought I'd share.

@taxilian
taxilian / emailvalidation.ts
Last active February 27, 2023 23:30
Tool that I use to verify email addresses
import emailaddr from 'email-addresses';
import disposable_domains from 'disposable-email-domains';
import dns from 'dns';
import { promisify } from 'util';
let resolveMx = promisify(dns.resolveMx);
let resolve4 = promisify(dns.resolve4);
let resolve6 = promisify(dns.resolve6);
function reverseLookup(ip: string) {
return new Promise<string[]>((resolve, reject) => {
@taxilian
taxilian / USBNotify.cpp
Created December 16, 2011 18:24
Example of receiving WM_DEVICECHANGE in a plugin
#include <set>
#include "USBNotify.h"
USBNotify::USBNotify()
{
}
USBNotify::~USBNotify()
{
<template>
<v-card>
<v-card-title>
<slot name="title">
<span class="headline" v-text="dialogTitle"></span>
</slot>
</v-card-title>
<v-card-subtitle>
<slot name="subtitle">
@taxilian
taxilian / check_k8s_certs.sh
Last active February 10, 2023 17:30
Check kubernetes certificate expiration
#!/bin/bash
CONTEXT=$1
ALLCERTS=$(kubectl --context $CONTEXT get secret --field-selector type=kubernetes.io/tls -A | tail +2 | awk '{print $1 ":" $2}')
TODAY=$(date +%s)
COL1=30
COL2=10
COL3=15