Skip to content

Instantly share code, notes, and snippets.

View dmytro's full-sized avatar

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

View GitHub Profile
@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 / .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 / 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 / run_root_remotely.sh
Created June 26, 2012 01:56
Various scripts
#!/bin/bash
:<<"=cut"
=head1 NAME
C<run_root_remotely> - use expect and sudo to deploy SSH key to remote
server root account and execute script on the remote via SSH as root
=head1 DESCRIPTION
@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 / 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 / ssh-multi.sh
Created October 31, 2012 03:46
Start multiple synchronized SSH connections with Tmux
#!/bin/bash
# ssh-multi
# D.Kovalov
# Based on http://linuxpixies.blogspot.jp/2011/06/tmux-copy-mode-and-how-to-control.html
# a script to ssh multiple servers over multiple tmux panes
starttmux() {
if [ -z "$HOSTS" ]; then
@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 / tmux_pwd.sh
Created November 22, 2012 06:15
Open Tmux panes in current directory
tmux_pwd () {
[ -z "${TMUX}" ] && return
TARGET=\-t$(tmux display-message -p "#S")
tmux set-window-option ${TARGET} default-path $PWD > /dev/null
(( sleep 300;
tmux set-window-option ${TARGET} default-path ~/Development > /dev/null; ) & ) > /dev/null 2>&1
}
alias pwd="\pwd; tmux_pwd"
@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~]$ " ""