Skip to content

Instantly share code, notes, and snippets.

View tedivm's full-sized avatar

Robert Hafner tedivm

View GitHub Profile
@tedivm
tedivm / github_backup.sh
Last active November 24, 2024 05:19
Github Backups
#!/usr/bin/env bash
ORGANIZATIONS="tedivm tedious multi-py TerraformInDepth GitConsensus"
BACKUP_DIR="/storage-pool/github"
FLAGS="--source --no-archived"
GITHUB_PREFIX="https://github.com/"
# GITHUB_PREFIX="[email protected]:"
function repo_list() {
@tedivm
tedivm / module_version.tf
Created April 23, 2024 19:16
Terraform Module Version from Inside Module
locals {
# Load the module versions from the modules.json file.
module_versions = jsondecode(file("${path.root}/.terraform/modules/modules.json"))
# Convert the module versions data into an object,
# with the module source path as key and version as value.
modules_by_source = { for module in local.module_versions :
module["Source"] => try(module["Version"], null)
}
@tedivm
tedivm / makefile
Created April 11, 2024 21:00
Rob's Mermaid and Dot Diagrams Makefile
# Configuration
MAKEFLAGS += -j8
DOT_OPTIONS:=-Nfontname=arial -Efontname=arial -Gfontname=arial
MMD_OPTIONS:=-w 2000 -b transparent --cssFile ./mermaid_png.css --configFile ./mermaid_config.json
# Get all diagram files
MERMAID_FILES:=$(shell find . -name "*.mmd" -type f -not -path '*/build/*')
DOT_FILES:=$(shell find . -name "*.dot" -type f -not -path '*/build/*')
# Files that should be generated
@tedivm
tedivm / robs_dimmer_blueprint.yaml
Created October 16, 2023 02:50
Home Assistant Dimmer Switch Blueprint
blueprint:
domain: automation
name: Rob's Dimmer Blueprint
description: Dimmer Controls
input:
controller_entity:
name: Philips Hue v2 Smart Dimmer Switch and Remote
description: The action sensor of the dimmer to use for the automation.
selector:
entity:
@tedivm
tedivm / plan.json
Created April 13, 2022 20:22
Terraform Plan Example
{
"format_version": "1.0",
"terraform_version": "1.1.7",
"planned_values": {
"root_module": {
"resources": [
{
"address": "random_integer.network",
"mode": "managed",
"type": "random_integer",
Twitter ID Screen name Followers Removal observed Before After
17461978 SHAQ 15612791 2022-02-26T22:24:52Z SHAQ.ETH SHAQ.SOL
21910850 jakeowen 2119904 2022-02-26T15:45:18Z jakeowen.eth Jake Owen
7846 ijustine 1811449 2022-03-09T14:43:37Z iJustine.eth iJustineUltra
1666038950 BoredElonMusk 1752290 2022-02-17T08:05:47Z bored.eth Bored
381051960 ethRuby 1267133 2022-03-19T08:08:11Z CryptoSolis.eth Ruby
1282418324228337665 wsbmod 832406 2022-02-24T06:52:07Z wsbmod.eth wsbmod
20882981 EclecticMethod 495235 2022-02-18T04:39:30Z eclecticm.eth Eclectic Method
811350 alexisohanian 479340 2022-02-08T06:31:55Z AlexisOhanian.eth 7️⃣7️⃣6️⃣ Alexis Ohanian 7️⃣7️⃣6️⃣
22784458 Fwiz 410813 2022-03-22T08:54:42Z Ryan Wyatt - fwiz.eth 💜 Ryan Wyatt - @ GDC
@tedivm
tedivm / queuerunner.py
Created February 15, 2022 16:46
Rob's QueueRunner
import logging
import multiprocessing as mp
import signal
import time
from queue import Empty, Full
from typing import Callable
import psutil
from pydantic import BaseSettings
@tedivm
tedivm / convert.sh
Last active January 12, 2022 14:56
Github Private to Internal
#!/usr/bin/env bash
# The "Internal" visibility is still in preview in the API.
# We cannot filter private and internal, so this script will
# convert internal to internal.
CONVERT_TO="internal"
if [[ -z "$1" ]]; then
echo "Organization required"
exit 1
@tedivm
tedivm / authorized_keys_command.sh
Created November 12, 2021 23:10
OpenSSH Authorized Keys Command
#!/usr/bin/env bash
# Explicit "allow" list in case Github users overlap with system users
ALLOWED_USERS="tedivm"
KEY_URL="https://github.com/${1}.keys"
if [[ -z $1 ]]; then
>&2 echo "Username required."
exit 1
fi
@tedivm
tedivm / aws_login.yml
Last active June 9, 2024 02:42
AWS ECR Github Actions OIDC
jobs:
deploy:
name: Push to ECR
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read