Skip to content

Instantly share code, notes, and snippets.

View matwerber1's full-sized avatar

Mathew Werber matwerber1

  • Seattle
View GitHub Profile
@matwerber1
matwerber1 / bigquery-sql-for-gmail-logs.sql
Last active June 11, 2025 21:57
Example SQL for Gmail Logs data written to BigQuery daily_ table
-- I was helping a company using Google Workspace for email, and they were having challenges
-- with email deliverability due to domain reputation. While it's true that gmail provides
-- provides detailed logs, I found their docs to be only marginaly helpful and lacking
-- more robust, real-world ways to interpret the data. I also struggled to find quality examples
-- when searching unofficial sources (blogs, etc.).
--
-- The query below is my best effort attempt to translate gmail logs into something half-way usable.
-- I'd be shocked if there weren't mistakes or areas for improvement, but either way, sharing in
-- the hope that it at least helps give a jumping-off point for anyone else that finds themselves
-- saying "OK, I enabled Gmail Logs for BigQuery.... now what?".
@matwerber1
matwerber1 / aws-cli-ecs-exec-with-fargate.sh
Last active October 13, 2023 04:18
Example to start an ECS Fargate task an existing cluster, task definition, and VPC, and then use ECS Exec to open an interactive shell with a containr in the task
CLUSTER="your_cluster_name"
REGION="cluster_region"
PRIVATE_SUBNETS="subnet-someSubnet123,subnet-someOtherSubnet456"
TASK_SECURITY_GROUP="security-group-for-ECS-task-ID"
PUBLIC_IP_SETTING="DISABLED"
TASK_CONTAINER_NAME_FOR_ECS_EXEC="container-name-for-ecs-exec"
# Run a Fargate task with ECS Exec enabled:
RUN_TASK_RESULT=$(
aws ecs run-task \
@matwerber1
matwerber1 / athena-query-for-cloudtrail-route53-dns-changes.sql
Last active October 15, 2023 04:42
Example SQL to search CloudTrail Logs stored in S3 using Amazon Athena for any changes to Route 53 DNS records#
-- Query assumes your Athena table is partitioned with a "day" column as described here:
-- https://www.linkedin.com/pulse/using-athena-partition-projection-query-cloudtrail-other-kinsman/
with detail AS (
SELECT
day,
eventtime as timestamp,
account,
awsregion as region,
eventid,
@matwerber1
matwerber1 / google-sheet-formula-parse-iso86001-date-strings.md
Created July 30, 2022 03:28
Google Sheet Formula to convert ISO86001 date from string to usable timestamp data type.

Google sheet formula to convert a ISO86001 string to a date time:

Input: 2022-06-23T16:31:34.036000+00:00 (cell A2)

Formula: SUM(SPLIT(left(A2,len(A2)-6),"T"))

Output: (a properly-formatted datetime)

@matwerber1
matwerber1 / ec2-node-amzn.sh
Created September 26, 2018 02:57 — forked from ogckw/ec2-node-amzn.sh
ec2-amazon-linux-node-userdata
#!/bin/bash
# Program:
# EC2 initially install node.js, git for development environment.
# You can modify nodev and nvmv for changing node and nvm version.
# Set permission to ec2-user install above.
# History:
# 2017/07/25 Hans First release
home=/home/ec2-user
nodev='8.11.2'
nvmv='0.33.11'