Skip to content

Instantly share code, notes, and snippets.


Viacheslav Ptsarev leemour

View GitHub Profile
leemour / basic_query_stats.sql
Last active Jan 12, 2022
PostgreSQL pg_stat_statements detailed output for query performance analysis and optimization
View basic_query_stats.sql
c.reltuples AS num_rows,
pg_size_pretty(pg_relation_size(quote_ident(t.tablename)::text)) AS table_size,
pg_size_pretty(pg_relation_size(quote_ident(indexrelname)::text)) AS index_size,
pg_relation_size(quote_ident(indexrelname)) as index_size_bytes,
CASE WHEN indisunique THEN 'Y'
leemour / sidekiq_monitoring
Created Aug 10, 2021 — forked from ngsmrk/sidekiq_monitoring
Sidekiq queue checking via rails console
View sidekiq_monitoring
stats =
leemour /
Created Mar 29, 2021 — forked from wojteklu/
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.

General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

leemour /
Created Aug 2, 2019
Rubocop run on only changed files
git diff --staged --name-only | xargs rubocop -a
leemour /
Last active Oct 16, 2020
Install and Uninstall (remove) Amazon Workspaces on Linux (Ubuntu 18.04 LTS 64-bit) Wine (Wine64)
sudo apt-get --purge remove wine
sudo apt-get purge wine* ; sudo dpkg --purge wine*
sudo apt-get purge wine64 ; sudo dpkg --purge wine64
sudo apt-get autoclean
sudo apt-get clean
sudo apt-get autoremove
cd $HOME
rm -r .wine
leemour / app.conf
Last active Jan 16, 2019
Monit with Puma, Sidekiq, Nginx, PostgreSQL, Disk space and Memory limits, using rbenv and nvm
View app.conf
# /etc/monit/conf.d/app
set daemon 30 with start delay 60
set log "/srv/www/app/shared/log/monit.log" # syslog facility log_daemon
set httpd port 2812
allow localhost
allow login:password
# with ssl {
# pemfile: /etc/ssl/certs/app_com.pem
# }
leemour / monit-and-gmail
Last active Jan 16, 2019 — forked from jcdarwin/monit-and-gmail
How to allow monit to use gmail as a smtp relay to send out alert emails
View monit-and-gmail
# visit and click to allow access
# edit /etc/monit/monitrc to include the following
set mailserver port 587
username "" password "whatever"
using tls
with timeout 30 seconds
# run the following to validate access
leemour / spree_carrierwave.rb
Created Jan 15, 2019
Spree Carrierwave replacement
View spree_carrierwave.rb
# app/models/spree/image.rb
module Spree
class Image < Asset
mount_uploader :attachment, Spree::ImageUploader,
mount_on: :attachment_file_name
validates :attachment, presence: true
leemour / format_ruby_hash.rb
Last active Jan 11, 2019
Format Ruby hash with left indent and awesome print
View format_ruby_hash.rb
# add `gem 'awesome_print` to Gemfile
rails c
# cl =
# hash = "Aberrant Researcher // Perfected Form").body[:data].first
ap hash, ruby19_syntax: true, index: false, indent: 2
# Copy and paste output into
leemour /
Created Dec 14, 2018
Ubuntu network stat check ports listen
# sudo apt install net-tools
sudo netstat -ntlp | grep LISTEN