Skip to content

Instantly share code, notes, and snippets.


Michael Nikitochkin miry

View GitHub Profile
miry / Rakefile
Last active May 26, 2022
Rake task to run minitests in batches
View Rakefile
namespace :test do
desc "Parallel tests. Use TEST_WORKERS and TEST_WORKER_NUM." \
task :parallel do
workers = ENV.fetch("TEST_WORKERS", 1).to_i
worker = ENV.fetch("TEST_WORKER_NUM", 1).to_i
buckets = { [] }
# Fill the buckets
i = 0
miry /
Last active May 24, 2022
Run minitest tests in batches


It requires two environment variables:

  • TEST_WORKERS - Total number of workers or batches. It uses to identify a total number of batches, that would be run in parallel. Default: 1
  • TEST_WORKER_NUM - Current worker id. The value is between 1 and TEST_WORKERS
$ bundle exec rake test:parallel TEST_WORKERS=5 TEST_WORKER_NUM=1
miry /
Last active Apr 19, 2022
Crystal logger
# The `Logger` class provides a simple but sophisticated logging utility
# that you can use to output messages.
# Level verbosity from 0 - nothing and high with more traces.
# NOTE: Modified version of
# log =, level: 0)
class Logger
property level : Int8
miry / client.rb
Created Mar 14, 2022
Testing toxiproxy
View client.rb
require 'socket'
require 'timeout'
require "toxiproxy"
hostname = 'toxiproxy'
port = 16379
# Setup = "http://#{hostname}:8474"
miry /
Last active Jan 9, 2022
Organize photos in Synology
set -e
echo "Started: $(date)"
export MAGICK_TMPDIR=~/tmp
miry / Gemfile
Last active May 22, 2021
Sidekiq gracefull startup and shutdown in Kubernetes
View Gemfile
# frozen_string_literal: true
source ""
git_source(:github) { |repo_name| "{repo_name}" }
gem "sidekiq"
miry / .overcommit.yml
Last active May 8, 2021
Overcommit configuration for Crystal projects
View .overcommit.yml
# Sample configuration for to support Crystal projects
verify_signatures: false
# NOTE: LineEndings does not work with git versions < 2.x
# LineEndings:
# enabled: true
enabled: true
miry / materilize_view_migration.rb
Last active Mar 19, 2021
Example of Migration to create a table with cached results: Materialised view table
View materilize_view_migration.rb
class MaterialisedView < ActiveRecord::Migration[5.2]
def change
execute <<-SQL
CREATE TABLE mv_complex_query
COMMENT 'Updated every 5m by the mv_complex_query event'
SELECT * FROM big_table
execute <<-SQL
CREATE EVENT dump_mv_complex_query
miry / kube_clean_staging_deployment.yml
Created Feb 19, 2021
A Kube resources to automaticaly to remove old kube resources that were deployed to staging
View kube_clean_staging_deployment.yml
apiVersion: v1
kind: ServiceAccount
k8s-app: deployments-gc
name: deployments-gc
namespace: pnd-staging
miry / sidekiq_mem_killer.rb
Last active Feb 17, 2021
Gracefull sidekiq worker killer for kubenernetes clusters
View sidekiq_mem_killer.rb
require 'fileutils'
require 'open3'
# Usage:
# Sidekiq.configure_server do |config|
# config.server_middleware do |chain|
# chain.add MemoryKillerMiddleware if ENV['SIDEKIQ_MEMORY_KILLER_MAX_RSS']
# end