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 5, 2024 03:17
A relatively simple way to handle impersonating a customer in vendure

Assumptions

This assumes that you're using standard auth strategies, you have set a cookie secret, and you're using a separate cookie for store and admin APIs, e.g.

  authOptions: {
    tokenMethod: ['cookie'],
    cookieOptions: {
      name: { shop: 'vendshop', admin: 'vendadmin' },
 secret: 'somethingthatIwillnevertellyouandyouwillneverguessthisisntitipromisenoreally',
@taxilian
taxilian / check_kubeconfig.sh
Created September 24, 2024 20:39
Bash script to check the certificate expirations in your kubeconfig file
#!/bin/bash
# Function to extract and decode certificate
extract_cert() {
echo "$1" | base64 -d 2>/dev/null | openssl x509 -noout -enddate 2>/dev/null | cut -d= -f2
}
# Function to calculate days until expiry
days_until_expiry() {
local expiry_date="$1"
@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 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 / 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 / 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) => {
<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
@taxilian
taxilian / emailService-EmailService.ts
Last active November 1, 2022 22:17
Example service using the abstraction I'm working on, - in filename shows directories
import { sendEmailTemplate, EmailDomains as ValidDomains } from '@/lib/email/mailer';
import { remoteMethod } from '@/lib/nats/types';
// NATS-capable email service
class EmailService {
@remoteMethod({
timeout: 10000,
})
async sendEmail(domain: string, tplName: string, data: any, options: any) {
@taxilian
taxilian / README.md
Last active July 25, 2024 07:36
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