Skip to content

Instantly share code, notes, and snippets.

View miry's full-sized avatar

Michael Nikitochkin miry

View GitHub Profile
@miry
miry / convert.sh
Created August 8, 2024 06:37
Convert HEIC to JPG in folder
for i in *.HEIC ; do heif-convert "$i" "${i%.*}.jpg" ; mv "$i" "$i.bak" ; done
@miry
miry / Rakefile
Last active May 26, 2022 18:48
Rake task to run minitests in batches
namespace :test do
desc "Parallel tests. Use TEST_WORKERS and TEST_WORKER_NUM." \
"TEST_WORKER_NUM in range from 1..TEST_WORKERS"
task :parallel do
workers = ENV.fetch("TEST_WORKERS", 1).to_i
worker = ENV.fetch("TEST_WORKER_NUM", 1).to_i
buckets = Array.new(workers) { [] }
# Fill the buckets
i = 0
@miry
miry / README.md
Last active May 24, 2022 10:07
Run minitest tests in batches

Usage

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
miry / logger.cr
Last active April 19, 2022 22:49
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 https://github.com/crystal-lang/logger.cr/blob/10dc2ef847e2f662abafb75f9e7dff21509adb85/src/logger.cr
#
# log = Logger.new(STDOUT, level: 0)
class Logger
property level : Int8
@miry
miry / client.rb
Created March 14, 2022 11:11
Testing toxiproxy
require 'socket'
require 'timeout'
require "toxiproxy"
hostname = 'toxiproxy'
port = 16379
# Setup
Toxiproxy.host = "http://#{hostname}:8474"
@miry
miry / import_photos.sh
Last active January 9, 2022 17:25
Organize photos in Synology
#!/bin/bash
set -e
echo "Started: $(date)"
export MAGICK_TMPDIR=~/tmp
mkdir -p $MAGICK_TMPDIR
orgdir="/var/services/homes/miry/work/cloned_photos"
@miry
miry / Gemfile
Last active August 10, 2024 12:40
Sidekiq gracefull startup and shutdown in Kubernetes
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
gem "sidekiq"
@miry
miry / .overcommit.yml
Last active May 8, 2021 17:32
Overcommit configuration for Crystal projects
# Sample configuration for https://github.com/sds/overcommit to support Crystal projects
---
verify_signatures: false
PreCommit:
# NOTE: LineEndings does not work with git versions < 2.x
# LineEndings:
# enabled: true
YamlLint:
enabled: true
@miry
miry / materilize_view_migration.rb
Last active March 19, 2021 07:51
Example of Migration to create a table with cached results: Materialised view table
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
SQL
execute <<-SQL
CREATE EVENT dump_mv_complex_query
@miry
miry / kube_clean_staging_deployment.yml
Created February 19, 2021 12:11
A Kube resources to automaticaly to remove old kube resources that were deployed to staging
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-app: deployments-gc
name: deployments-gc
namespace: pnd-staging