Skip to content

Instantly share code, notes, and snippets.

View dmytro's full-sized avatar

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

View GitHub Profile
@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~]$ " ""
@dmytro
dmytro / play.rb
Created November 20, 2012 01:56
Low tech Mac music player
#!/usr/bin/env ruby
def play songs
song = songs[rand songs.length].strip
puts song
song.gsub!('`','\\\\`')
$pid = Process.spawn "afplay -v .2 \"#{song}\""
Process.wait $pid
sleep 1
end
@dmytro
dmytro / rt.css
Last active October 7, 2015 08:28
RT 4 - custom css
/* Page */
body {}
/* Header */
div#quickbar {}
body.aileron #main-navigation #app-nav > li, body.aileron #main-navigation #app-nav > li > a, #prefs-menu > li, #prefs-menu > li > a, #logo .rtname {}
/* Page title */
div#header h1 {}
@dmytro
dmytro / vpnc.sh
Created July 1, 2012 09:59
VPNC on MacOSX
#!/bin/bash
# D.Kovalov, 2008
# Non-debian patched vpns dos not support Target Nets config option.
# This script would emulate it: resets default routing after vpnc starts
# and sets DNS after startr/stop of VPNC
#
# User setting:
# What nets are routced through vpnc tun deviceand what's gateway for it
@dmytro
dmytro / config__amd64.cfg
Created June 21, 2012 06:11
Debian 6.0 with Cobbler
MEDIUM_SUPPORTED = cdrom cdrom-xen netboot netboot-gtk netboot-xen hd-media
MEDIUM_SUPPORTED_EXTRA = monolithic
# The version of the kernel to use.
KERNELVERSION = 2.6.32-5-amd64
KERNELMAJOR = 2.6
KERNEL_FLAVOUR = di
KERNELNAME = vmlinuz
KERNELIMAGEVERSION = $(KERNELVERSION)
@dmytro
dmytro / .bashrc
Created November 30, 2011 03:05
Dot files - fragments
PS1="\u@\h:\W $ "
short_path () {
local max_len=20
path=$(pwd)
len=$(echo $path | wc -c)
if test $len -lt $max_len; then
echo $path
else
st=$(echo $path | cut -c-8)
echo "${st}.../$(basename $path)"
@dmytro
dmytro / gist:1403742
Created November 29, 2011 06:45
Simple debugging
class Object
require 'pp'
# Simple debugging method for ruby. It takes an object, prints it with time
# stamp and caller insformation, returns an object. So it can be instesreted
# into any chain or method calls.
#
# Program debug level can be set by either global variable $debug or
# environment setting ENV['DEBUG']
#
@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"