Skip to content

Instantly share code, notes, and snippets.

// LiquidCrystal_I2C.h: https://github.com/johnrickman/LiquidCrystal_I2C
#include <Wire.h> // Library for I2C communication
#include <LiquidCrystal_I2C.h> // Library for LCD using I2C Adapter
#include <Firmata.h>
// Wiring: SDA pin is connected to A4 and SCL pin to A5.
// Connect to LCD via I2C, default address 0x27 (A0-A2 not jumpered)
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2); // Change to (0x27,20,4) for 20x4 LCD.
int lastLine = 1;
@spensireli
spensireli / gist:e6046349a34ace803ff12c17a5f91516
Last active September 20, 2022 18:57
Quick-Route53-Backup
aws route53 list-resource-record-sets --hosted-zone-id "/hostedzone/ZXXXX" | jq -r '.ResourceRecordSets[] | [.Name,.TTL,.Type,(.ResourceRecords[]?|.Value),.AliasTarget.DNSName?] | @tsv' > output.tsv
@spensireli
spensireli / Cordon-All-Nodes.md
Created September 20, 2022 17:13
Handy Kubernetes Gists

Cordon all nodes.

for i in $(kubectl get nodes | grep ip |awk '{print $1}'); do kubectl cordon $i; done
@spensireli
spensireli / gist:a3d01bd8e8a7cd02fe5f51c81b324eea
Created December 16, 2022 15:42
CDK CloudFormation Output
self.output = CfnOutput(self, "Ec2DetailedMonitoringMitigationArn",
value=self.function.function_arn,
export_name='Ec2DetailedMonitoringMitigationArn')
@spensireli
spensireli / GitHub Example
Created January 4, 2023 19:49
SSM Send Command for GitHub and S3
source_info = {"owner":"spensireli","repository":"ssm-test","path":"ssm-test","tokenInfo":"{{ssm-secure:git-token}}", "getOptions":"branch:main"}
json_encoded_source_info = json.dumps(source_info)
try:
send_command = ssm_client.send_command(
InstanceIds=[resource_id],
DocumentName="AWS-ApplyAnsiblePlaybooks",
Parameters={"SourceType": ["GitHub"], "SourceInfo": [json_encoded_source_info], "PlaybookFile": ["someteam.yml"], "InstallDependencies": ["True"]}
)
@spensireli
spensireli / gist:801ef8ced46a394a417ee1504d38c596
Created March 10, 2023 17:18
Tar and Move Directory in One Line
mkdir /target/directory
cd /source/directory
tar -cvf - . | (cd /target/directory && tar xvf -)
@spensireli
spensireli / gist:96b57db8a6651f3bb78301584e4ee97b
Created March 15, 2023 20:04
Update Opensearch Index Field Limit
PUT /_cluster/settings
{
"index.mapping.total_fields.limit": 3000
}
@spensireli
spensireli / gist:9c5e9517b4ff9f0693c692d63bbac7ee
Last active April 9, 2023 00:50
Flash esp8266 with micropython
# Flash the esp8266 from my m2 macbook
esptool.py --port /dev/cu.usbserial-0001 --baud 460800 write_flash --flash_size=detect -fm dout 0 ~/Downloads/esp8266-20220618-v1.19.1.bin
# Connect via serial with rshell
rshell -p /dev/cu.usbserial-0001
# Stop Daemonset (apply node selector)
kubectl -n <namespace> patch daemonset <name-of-daemon-set> -p '{"spec": {"template": {"spec": {"nodeSelector": {"non-existing": "true"}}}}}'
# Start Daemonset (remove node selector)
kubectl -n <namespace> patch daemonset <name-of-daemon-set> --type json -p='[{"op": "remove", "path": "/spec/template/spec/nodeSelector/non-existing"}]'
@spensireli
spensireli / gist:9a0a15585e8a2711caa5088b7a4f3250
Created November 7, 2023 14:58
Loop through and Remove KMS Key Grants
for grant_id in $(aws kms list-grants --key-id <key-id> --query 'Grants[].GrantId' --output text); do aws kms revoke-grant --key-id <key-id> --grant-id $grant_id; done