Skip to content

Instantly share code, notes, and snippets.

@biiont
biiont / gist:8e069824a4d71ddf8ca0
Created August 29, 2015 13:23
Check latency of Hurricane Electric IPv6 Tunnel Servers
#!/bin/sh
IPS="216.218.221.6:216.218.221.42:74.82.46.6:216.66.84.46:216.66.86.114:216.66.87.14:216.66.80.30:216.66.88.98:216.66.84.42:216.66.86.122:216.66.80.90:216.66.80.162:216.66.80.98:216.66.22.2:184.105.253.14:184.105.253.10:184.105.250.46:72.52.104.74:64.62.134.130:216.66.77.230:209.51.161.58:209.51.161.14:66.220.7.82:216.218.226.238:216.66.38.58:184.105.255.26"
#IPS="216.218.221.6"
IT="${IPS}:"
while [ -n "$IT" ]
do
VAL="${IT%%:*}"
RES=$(ping -q -n -c 9 "${VAL}" | grep -e 'rtt' | cut -d ' ' -f 4)
@biiont
biiont / vim.tiny-rc
Created September 12, 2015 04:27
Fix cursor movement and backspace in insert mode for vim.tiny.
" Fix cursor movement and backspace in insert mode for vim.tiny.
set nocompatible
set backspace=indent,eol,start
@biiont
biiont / manipulate_rc.d_scripts.sh
Last active October 1, 2015 08:27
List, enable and disable rc.d scripts
# Here prefx "S" means start, and "K" means stop/kill.
# Two digits after mean order of start and kill operations.
# I have not found any standard defining this order,
# but orders above 90 usually are user scripts.
# List installed runlevels
ls /etc/rc.d/rc?.d/*someservice
# Remove from any runlevels
rm /etc/rc.d/rc?.d/*someservice
@biiont
biiont / someservice
Created October 1, 2015 08:28
init.d service for ordinary console app
#!/bin/sh
# This is /etc/sysconfig/someservice:
# CHARTSRVBASE="/opt/someservice"
# CHARTSRVRUN="/opt/someservice"
# CHARTSRVBIN="/opt/someservice/someservice"
# CHARTSRVPID="/var/run/someservice.pid"
# CHARTSRVLOG="/var/log/someservice/someservice-$(date +%Y%m%d%H%M%S).log"
########################################################################
# Begin $rc_base/init.d/
# Description :
@biiont
biiont / batch_image_resample.sh
Created October 1, 2015 10:07
Batch image resample
#!/bin/sh
# This script allows to resample images from whatever DPI to 75 DPI (screen resolution)
# in batch. I use it to prepare smallsize images of scans of my IDs, etc...
cd path/to/collections/base/dir
for fi in $(/bin/ls -1 image_collection_600dpi/*)
do
fo="$(echo $fi | sed 's/_[[:digit:]]\+dpi//g')"
echo convert-im6 $fi -units PixelsPerInch -resample 75 $fo
@biiont
biiont / ssh-sync-date.sh
Created October 1, 2015 10:08
Sync local time to remote host over ssh
#!/bin/sh
# Sync local date to remote host over ssh
ssh remote.host.net sudo date $(date "+%m%d%H%M%Y.%S")
@biiont
biiont / gist:6744b1bae9c7bb1cd6ca
Created October 1, 2015 10:08
Fix dhcp name change
#!/bi/sh
# Fix dhcp name change. Works for Debian on 2015-07-11.
sudo echo "supersede host-name gethostname();" >> /etc/dhcp/dhclient.conf
@biiont
biiont / mass_rename.sh
Last active October 6, 2015 11:53
Mass files rename in shell
#!/bin/false
## First: select file set.
/bin/ls -1 prefix_to_remove_*
## Second: test transformation.
/bin/ls -1 prefix_to_remove_* | sed 's/^prefix_to_remove_\(.*\)$/\1/'
## Third: execute
## NOTE: Added 'mv \0 ' to the sed command and '| sh' to the pipe.
@biiont
biiont / xelatex-word-replace.tex
Last active October 22, 2015 13:23
This gist allows to programmatically search and replace in latex taking in consideration word form.
\documentclass{article}
\usepackage{xltxtra}
\usepackage{xecyr}
\usepackage{polyglossia}
\setmainlanguage{russian}
\setotherlanguage{english}
\newfontfamily\cyrillicfont{DejaVu Serif}
@biiont
biiont / multipdf.sh
Created November 10, 2015 19:55
Create multipage scanned pdf files
#!/bin/sh
OUT="result" convert source1.tiff source1.tiff ... -depth 75 -units pixelsperinch -compress zip $OUT.pdf && pdf2ps $OUT.pdf && ps2pdf $OUT.ps && rm -f $OUT.ps