Skip to content

Instantly share code, notes, and snippets.

@adamantnz
adamantnz / README.md
Created September 17, 2026 10:00
Access nav icons before/after

Access nav icon screenshots

@adamantnz
adamantnz / README.md
Created September 11, 2026 10:02
gh stack-approve: approve every PR in a GitHub stack with one command

gh stack-approve

Approve every open pull request in a GitHub stack with one command.

gh stack can link, sync, and merge. It cannot approve. After you have reviewed every layer, this submits gh pr review --approve on each open PR in the stack.

Install

Requires gh and jq.

> aws events describe-rule --name "airflow-start-scheduler-service" --profile test
{
"Name": "airflow-start-scheduler-service",
"Arn": "arn:aws:events:<region>:<accountid>:rule/airflow-start-scheduler-service",
"ScheduleExpression": "cron(0/5 * * * ? *)",
"State": "ENABLED",
"Description": "runs 'airflow scheduler --run-duration 300' on airflow server every 300 seconds to ensure scheduler is always running"
}
import airflow
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta
from pathlib import Path
import boto3
# dag methods
import os
# this is in the global scope so will run each time the file is parsed :(
folder = "my_folder"
if not os.path.exists(folder):
os.makedirs(folder)
def create_folder(folder):
# this will only run when the method is explicitly called, much better! :)
if not os.path.exists(folder):
import airflow
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta
from pathlib import Path
print(
"""This print is in the global state, so it will print this string
@adamantnz
adamantnz / update-aws-cost-and-usage-report-columns.sql
Last active December 12, 2019 01:07
Update AWS Cost and Usage Report Columns
/*
Dynamically creates Redshift "alter column" SQL for AWS "Cost and Usage Reports" based on the "tagmapping" data
Note: Redshift column names are case-sensitive so the first query renames the duplicate usertags (if any)
*/
update awsbillingYYYYMM_tagmapping
set usertag = b.usertag || '_' || cast(sequence as varchar)
from awsbillingYYYYMM_tagmapping a
inner join (
select row_number() over (
partition by lower(usertag) order by usertag desc
@adamantnz
adamantnz / lambda-create-dynamodb-backups.py
Last active June 11, 2019 09:44
lambda: create dynamodb table backups
from datetime import date, datetime, timedelta
import json
import boto3
from botocore.exceptions import ClientError
import os
ddbRegion = os.environ['AWS_DEFAULT_REGION']
now = datetime.now().strftime("-%Y-%m-%d-%H-%M-%S")
backupRetention = 7
@adamantnz
adamantnz / Tail-most-recent-log.ps1
Created May 12, 2017 13:34
Tail the most recent log file in a directory
get-content -tail 10 -wait -path (Get-ChildItem -Path C:\logs\...\ | Sort-Object LastAccessTime -Descending | Select-Object -First 1).FullName
@adamantnz
adamantnz / RedshiftQueries.sql
Last active November 26, 2020 18:20
Useful AWS Redshift Queries
/* show running queries */
select pid, user_name, starttime, query
from stv_recents
where lower(status) = 'running';
/* show recent completed queries */
select pid, user_name, starttime, query
from stv_recents
where lower(status) = 'done'
order by starttime desc;