Skip to content

Instantly share code, notes, and snippets.

View ajardin's full-sized avatar
🏠
Working from home

Alexandre Jardin ajardin

🏠
Working from home
View GitHub Profile
@ajardin
ajardin / 1-initialization.sh
Created May 6, 2024 21:29
How to improve your Symfony commands
composer create-project symfony/website-skeleton sandbox
cd sandbox
composer install --optimize-autoloader
@ajardin
ajardin / 1-github-action.yaml
Created May 6, 2024 21:22
Distributing projects compiled into PHAR
name: Continuous Deployment
on:
push:
branches: ['master']
jobs:
tests:
name: Deployment
runs-on: ubuntu-latest
@ajardin
ajardin / 1-esb-tags.sh
Created August 21, 2020 18:39
Adding tags to EBS volumes
#!/usr/bin/env bash
set -euo pipefail
# Retrieve the current EC2 instance ID.
declare -r instance_id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
# Retrieve the AWS region ID where the EC2 instance is located.
declare -r region_id=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | grep -Po "(us|ca|ap|eu|sa)-(north|south)?(east|west|central)-[0-9]+")
# Retrieve the volumes attached to the current EC2 instance.
@ajardin
ajardin / aws-connect.sh
Created August 21, 2020 18:35
Connecting to EC2 instances without a headache
#!/usr/bin/env bash
set -euo pipefail
# ======================================================================================================================
# Make the SSH connection to EC2 instances easier by requiring only tag values instead of IP addresses.
#
# Usage:
# bash aws-connect.sh <environment> <bastion|apache|nginx|...> <index>
#
# Examples:
@ajardin
ajardin / 1-changelog.diff
Created August 21, 2020 18:32
Blackfire & Magento
- <a href="<?php echo $helper->getCategoryUrl($category); ?>">
+ <a href="<?php echo $helper->getData('url_path'); ?>">
<?php echo $category->getData('name'); ?>
</a>
@ajardin
ajardin / 1-main.conf
Created August 21, 2020 18:15
Defending against Apache DoS attacks
<IfModule evasive_module>
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
</IfModule>
@ajardin
ajardin / 1-manual-cleaning.sh
Created August 21, 2020 17:20
Garbage collector for Docker
# Remove all dangling images
docker rmi $(docker images --filter="dangling=true" --quiet)
# Remove all stopped containers
docker rm $(docker ps --filter="status=exited" --quiet)
# Remove all dangling volumes
docker volume rm $(docker volume ls --filter="dangling=true" --quiet)
@ajardin
ajardin / 1-phar-compilation.sh
Last active November 10, 2020 16:37
Compiling Symfony projects into PHAR
# Compiles the project into a PHAR archive.
docker run --rm --interactive --tty --volume="$(pwd):/app" ajardin/humbug-box compile -vvv
@ajardin
ajardin / commit-msg.sh
Last active June 20, 2018 19:07
Git commit-msg hook to validate message format.
#!/usr/bin/env bash
set -euo pipefail
# ====================================================================================================
# The script below allows to check automatically a commit message before saving it.
# In order to use it, you have to copy this code in .git/hooks/commit-msg inside your project.
# Don't forget to add proper permissions if you create a new file (chmod +x). Bash 3+ is required.
# ====================================================================================================
COMMIT_MSG=$(cat $1)
@ajardin
ajardin / sync-tags.sh
Last active September 17, 2019 20:03
Adding tags to EBS volumes.
#!/usr/bin/env bash
set -euo pipefail
# Retrieve the current EC2 instance ID.
declare -r instance_id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
# Retrieve the AWS region ID where the EC2 instance is located.
declare -r region_id=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | grep -Po "(us|ca|ap|eu|sa)-(north|south)?(east|west|central)-[0-9]+")
# Retrieve the volumes attached to the current EC2 instance.