Skip to content

Instantly share code, notes, and snippets.

View dsmrt's full-sized avatar
🤙
❤️

Damien Smrt dsmrt

🤙
❤️
View GitHub Profile
tail -f storage/logs/web.log | grep -A 10 -n '\[saml-\]'
@dsmrt
dsmrt / run-on-one-server.bash
Created February 12, 2019 16:47
AWS ElasticBeanstalk helper - Only run command on one server in an EB environment.
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage run-on-one-server.bash <eb-environment-name>";
exit 0;
fi
LEADER_INSTANCE=$(aws --region us-west-2 ec2 describe-instances --filters "Name=instance-state-name,Values=running" "Name=tag:elasticbeanstalk:environment-name,Values=$1" | jq '[.Reservations[].Instances[0]] | sort_by(.LaunchTime) | .[0].InstanceId' -r)
THIS_INSTANCE=$(curl http://169.254.169.254/latest/meta-data/instance-id)
@dsmrt
dsmrt / query-aws-logs-insights.bash
Last active April 18, 2025 14:47
Using AWS CLI to query CloudWatch Logs with Insights. Looking -30 mins to now.
# this script queries aws logs with insights filtering on ERROR
# explanation of start and end times
#--start-time = unix timestamp 30 mins in the past
#--end-time = unix timestamp now
QUERY_ID=$(aws logs start-query \
--profile $profile \
--log-group-name /aws/lambda/aap-event-consumer-dev \
--start-time `date -v-30M "+%s"` \
@dsmrt
dsmrt / grep-craft-log.bash
Last active February 8, 2019 18:57
Grep large craft logs. Looking for errors.
#!/bin/bash
grep -B 3 -A 10 -n '\[error\]' storage/logs/web.log
@dsmrt
dsmrt / get-all-recomend-ecs-amis.bash
Created August 2, 2018 15:52
Get the latest recommended ECS optimized AMIs printed for CloudFormation Mappings
#!/bin/bash
echo "AWSRegionToAMI:"
for region in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text)
do
echo " ${region}:";
AMI=$(aws ssm get-parameters --names /aws/service/ecs/optimized-ami/amazon-linux/recommended --region $region | jq -r '.Parameters[0].Value | fromjson | .image_id')
printf " AMI: %s \n" $AMI
done
@dsmrt
dsmrt / alter-table-ignore-dupes.sql
Created July 12, 2018 17:13
Mysql - Remove duplicates by adding a unique key.
-- Reference: https://stackoverflow.com/questions/36647058/removing-duplicates-with-unique-index
ALTER IGNORE TABLE mytable ADD UNIQUE INDEX myindex (A, B, C, D);
@dsmrt
dsmrt / install-saml-sp.sh
Last active April 11, 2018 16:33
Composer require Saml SP
composer require flipboxfactory/saml-sp
#waiting for craftcms v3!
while true; do composer update; done
@dsmrt
dsmrt / docker-compose.yml
Created February 8, 2018 17:33
Flipbox NGINX/PHP 7.2 FPM CraftCMS docker-compose.yml
# REPOs
# https://hub.docker.com/r/flipbox/php/
version: "3"
services:
web:
image: flipbox/php:72-fpm-alpine
volumes:
- .:/app/
# point to your fpm inis
- ./general.ini:/usr/local/etc/php/conf.d/general.ini
@dsmrt
dsmrt / docker-compose.yml
Last active February 8, 2018 17:18
Flipbox Docker LAMP for CraftCMS Dev
version: "3"
services:
web:
image: flipbox/php:71-amazonlinux-apache
ports:
- 80:80
#I have a self signed cert for local dev work
- 443:443
volumes:
- .:/var/www/html