Skip to content

Instantly share code, notes, and snippets.

zinovyev / tt
Last active Mar 19, 2021
Create directory and file paths recursively
View tt
#! /usr/bin/env bash
# Create file or directory with parent directories
# For a more detalied description please take a look at:
Create files or directories with underlying path
Usage Examples:
zinovyev / kafka commands
Last active Feb 6, 2020
kafka base commands
View kafka commands
# Create a topic
kafka-topics --create --bootstrap-server localhost:9092 --topic test --partitions 1 --replication-factor 1
# List existend topics
kafka-topics --list --bootstrap-server localhost:9092
# Start a consumer
kafka-console-consumer --bootstrap-server localhost:9092 --topic test --from-beginning
# Start a producer
zinovyev / 20-intel.conf
Created Oct 17, 2019
Fix video tearing on Thinkpad t480 with Archlinux on board /etc/X11/xorg.conf.d/20-intel.conf
View 20-intel.conf
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "TearFree" "true"
Option "AccelMethod" "uxa"
zinovyev / convenient_hours.rb
Created Sep 4, 2019
Find out wich hours are convenient for the meeting for different people working from the defferent timezones: `ruby convenient_hours.rb +2 +3 +8`
View convenient_hours.rb
#! /usr/bin/env ruby
def format_time_zone(tz)
format('%06.2f', tz.gsub(/:/, '.')).gsub(/^0/, '+').gsub(/\./, ':')
TIMEZONES = { |tz| format_time_zone(tz) }.freeze
WORKING_HOURS = (7..19).freeze
zinovyev /
Created Apr 22, 2019
Generate new `secrets.yml` for rails
bundle exec rake secret | \
awk '{ print "development:\n secret_key_base: "$1"\nstaging:\n secret_key_base: "$1"\nproduction:\n secret_key_base: "$1 }' | \
cat > config/secrets.yml
zinovyev / webpacker_helper.rb
Created Mar 28, 2019
Rails helper for loading controller specific assets managed by Webpacker
View webpacker_helper.rb
module WebpackerHelper
def page_pack_tags
def application_pack_tags
join_paths(attempt_to_find(:stylesheet, 'application'),
attempt_to_find(:javascript, 'application'))
zinovyev / rpmtoarch
Created Nov 8, 2018
Convert rpm package to Archlinux package (makepkg -s command required afterwards)
View rpmtoarch
#!/usr/bin/env ruby
require "fileutils"
class Package
FILTERED_PARTS = %w[rpm x86_64]
INSTALL_SECTIONS = %w[pre_install post_install pre_upgrade
post_upgrade pre_remove post_remove].freeze
zinovyev / Makefile
Last active Nov 5, 2018
A Makefile to deploy docker wrapped ROR app to a VPS
View Makefile
RAILS_ENV := "development"
DOCKER_CMD := "bundle exec rails s -b -p 3000"
PROJECT := $(shell basename ${PWD})
TIMESTAMP := $(shell /bin/date +%Y%m%d%H%M%S)
IMAGE_NAME := "${PROJECT}:latest"
APP_PATH := "/opt/apps/${PROJECT}"
zinovyev / htpasswd
Created Sep 30, 2018
Save it to excutable PATH and use command similar to htpasswd without need to have Apache installed
View htpasswd
#!/usr/bin/env bash
printf "$USER:$(openssl passwd -crypt $PASSWORD)\n" >> $HTPASSWD
zinovyev /
Created Sep 28, 2018
Output docker stats as json
docker stats --no-stream --no-trunc --format '{ "container": "{{ .Container }}", "name": "{{ .Name }}", "id": "{{ .ID }}", "cpu_perc": "{{ .CPUPerc }}", "mem_usage": "{{ .MemUsage }}", "net_io": "{{ .NetIO }}", "block_io": "{{ .BlockIO }}", "mem_perc": "{{ .MemPerc }}", "pids": "{{ .PIDs }}" }'