Skip to content

Instantly share code, notes, and snippets.

import "sockaddr"
import "strings"
# todo - need to change logic to not `return false` on any hit of non-matching cidr
# as if multiple CIDRs here it will fail Sentinel rule any non-matching
allowed_cidrs = ["192.168.1.1/24","10.10.10.10/30"]
# First IP 192.168.1.0
# Last IP 192.168.1.255
# First IP 10.10.10.8
# Last IP 10.10.10.11
# this goes with https://gist.github.com/mikegreen/8a0860901c57e3b02277c82561754a1c
import RPi.GPIO as gpio
import smbus
import time
import sys
import struct
from datetime import datetime
bus = smbus.SMBus(1)
# this goes with https://gist.github.com/mikegreen/74d98e87224508c242eac10d024426b9
# cat dht22_test.py
import time
import adafruit_dht
import board
from datetime import datetime
# Initial the dht device, with data pin connected to:
dhtDevice = adafruit_dht.DHT22(board.D17)
#include <Wire.h>
#define SLAVE_ADDRESS 0x04
#define LED 6
int number = 0;
// Pin that input voltage and resistors are connected
// doc here resistor setup
int inputPin = A0 ;
@mikegreen
mikegreen / packets.sh
Created June 24, 2020 22:41
packets per second
#!/bin/bash
time="1" # one second
int="ens3" # network interface
while true
do
txpkts_old="`cat /sys/class/net/$int/statistics/tx_packets`" # sent packets
rxpkts_old="`cat /sys/class/net/$int/statistics/rx_packets`" # recv packets
sleep $time
@mikegreen
mikegreen / vault_raft_bu_restore_example.sh
Last active February 16, 2021 15:25
Vault raft snapshot backup and restore quick demo
# 2020-06-23
# this shows creating a Vault instance running integrated storage/raft,
# then adding a KV and taking a snapshot
# then kill the raft DB files to simulate a storage failure
# repeat new Vault instance, restore snapshot, unseal and auth with orig keys
# and read some data to show how backup/restore works
# not meant to be a live script to run!
# this uses the vault_config.hcl from https://gist.github.com/mikegreen/c2df5eea2283f0dbc5f3a5d3650536fd
@mikegreen
mikegreen / vault_config.hcl
Last active June 23, 2020 19:45
Raft sample config
# vault_config.hcl
# to start: $ vault server -config=vault_raft.hcl
ui=true
disable_mlock = true
storage "raft" {
path = "/opt/vault/"
node_id = "raft_01"
}
listener "tcp" {
address = "127.0.0.1:8200"
#!/bin/bash
#Count TFE Metrics
#Requires TFE_TOKEN environment variable to be set to site admin api token
#Check for TFE_TOKEN
if [ -n "$TFE_TOKEN" ]; then
echo "----------------------------------"
echo "TFE Token detected!"
echo "----------------------------------"
else
@mikegreen
mikegreen / raft_migration.sh
Created May 13, 2020 15:05
Test Consul Vault to Raft/Integrated Storage Vault
#!/bin/bash
# this was shared by Nick on the Vault gg, all credit to him
# https://groups.google.com/d/msg/vault-tool/hmejXvIFuOU/M3bKDKFBBwAJ
# Test Vault migration from consul to raft.
# Dependencies: vault, consul, nc (netcat)
# Writes to (and blows away) ~/migrate_consul_to_raft.
# Kills any running vault or consul processes.
# Tested on MacOS and Linux.
gpg --keyserver pool.sks-keyservers.net --recv-key 1285491434D8786F
gpg -a --export 1285491434D8786F | sudo apt-key add -
echo 'deb http://linux.dell.com/repo/community/openmanage/932/bionic bionic main' | sudo tee -a /etc/apt/sources.list.d/linux.dell.com.sources.list
apt-get update