Skip to content

Instantly share code, notes, and snippets.

Setting branch tracking

When publishing local branch

git push -u origin dev

When checkouting

git checkout --track origin/dev

When forgot to do above

@mortalius
mortalius / set_default_aws_profile.sh
Created September 4, 2020 12:43
Set Profile scripts
#!/bin/bash
unset AWS_PROFILE
unset AWS_DEFAULT_REGION
PROFILE=$1
REGION=$(aws --profile $PROFILE configure get region)
REGION=${REGION:-us-east-1}
echo export AWS_PROFILE=${PROFILE}
export AWS_PROFILE=${PROFILE}
@mortalius
mortalius / athenaqueries.md
Last active September 4, 2020 12:21
Athena queries

ALB

SELECT *
FROM alb_logs_UAT
WHERE parse_datetime(time,'yyyy-MM-dd''T''HH:mm:ss.SSSSSS''Z') 
     BETWEEN parse_datetime('2020-07-21-05:20:00','yyyy-MM-dd-HH:mm:ss') 
     AND parse_datetime('2020-07-21-05:45:00','yyyy-MM-dd-HH:mm:ss')
     AND elb_status_code like '4%'
@mortalius
mortalius / AWS JMESPath by examples.md
Last active November 2, 2022 13:49
AWS JMESPath examples
Get Reservations that have more than 1 instance records and show ReservationId and InstanceIds
aws ec2 describe-instances --query 'Reservations[?Instances | length(@) > `1` ].[ReservationId,Instances[].[InstanceId]]'
Same, but shows total number of instances per Reservation
aws ec2 describe-instances \
--query 'Reservations[?Instances | length(@) == `3`].[ReservationId,Instances[] | length(@)]'
Get Name tag