VIM: File Autosave

I was wondering how to save file in VIM automatically. Found some solutions in internet but decided to do it my way. So I wrote this small solution: """ Save file on each edit exit function FileAutoSave() if exists('g:file_autosave_async') return endif if @% == "" return elseif !filewritable(@%) return endif let g:file_autosave_async = 1 call timer_start(500, 'FileAutoSaveAsync', {'repeat': 1}) endfunction function FileAutoSaveAsync(timer) update unlet g:file_autosave_async endfunction :autocmd InsertLeave,TextChanged * call FileAutoSave() """ It updates file in two cases:...

June 2, 2020

Route 53 Resolver: NXDOMAIN|SERVFAIL

What we have: On premises data center with own domain zone (domain.local) and dns servers AWS VPC with it’s own domain zone (domain.r53) and using Route 53 as DNS Server What we need: Ability to resolve domain zone hosted on premises DNS Servers from AWS VPC graph LR A[EC2 Instance] -->|a.domain.local| B[Route 53 Forward] -->|a.domain.local| C[DNS On Premises] The configuration is straightforward and well described in official documentation. You simply create rules:...

May 29, 2020

PostgreSQL 11 Administration Summary

PostgreSQL Administration Cheatsheet Intro New In PostgreSQL 11 WAL Size CREATE STATISTICS INCLUDE indexes CREATE INDEX in parallel pg_prewarm Updated WINDOW Functions JIT Compilation Better Partitioning Default Partition Partition Key Updating Hash Partitioning Index Created on Parent Table Better Support Of Stored Procedures Faster ALTER TABLE Locks and Transactions now() function SAVEPOINT DDL commands are transaction safe Explicit Locking FOR SHARE and FOR UPDATE SKIP LOCKED Using CTE with RETURNING FOR SHARE and FOR UPDATE FOR … clauses by locking strength FOR UPDATE SKIP LOCKED Recommended Locks VACUUM autovacuum Transaction ID Wraparound Transaction Duration Indexing Costs Model PostgreSQL Administration Cheatsheet Intro This cheatsheet is based on the great book about PostgreSQL 11 Administration...

May 22, 2020

command not found: ck-unlock-session

This evening I was updating my Gentoo laptop. While updating, my session were locked with the message, that to unlock it I have to use ck-unlock-session. Unfortunately shell told me that there is no such command on my laptop: └> ck-unlock-session zsh: command not found: ck-unlock-session In the vastness of the Internet found the solution, but it’s too long to remember: dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Session1 org.freedesktop.ConsoleKit.Session.Unlock Session1 - session name and it may differs....

July 25, 2019

Docker: Mounting block devices into container

Today was curious is it possible to mount block device into a docker container without mounting it on system. It’s not well documented but found one interesting comment in github. So, if –mount option in docker run command is “magic” on top of “mount” system call, we can use it. After experimenting a bit here is an example mounting lvm volumes. First, let’s create loop device for LVM: dd if=/dev/zero of=/tmp/loop bs=1M count=100 losetup /dev/loop0 /tmp/loop Then, making an LVM device:...

July 25, 2019

Gentoo: Building FireFox 63.0.3

Today I was trying to update FireFox on my Gentoo box and failed with error: 0:06.75 checking rustc version... 1.30.1 0:06.75 ERROR: Cargo package manager not found. 0:06.75 To compile Rust language sources, you must have 'cargo' in your path. 0:06.75 See https://www.rust-lang.org/ for more information. 0:06.75 0:06.75 You can install cargo by running './mach bootstrap' 0:06.75 or by directly running the installer from https://rustup.rs/ 0:06.75 0:06.79 *** Fix above errors and then restart with\ 0:06....

November 21, 2018

Gentoo: Backslash as Yen char

If while browsing the internet you have a problem with backslash character which displayed as yen sign you can fix it this way. First, let’s install the appropriate fonts. emerge -av media-fonts/droid Then we have to enable them for wide system. eselect fontconfig enable 59-google-droid-sans.conf eselect fontconfig enable 59-google-droid-sans-mono.conf eselect fontconfig enable 59-google-droid-serif.conf Next step is to clean fonts cache. fc-cache -rf That’s all. P.S. Also I had a problem displaying cyrillic characters....

February 19, 2017

Pure Bash script for IO usage monitoring

I had the need to implement pure bash solution for IO usage monitoring without any tools installed on OS, do this fast and accurately. After little reaserching about /sys/ filesystem the next script was born: #! /bin/bash SLEEP=0.01 declare -A ops=() for dev in /sys/block/*;do dev=${dev##*/} ops+=( [${dev}]=0 ) done for i in $(seq 1 100);do while read _ _ drive _ _ _ _ _ _ _ _ tasks _ _;do [ -n "${drive}" ] || continue case ${tasks} in 0|[!...

September 13, 2016

libgcc_s.so: cannot open shared object file

Как то вечером, я решил, что стоит лечь по-раньше спать. Подумал, что надо бы выспаться, все дела, но перед этим просто загляну в ноутбук, и тут началось. Для чего то я одновременно запустил rtorrent + emerge -vuDN @world. Стоит ли говорить, что система установлена на шпиндельном hdd, поверх которого работает ssd cache (Bcache). Видимо из-за нагрузки, ноутбук завис и ни на какие действия не реагировал. “Семь бед - один ресет”, подумал я и перезагрузил ноутбук....

April 29, 2016

Docker: Using docker with LVM Thin Pool

Docker is the nice tool for almost every use case in my sphere. It’s easy to use, it’s fast to build and deploy. Docker can be used with miscellaneous storage drivers such as btrfs, datamapper, overlayfs, aufs. A long time I was using docker with btrfs backend and everything seems to be nice, but when load on this server increased, corrupted layers are began to appear. It looks like build process in the next RUN step unable to find files from previous step....

February 8, 2016