Skip to content

Instantly share code, notes, and snippets.

View gdm's full-sized avatar

Dmytro Gorbunov gdm

View GitHub Profile
@gdm
gdm / jq magic
Last active April 10, 2019 19:16
# usefull when parse output frow aws cli
# from https://github.com/stedolan/jq/issues/370
jq '.Attributes[] | select (.Name == "public_ip") | .Value'
# json to bash-style env
jq -r 'to_entries | .[] | .key + "=\"" + .value + "\""' | grep -P '^AWS_(REGION|ACCESS_KEY|SECRET|SESSION)'
# parse CloudTail logs (from http://flaws2.cloud/defender3.htm )
jq -cr '.Records[]|[.eventTime, .sourceIPAddress, .userIdentity.arn, .userIdentity.accountId, .userIdentity.type, .eventName]|@tsv' | sort
@gdm
gdm / dump-iptables-docker-managed.txt
Created December 26, 2018 21:46
iptables modified by docker when nginx container is running
[root@bigben audit]# iptables --line-numbers -n -L -t nat
Chain PREROUTING (policy ACCEPT)
num target prot opt source destination
1 DOCKER all -- 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL
Chain INPUT (policy ACCEPT)
num target prot opt source destination
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
@gdm
gdm / convert-pdf-to-images
Created January 22, 2019 22:21
Convert big pdf to png images
for i in {1..83} ; do echo $i ; pdftoppm file.pdf page-$i -png -f $i -singlefile ; done;
@gdm
gdm / nvm-one-liners
Created February 10, 2019 21:46
one liners for NVM
nvm install 11.9.0 --reinstall-packages-from=11.8.0
nvm ls-remote
du -sh ~/.nvm/versions/node/*
#!/bin/bash -xe
VGNAME=eph
# now we need to check that we use ephemeral disk as /dev/xvdb
# its very naive check but better then nothing because operations above can be dangerous
if ! lsblk | grep '^xvdb' | grep 75G > /dev/null ; then
echo "Problems with expectations for /dev/xvdb"
exit 1
fi
hhvm.conf:
check program check-hhvm with path "/etc/monit/bin/check-hhvm.sh"
if status != 0 then alert
if status != 0
then exec "/usr/sbin/service hhvm restart"
/etc/monit/bin/check-hhvm.sh:
#!/bin/bash
# rename files with complex names
j=1
for f in *.jpg ; do
echo "mv '$f' p${j}.jpg"
j=$((j+1))
done
@gdm
gdm / resize-fs
Created April 24, 2019 05:39
Resize filesystems
lvextend -L +90G /dev/exhdd/backup
btrfs: btrfs filesystem resize max /mnt/backup/
@gdm
gdm / gist:5fa8b1347a37b8da1d1eca43078e17d3
Last active April 28, 2019 21:48
AWS articles 2read
AWS Lambda + Node Modules, no Docker required : https://medium.com/@haydnjmorris/aws-lambda-node-modules-no-docker-required-76443a0f6c4e
Automate Custom EC2 AMIs: (python, terraform, docker): https://medium.com/devopslinks/automate-custom-ec2-amis-155af71fae7d
NEWS about JAVA + Docker:
https://blog.softwaremill.com/docker-support-in-new-java-8-finally-fd595df0ca54?gi=53e209ef5a04
https://blog.docker.com/2018/04/improved-docker-container-integration-with-java-10/
@gdm
gdm / cleancache.sh
Created May 1, 2019 00:06
clean-cache-magento
#!/bin/bash
rm -rf /var/run/nginx-cache/*
rm -rf /home/shop_production/htdocs/var/cache/*
rm -rf /cache/catalog-cache/*
rm -rf /cache/shop-cache/*
rm -rf /cache/nginx-cache/*
# clean redis