Skip to content

Instantly share code, notes, and snippets.

View gdm's full-sized avatar

Dmytro Gorbunov gdm

View GitHub Profile
# rename files with complex names
j=1
for f in *.jpg ; do
echo "mv '$f' p${j}.jpg"
j=$((j+1))
done
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
#!/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
@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/*
@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 / 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 / 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
List deptree
for i in `rpm -qa` ; do echo "Package [$i]:"; rpm -q --requires $i ; echo ; done
@gdm
gdm / udev-rules
Last active October 6, 2018 22:24
udevadm info -n /dev/sdb -q property
udevadm monitor
Pre-installed udev rules
/lib/udev/rules.d/60-block.rules
ACTION=="add", SUBSYSTEM=="block", ENV{ID_FS_UUID}=="xxxxx", RUN+="/root/my-usb.sh $devpath $name"
for FILE in *.mp4; do
echo -e "Processing video '\e[32m$FILE\e[0m'";
ffmpeg -i "${FILE}" -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 "${FILE%.mp4}.mp3"
done;
# find . -type f -iname "*.webm" -exec bash -c 'FILE="$1"; ffmpeg -i "${FILE}" -vn -ab 128k -ar 44100 -y "${FILE%.webm}.mp3";' _ '{}' \;
#ffmpeg -i video.mp4 -vn \
# -acodec libmp3lame -ac 2 -ab 160k -ar 48000 \
# audio.mp3