Skip to content

Instantly share code, notes, and snippets.

View famousgarkin's full-sized avatar

Ján Dzurek famousgarkin

View GitHub Profile
# https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/filter/core.py
# https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/kms.html
import boto3
import base64
kms = boto3.client('kms', region_name='eu-central-1')
def aws_kms_decrypt(ciphertext):
'''
set -ex
# https://kubernetes.io/docs/tasks/run-application/run-stateless-application-deployment/
# create
kubectl apply -f https://k8s.io/examples/application/deployment.yaml
kubectl describe deployment nginx-deployment
kubectl get pods -l app=nginx
sleep 20s
@famousgarkin
famousgarkin / docker-check-if-inside-container.sh
Last active July 20, 2018 12:46
check if inside Docker container
grep -q docker /proc/1/cgroup
@famousgarkin
famousgarkin / aws-orphaned-ami-snapshots-cleanup.sh
Last active August 27, 2018 05:44
AWS orphaned AMI snapshots cleanup
#!/usr/bin/env sh
# https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-snapshots.html
snapshots=$( \
aws ec2 describe-snapshots \
--region eu-central-1 \
--owner-id $OWNER_ID \
--filters 'Name=description,Values="Created by CreateImage*",Name=status,Values=completed'
)
@famousgarkin
famousgarkin / download-latest-cli53-release.sh
Last active November 20, 2017 08:57
download latest cli53 release
curl https://api.github.com/repos/barnybug/cli53/releases/latest \
| jq --raw-output '.assets[] | select(.name == "cli53-linux-amd64") | .browser_download_url' \
| xargs curl --location --output /usr/local/bin/cli53
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' <URL>
@famousgarkin
famousgarkin / fastcgi-php.conf
Created August 28, 2017 16:52
Debian Nginx PHP FastCGI snippet
### Debian snippets/fastcgi-php.conf
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
@famousgarkin
famousgarkin / Dockerfile
Created August 28, 2017 13:42
Docker PHP php.ini setup
# FROM https://hub.docker.com/_/php/
RUN mkdir /usr/src/php
RUN tar --file /usr/src/php.tar.xz --extract --strip-components=1 --directory /usr/src/php
RUN cp /usr/src/php/php.ini-production /usr/local/etc/php/php.ini
@famousgarkin
famousgarkin / rm.sh
Created July 17, 2017 10:34
remove dangling Docker images
docker image rm $(docker image ls --quiet --filter dangling=true)