Skip to content

Instantly share code, notes, and snippets.

View burik666's full-sized avatar
🤘
\m/

Andrey Burov burik666

🤘
\m/
View GitHub Profile
@burik666
burik666 / .bashrc
Last active April 12, 2021 02:13
bash: print command execution time and exit code.
function __timer_now {
printf %s "${EPOCHREALTIME//\./}"
}
function __timer_start {
timer_start=${timer_start:-$(__timer_now)}
}
function __timer_stop {
local delta_us=$(($(__timer_now) - timer_start))
@burik666
burik666 / golangci-lint.sh
Created November 9, 2020 09:58
Use golangci-lint in docker like locally installed.
#!/bin/bash
CACHE_DIR="/tmp/golint-docker-$USER"
DEFAULT_CONFIG="$HOME/.golangci.yml"
mkdir -p "$CACHE_DIR"
if [ -f "$DEFAULT_CONFIG" ]; then
n=$(basename "$DEFAULT_CONFIG")
config_file=("-v" "${DEFAULT_CONFIG}:/$n")
fi
@burik666
burik666 / xterm.sh
Created April 7, 2019 07:12
Start a new terminal in the same directory (i3wm)
#!/bin/bash
filter="(bash|vi|mc)"
winpid=$(xprop -id $(xdotool getactivewindow) _NET_WM_PID|awk '{print $3}')
if [ -n "$winpid" ]; then
lpid=$(pstree -aApT ${winpid}|grep -E "\\-${filter},[0-9]+" -o|tail -n1|awk -F, '{print $2}')
if [ -n "${lpid}" ]; then
cd $(readlink /proc/${lpid}/cwd)
fi
fi
xterm &
@burik666
burik666 / telegram.py
Last active March 13, 2021 02:40
Simple python script for sending messages to telegram. (I use for zabbix)
#!/usr/bin/env python
import requests
import sys
token = 'YOUR_BOT_TOKEN_HERE'
msg = {
'chat_id': sys.argv[1],
'text': sys.argv[2],
"disable_web_page_preview":True,
@burik666
burik666 / crontab_wrapper.sh
Created June 5, 2018 11:07
crontab remove confirmation wrapper
#!/bin/bash
# alias crontab=/path/to/crontab_wrapper.sh
while getopts ":r" opt
do
case $opt in
r)
read -r -n 1 -p "Do really want to remove current crontab? [Y/n]" confirm
echo
if [ "$confirm" != "Y" ]; then
exit 1