Skip to content

Instantly share code, notes, and snippets.

Avatar

Dmytro Kovalov (uk: Дмитро Ковальов) dmytro

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@dmytro
dmytro / TikiWiki_Dockerfile
Last active Feb 24, 2016
Dockerize PHP application for safe serving RO web site. Server several LAMP sites from Docker containers read-only. MySQL dumps are loaded at the time of containers start.
View TikiWiki_Dockerfile
FROM tutum/lamp:latest
RUN rm -fr /app
ADD src /app
RUN chown www-data -R /app/tiki
ADD kraiany.dump.bz2 /kraiany.dump.bz2
ADD prepare.sh /prepare.sh
@dmytro
dmytro / rip_dvd.sh
Last active Feb 4, 2016
Rip and encode DVD
View rip_dvd.sh
#!/bin/bash
# (c) Dmytro Kovalov, 2016.
#
# Converts VIDEO_TS folder of the DVD stored on disk into VOB file for each of the titles
# and converts them to H264 (using separate to264 script.)
# Tested on Debian Linux with:
# lsdvd -V
# lsdvd 0.16 - GPL Copyright (c) 2002, 2003, 2004, 2005 "Written" by Chris Phillips <acid_kewpie@users.sf.net>
# mplayer -V
# MPlayer svn r34540 (Debian), built with gcc-4.7 (C) 2000-2012 MPlayer Team
@dmytro
dmytro / generate_openvpn_config.sh
Last active Jan 31, 2021
Script for OpenVPN generate client config file.
View generate_openvpn_config.sh
#!/bin/bash
# Easy script to create OpenVPN client configuration with the user, pre-generating user's
# RSA key and certificate.
#
# Configuration template must exist in the same directory, with only missing part: certificates.
#
# (c) Dmytro Kovalov, 2015
#
cd $(dirname ${BASH_SOURCE[0]})
@dmytro
dmytro / file2utf8tag.sh
Created Aug 21, 2014
Set ID3 tags of MP3 files from file names and directory names.
View file2utf8tag.sh
#!/bin/bash
#
# If you have munch of MP3's in a folder with filenames corresponding
# to the titles of songs, but ID3 tags are missing or misformed (for
# example, coming from Windows with cp1251 codapage, but you need
# UTF8), this script will read filenames and set ID3 tags
# correspondingly.
#
# cd to the directory with mp3 files and execute script
# there. Directories on the upper level should have names:
@dmytro
dmytro / lossless2mp3.sh
Last active Aug 29, 2015
Shell script to convert FLAC or APE files to MP3
View lossless2mp3.sh
#!/bin/bash
doit () {
NAME="$*"
echo $NAME
NAME=$(echo $NAME | sed 's;^\.\/;;')
DIR=$(dirname "$NAME")
FILE="$(echo $(basename ${NAME}) | sed 's/\.[^\.]*$//')"
OUT=tmp/$DIR
OFILE="${OUT}/${FILE}.mp3"
@dmytro
dmytro / gist:7887843
Last active Nov 8, 2018
Shell script for SYN flood DOS attacks prevention. Use sqlite3 to filter IP's
View gist:7887843
#!/bin/bash
SLEEP=120
MAX_CONN=20
MY_IP=0.0.0.0 # Configure your IP here
while true; do
(
echo "create table ips (ip string);"
echo 'begin transaction;'
netstat -an | grep -v ESTABLISHED | grep ${MY_IP}:80 | awk '{print $5}' | cut -f4 -d: | while read IP; do
@dmytro
dmytro / nfc_checks.yml
Created Dec 12, 2012
checks configuration for Nagios for Couchbase
View nfc_checks.yml
:vb_active_num:
:namespace: Wizcorp::Couchbase
:class: BucketStats
:function: :avg # :avg, :sum, :none
:operator: :<
:rag: [1024,1024,1025]
@dmytro
dmytro / rag.rb
Created Dec 12, 2012
RAG Checks for Nagios
View rag.rb
def rag
rag = -1
res = @connection.send(@key[:name]).send(@key[:function].to_sym)
thresholds = @key[:rag].reverse
thresholds.each_index do |idx|
val = thresholds[idx]
rag = idx if res.send(@key[:operator].to_sym, val)
end
@dmytro
dmytro / prompt.zsh
Created Nov 27, 2012
Prompt for ZSH and Git
View prompt.zsh
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
precmd() {
vcs_info
}
setopt prompt_subst
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:*' formats "%f[%%n@%%m %1~] $ " "%f%a %F{3}%m%u%c %f%b:%r/%S"
zstyle ':vcs_info:*' nvcsformats "%f[%n@%m %1~]$ " ""