Skip to content

Instantly share code, notes, and snippets.

Avatar
🇩🇪

Michael Nikitochkin miry

🇩🇪
View GitHub Profile
@miry
miry / Gemfile
Last active May 22, 2021
Sidekiq gracefull startup and shutdown in Kubernetes
View Gemfile
# 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
Overcommit configuration for Crystal projects
View .overcommit.yml
# 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 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
SQL
execute <<-SQL
CREATE EVENT dump_mv_complex_query
@miry
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
metadata:
labels:
k8s-app: deployments-gc
name: deployments-gc
namespace: pnd-staging
@miry
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
@miry
miry / README.org
Last active Nov 13, 2020
Spacemacs layer OSX fast open file by name to add CMD+P to find a file by name
View README.org
View duplication_in_block.rb
def method_one(&block)
puts "method_one"
block.call
end
def method_two(&block)
puts "method_two"
block.call
end
View usage.sh
#!/usr/bin/env bash
medup -u miry -d ./posts/miry # Articles written by miry
medup -u miry -d ./posts/favorites -r # Favorite articles of miry (clapped one)
medup -u miry -d ./posts/miry --update # Update existing exported posts with latest versions of posts
medup https://medium.com/notes-and-tips-in-full-stack-development/medup-backups-articles-8bf90179b094 # Export single article
medup https://jtway.co/git-minimum-for-effective-project-development-841a0b865ef0 # Export signle article with custom domain
@miry
miry / MOVIE COMPRESSION.md
Last active Aug 12, 2020
Automate compressing of video files from GoPro
@miry
miry / 01_dynamodb_get_all.rb
Last active May 6, 2020
Sample to get all items from DynamoDB table
View 01_dynamodb_get_all.rb
# frozen_string_literal: true
require 'aws-sdk-dynamodb'
require 'hirb'
# NOTICE: Authorize via https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
dynamodb = Aws::DynamoDB::Client.new
scan_opts = { table_name: '<TABLE_NAME>' }
items = []