Skip to content

Instantly share code, notes, and snippets.

View ojacques's full-sized avatar
🌤️
Head in the cloud; feet, too.

Olivier Jacques ojacques

🌤️
Head in the cloud; feet, too.
View GitHub Profile
@ojacques
ojacques / README.md
Created February 26, 2024 08:08
Minimal Docker image from AL2023 Amazon Linux 2023

Minimal Docker image from AL2023 Amazon Linux 2023 (in this case, bash and its dependencies)

FROM public.ecr.aws/amazonlinux/amazonlinux:2023 as build
RUN dnf --releasever=$(rpm -q system-release --qf '%{VERSION}') \
  --installroot /sysroot \
  -y \
  --setopt=install_weak_deps=False \
  install bash
@ojacques
ojacques / aws-sagemaker-delete-apps.sh
Created October 3, 2023 17:03
List and delete all Amazon SageMaker KernelGateway apps which are still running
aws sagemaker list-apps --query "Apps[?AppType=='KernelGateway' && Status=='InService']" | jq -r '.[] | "\(.AppName) \(.DomainId) \(.UserProfileName)"' | while read AppName DomainId UserProfileName; do echo Deleting $AppName for user $UserProfileName ... && aws sagemaker delete-app --domain-id $DomainId --app-type KernelGateway --app-name $AppName --user-profile $UserProfileName; done
@ojacques
ojacques / README.md
Created May 24, 2023 17:35
Ressources: Réduire son empreinte carbone 🌳🌻 grâce au cloud ☁️
@ojacques
ojacques / README.md
Last active May 11, 2023 21:32
We are ALL DevOps YouTubers now - resources
@ojacques
ojacques / VI.without.VI.in.Docker.container.md
Created January 11, 2023 16:37
Edit a file in Docker container when no editor / vi

Context

I need to edit a file in a Docker container. This container does not have vi or an actual editor. I cannot install anything. I don't have access to run chown either.

Solution

  • Login on the Docker host
  • Get the file from the container: docker cp b28b1d60e423:/the/file/that.I.want.json .
  • Get into the container and find out what is the UID/GID which you want to create the file with (use id)
  • Edit the file on the Docker host
@ojacques
ojacques / gist:578cce2b77c868e2775f4f64de77a23a
Created January 11, 2023 13:42
AWS delete backup recovery points earlier than a date
VAULT=<your vault here>
for ARN in $(aws backup list-recovery-points-by-backup-vault --backup-vault-name "$VAULT" --query 'RecoveryPoints[].RecoveryPointArn' --output text --region eu-west-1 --by-created-before 1672580151); do
echo "deleting $ARN"
aws backup delete-recovery-point --recovery-point-arn $ARN --region eu-west-1 --backup-vault-name "$VAULT"
done
@ojacques
ojacques / delete-SSM-params.md
Created November 22, 2022 18:10
Delete SSM parameters starting with...

Delete all SSM parameters starting with /XYZ:

aws ssm get-parameters-by-path --path /XYZ --recursive --query 'Parameters[].[Name]' --output text | xargs -n1 -IParam aws ssm delete-parameter --name Param
@ojacques
ojacques / README.md
Last active November 17, 2022 20:25
Export aws ssm get-parameters-by-path results as environment variables with jq

Export all AWS SSM Parameters retrieved from a given path as environment variables

Example:

I have the following SSM parameters:

  • /codepipeline/deploy_prod with value "v1.2.0"
  • /codepipeline/deploy_preprod with value "v1.1.1"
  • /codepipeline/deploy_sandbox with value "a0582a5fa7fff7361b18581d04d222a35cceb264"

The following environment variables will be exported:

@ojacques
ojacques / batch-encode.md
Created December 20, 2021 22:13
Batch encode GoPRO 4K H265 to H265 with ffmpeg

Use case

Filming with GoPro with H.265, but editing with software which does not support H.265 (like Magix FastCut). Let's convert all those files to H.264, leveraging GPU (like NVidia RTX 3070 -> ~2x speed at 4K->4K)

One liner

for f in *.MP4; do ffmpeg -hwaccel cuvid -i "$f" -map 0 -c copy -c:v h264_nvenc -qp 20 -tune hq -crf 25 -preset slow h264vids/"${f%.*}.mp4"; done
@ojacques
ojacques / git.squash.commits.in.PR.md
Last active September 8, 2021 09:30
Squash multiple commits in a PR that was already pushed

Find out the SHA for when the branch was initiated:

$ git merge-base feature/248227-create-drop-artifact develop
b373da2f4b24e57a147021df1d3964a46b47edf3

Rebase / squash interactively: