Skip to content

Instantly share code, notes, and snippets.

View brianonn's full-sized avatar

Brian Onn brianonn

  • Vancouver, Canada
View GitHub Profile
@brianonn
brianonn / AuthyToOtherAuthenticator.md
Last active January 9, 2024 23:03 — forked from gboudreau/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy

Generating Authy passwords on other authenticators


*update: This might affect how easy it is to use this technique past August 2024: https://www.theverge.com/2024/1/8/24030477/authy-desktop-app-shutting-down


There is an increasing count of applications which use Authy for two-factor authentication. However many users who aren't using Authy, have their own authenticator setup up already and do not wish to use two applications for generating passwords.

Since I use 1Password for all of my password storing/generating needs, I was looking for a solution to use Authy passwords on that. I couldn't find any completely working solutions, however I stumbled upon a gist by Brian Hartvigsen. His post had a neat code with it to generate QR codes for you to use on your favorite authenticator.

@brianonn
brianonn / enable_aspm.sh
Created December 30, 2023 02:38
Enable ASPM on pcie devices if the BIOS did not turn it on
#!/bin/bash
# Copyright (c) 2010 Luis R. Rodriguez <mcgrof@gmail.com>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@brianonn
brianonn / xmonad.hs
Created October 6, 2023 04:51
A sample xmonad config file that has layouts for borderless fullscreen mode -- Use this for a reference for my own xmonad
------------------------------------------------------------------------
-- import
------------------------------------------------------------------------
--
-- from Stackoverflow https://unix.stackexchange.com/a/698139
--
import XMonad hiding ( (|||) ) -- jump to layout
import XMonad.Config.Desktop
import qualified XMonad.StackSet as W
import System.Exit
@brianonn
brianonn / main.tf
Created March 12, 2023 10:48
main.tf for use with localstack running on localhost port
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.27"
}
}
required_version = "~> 1.0"
}
@brianonn
brianonn / aws-describe-instances.sh
Created March 12, 2023 10:43
describe instances in AWS with a nice table output
#!/bin/sh
## -----------------------------------------------------------------------
## | DescribeInstances |
## +-----------------+-----------------------+-------------+-------------+
## | IP Address | Instance ID | Name | State |
## +-----------------+-----------------------+-------------+-------------+
## | 10.66.122.61 | i-e947af0a891355efc | Server 002 | terminated |
## | 10.163.29.52 | i-828f336627c36ba76 | Server 001 | terminated |
## | 10.222.236.205 | i-60cef875d3e88c7a5 | Server 001 | terminated |
@brianonn
brianonn / nsenter-node.sh
Created January 18, 2023 09:30
get a shell on a kubernetes node using just the nodename
#!/bin/sh
set -x
node=${1}
nodeName=$(kubectl get node ${node} -o template --template='{{index .metadata.labels "kubernetes.io/hostname"}}')
nodeSelector='"nodeSelector": { "kubernetes.io/hostname": "'${nodeName:?}'" },'
podName=${USER}-nsenter-${node}
kubectl run ${podName:?} --restart=Never -it --rm --image overriden --overrides '
{
@brianonn
brianonn / README.md
Last active December 24, 2022 14:18
for telmate/proxmox provider: extract host IPs from terraform.tfstate file after hosts are created

Extract hosts inventory file for Ansible

This script is intended to be used with the Telmate terraform provider for Proxmox

Requirements

  • Telmate terraform provider installed via terraform init
  • must use tags = "server" or tags = "worker" when defining server and worker VM's in the terraform provider
  • have a successfull terraform apply that created the terraform.tfstate file
  • Ansible installed
  • jq installed
@brianonn
brianonn / prepare-ubuntu-template.sh
Last active December 26, 2022 07:38
cleanup a standard ubuntu server install for making a cloud-init template (i.e. for VM creation template, proxmox, vmsphere, etc)
#!/bin/bash
###########################################
#
# 1) install a standard ubuntu server from the server image
# 2) during server installation you will have to create a user, so create a throwaway user, ie 'tmpinstall'
# 3) login to that throwaway user 'tmpinstall' after the server is up
# 4) install any additional packages and even any special users that you want to always
# be there in your base image template
# 5) when finished, become a clean root shell for the next steps:
@brianonn
brianonn / create-kubernetes-cluster.sh
Created July 8, 2022 00:56
stand up a kubernetes cluster on a host - shell or yaml for ansible - from
#!/bin/bash
# originally from: https://github.com/kubernetes/kubernetes/issues/106464#issuecomment-1142563656
# edited by Brian Onn https://github.com/brianonn
# see also
# https://kubernetes.io/docs/setup/production-environment/container-runtimes/#containerd-systemd
# works on debian 10, maybe 11 ? maybe 9 ?
@brianonn
brianonn / aesgcm.py
Created May 26, 2022 01:11
AESGCM in python
# from https://stackoverflow.com/a/59835994
# also see: https://soatok.blog/2020/05/13/why-aes-gcm-sucks/
import secrets
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
# Generate a random secret key (AES256 needs 32 bytes)
key = secrets.token_bytes(32)
# Encrypt a message