Skip to content

Instantly share code, notes, and snippets.

View dmytro's full-sized avatar

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

View GitHub Profile

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@dmytro
dmytro / TikiWiki_Dockerfile
Last active February 24, 2016 01:47
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.
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 May 26, 2024 13:57
Rip and encode DVD
#!/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 <[email protected]>
# mplayer -V
# MPlayer svn r34540 (Debian), built with gcc-4.7 (C) 2000-2012 MPlayer Team
@dmytro
dmytro / generate_openvpn_config.sh
Last active August 12, 2024 23:04
Script for OpenVPN generate client config file.
#!/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 August 21, 2014 02:31
Set ID3 tags of MP3 files from file names and directory names.
#!/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 August 29, 2015 14:05
Shell script to convert FLAC or APE files to MP3
#!/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 November 8, 2018 11:14
Shell script for SYN flood DOS attacks prevention. Use sqlite3 to filter IP's
#!/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 December 12, 2012 08:37
checks configuration for Nagios for Couchbase
:vb_active_num:
:namespace: Wizcorp::Couchbase
:class: BucketStats
:function: :avg # :avg, :sum, :none
:operator: :<
:rag: [1024,1024,1025]
@dmytro
dmytro / rag.rb
Created December 12, 2012 08:00
RAG Checks for Nagios
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 November 27, 2012 05:40
Prompt for ZSH and Git
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~]$ " ""