Skip to content

Instantly share code, notes, and snippets.

View brandond's full-sized avatar

Brad Davidson brandond

View GitHub Profile
@brandond
brandond / mirror-image.sh
Last active May 11, 2021 14:44
Ignorant hack of a script to mirror multiarch images on Docker Hub. Requires docker and jq.
#!/bin/bash
FLAGS=""
SOURCE="docker.io/library"
DEST="docker.io/brandond"
IMAGE="busybox"
TAG="1.32.0-uclibc"
docker buildx imagetools inspect ${SOURCE}/${IMAGE}:${TAG} --raw | \
jq -r '.manifests[] | (.digest + " " + .platform.architecture)' | \
@brandond
brandond / k3s-kk.sh
Last active January 20, 2022 20:40
Various scripts for doing K3s/RKE2 release stuff
#!/bin/bash
# This script assumes a couple things:
# * you have a copy of kubernetes/kubernetes checked out to $GOPATH/src/github.com/kubernetes/kubernetes
# * you have a copy of k3s-io/k3s checked out to $GOPATH/src/github.com/k3s-io/k3s
# * the repos listed above have an origin named ${USER} (your login) that points to your personal fork of that repo
# * the repos listed above have an origin named k3s-io that points to the k3s-io fork of that repo
# * the kubernetes repo has an origin that points at the kubernetes upstream (doesn't matter what it's called)
set -euxo pipefail
@brandond
brandond / menlo.py
Last active December 16, 2020 16:10
Sample Menlo Security logging API client
#!/usr/bin/env python
import logging
import requests
import click
import itertools
from dateutil.parser import isoparse
from datetime import datetime, timezone
from time import time
@brandond
brandond / panel.h
Last active January 14, 2020 07:52
ESPHome Addressable Light Groups
#include "esphome/core/component.h"
#include "esphome/components/light/addressable_light.h"
namespace esphome {
namespace panel {
static const char *TAG = "panel.light";
class AddressablePanel;
class PanelLightOutput;
@brandond
brandond / fastblink bootstrap success.txt
Created February 5, 2019 10:29
Neo Coolcam PIR sensor reverse-engineering
@brandond
brandond / fixtures.yaml.j2
Created February 1, 2019 20:37
esphomeyaml templates
esphomeyaml:
name: fixture{{ID}}
platform: ESP8266
board: esp01_1m
arduino_version: 2.4.2
esphomelib_version: dev
board_flash_mode: dout
build_path: esp8266
on_boot:
if:
@brandond
brandond / kinesis-s3-splunk-gzip.py
Last active March 10, 2018 00:11
Proof-of-concept CLI tool to ingest CloudWatch Logs data archived via Kinesis Firehose from S3 into Splunk via the HTTP Event Collector
from __future__ import print_function, division
import gzip
import io
import logging
import sys
import tempfile
import zlib
import boto3
import click
@brandond
brandond / function.py
Last active February 6, 2023 21:09
Python script to auto-tag AWS EBS Snapshots and Volumes using AMI and Instance tags
import copy
import logging
import os
import boto3
logging.basicConfig(level=os.environ.get('LOG_LEVEL', 'INFO'))
ec2 = boto3.client('ec2')
logger = logging.getLogger(__name__)
@brandond
brandond / sslscan.py
Created March 25, 2017 09:02
Stupid simple Python SSL certificate chain scanner
#!/usr/bin/env python
from __future__ import print_function
import sys
import socket
import requests
import datetime
from OpenSSL import SSL, crypto
@brandond
brandond / squid
Last active September 18, 2019 18:14 — forked from hrchu/gist:0cc5e783387f5453f528
logstash-grok-pattern-squid
# Follows the squid format in default:
# logformat squid %ts.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt
# http://www.squid-cache.org/Doc/config/logformat/
SQUID4 %{NUMBER:timestamp:float}\s+%{NUMBER:response_time:int} %{IPORHOST:src_ip} %{NOTSPACE:squid_request_status}/%{NUMBER:http_status_code:int} %{NUMBER:transfer_size:int} %{NOTSPACE:http_method} (%{URIPROTO:url_scheme}://)?(?<url_host>\S+?)(:%{INT:url_port})?(/%{NOTSPACE:url_path})?\s+%{NOTSPACE:client_identity}\s+%{NOTSPACE:peer_code}/%{NOTSPACE:peerhost}\s+%{NOTSPACE:content_type}