Skip to content

Instantly share code, notes, and snippets.

@metahertz
metahertz / gist:c982c86cf6c8fa5e7ccf5b4186e3e07c
Created September 3, 2024 13:20
ESPHome UK Single Phase emporia-vue-local config
# Working (at a glance) configuration for use with https://github.com/emporia-vue-local/esphome
# Emporia Vue Rev2 hardware after flashing with ESPHome following instructions in the link above.
# Ports without a CT clamp will report random values, all ports are active in this config but only 1-7
# (and the total Phase1) are exported to home assistant (see lines at the very bottom)
# RETURN phase1 power to grid also reported.
# All Phase2 and Phase3 (B and C) references removed.
esphome:
name: emporiav2-1
friendly_name: emporiav2-1
@metahertz
metahertz / backup-boot.sh
Created August 1, 2023 13:32
Backup linux boot-related items.
#!/usr/bin/env bash
## Export variables for the various commands
## find BOOT_DISK, BOOT_PART and EFI_PART with the following commands:
### blkid | grep vfat
### There will likley be one disk only listed, with one or two partitions. This is your BOOT_DISK (example, /dev/sda or /dev/nvme0n1)
export BOOT_DISK=CHANGEME
### sudo fdisk ${BOOT_DISK} print
@metahertz
metahertz / aws-cloud9-ssh.py
Created June 9, 2022 12:17
AWS Cloud9 SSH Automation
## API Creation of AWS Cloud9 "SSH" instances.
## Matt Johnson <[email protected]>
### SSH Instances allow Cloud9 to be run ontop of existing systems, rather than a cloud9-managed EC2 Instance.
### They are useful as Cloud9 does not allow pre-customization of a Cloud9-managed instance.
### The API is undocumented, allowing creation only via the AWS console. Hence this script.
import sys, os, datetime, json
import requests
from requests_aws4auth import AWS4Auth
from time import sleep
#!/usr/bin/env bash
# If no argument is given -> Downloads the most recently released
# kustomize binary to your current working directory.
# (e.g. 'install_kustomize.sh')
#
# If one argument is given ->
# If that argument is in the format of #.#.#, downloads the specified
# version of the kustomize binary to your current working directory.
# If that argument is something else, downloads the most recently released
@metahertz
metahertz / Checkov-v2-checks.md
Created March 29, 2021 14:07
Checkov V2 New Checks
Checkov Check ID Check Description (CKV_ checks are python, CKV2_ checks are graph/yaml)
CKV_AZURE_55 Ensure that Azure Defender is set to On for Servers
CKV_AZURE_61 Ensure that Azure Defender is set to On for App Service
CKV_AZURE_69 Ensure that Azure Defender is set to On for Azure SQL database servers
CKV_AZURE_79 Ensure that Azure Defender is set to On for SQL servers on machines
CKV_AZURE_84 Ensure that Azure Defender is set to On for Storage
CKV_AZURE_85 Ensure that Azure Defender is set to On for Kuber
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
gc = gspread.authorize(credentials)
# Open a worksheet from spreadsheet with one shot
wks = gc.open("sheetname").sheet1
@metahertz
metahertz / deploy-check-iam.yml
Created October 18, 2020 19:40
AirIAM drift detection with GH Actions
name: Deploy SLS with IAM change notifications
on:
push:
branches:
- master
jobs:
airiam-pre:
name: Generate current IAM terraform, pre-deploy.
runs-on: ubuntu-latest
steps:
@metahertz
metahertz / launch.json
Created August 28, 2020 16:52
Checkov VSCode debug launch.json
{
"version": "0.2.0",
"configurations": [
{"name":"Python: Checkov","type":"python","request":"launch","program":"${workspaceFolder}/checkov/main.py", "args": ["-f", "${workspaceFolder}/test.tf"], "console":"integratedTerminal", "env": {"PYTHONPATH": "${workspaceFolder}"}},
{"name":"Python: Remote Attach","type":"python","request":"attach","connect":{"host":"localhost","port":5678},"pathMappings":[{"localRoot":"${workspaceFolder}","remoteRoot":"."}]},
]
}
user_pref("browser.startup.homepage", "https://example.homepage.com");
user_pref("browser.startup.homepage", "https://developer.cisco.com");