Skip to content

Instantly share code, notes, and snippets.

View leemour's full-sized avatar

Viacheslav Ptsarev leemour

  • Blinkist
  • Valencia, Spain
View GitHub Profile
@leemour
leemour / alias_matchers.md
Created January 2, 2025 23:35 — forked from JunichiIto/alias_matchers.md
List of alias matchers in RSpec 3

This list is based on aliases_spec.rb.

You can see also Module: RSpec::Matchers API.

matcher aliased to description
a_truthy_value be_truthy a truthy value
a_falsey_value be_falsey a falsey value
be_falsy be_falsey be falsy
a_falsy_value be_falsey a falsy value
@leemour
leemour / s3_folder_upload.rb
Last active November 20, 2024 16:58 — forked from fleveque/s3_folder_upload.rb
Upload folder to S3 recursively with ruby, multi threads and aws-sdk v3 gem
# frozen_string_literal: true
require 'rubygems'
require 'aws-sdk'
module S3
# Upload directory recursively to S3
class DirectoryUpload
attr_reader :folder_path, :bucket, :include_folder
attr_accessor :files
@leemour
leemour / basic_query_stats.sql
Last active May 1, 2024 14:04
PostgreSQL pg_stat_statements detailed output for query performance analysis and optimization
SELECT
t.tablename,
foo.indexname,
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'
ELSE 'N'
END AS UNIQUE,
@leemour
leemour / rails_new.sh
Last active January 2, 2024 21:26
Rails new template generation
rails _5.2.8_ new dummy \
--skip-action-text --skip-active-storage --skip-action-cable --skip-active-job --skip-active-record --skip-git \
--skip-sprockets --database=mysql --skip-javascript --skip-coffee --skip-turbolinks --skip-test --skip-system-test --no-skip-active-record
@leemour
leemour / workspace_ubuntu_install.md
Last active November 20, 2023 16:55
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
leemour / Zsh & theme
Last active April 12, 2023 08:53
Zsh installation and Agnoster theme settings
# Railscast
http://railscasts.com/episodes/308-oh-my-zsh
# Install Zsh
sudo apt-get update && sudo apt-get install zsh
# Install Oh-my-zsh
wget –no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O – | sh
# Make ZSH default shell
@leemour
leemour / sidekiq_monitoring
Created August 10, 2021 09:33 — forked from ngsmrk/sidekiq_monitoring
Sidekiq queue checking via rails console
stats = Sidekiq::Stats.new
stats.queues
stats.enqueued
stats.processed
stats.failed
@leemour
leemour / carrierwave_selectel.rb
Last active July 1, 2021 10:37
Carrierwave integration with Selectel using fog-openstack
CarrierWave.configure do |config|
if Rails.env.test? || Rails.env.cucumber?
config.storage = :file
config.enable_processing = false
else
config.asset_host = Rails.application.secrets.asset_host
config.fog_provider = 'fog/openstack'
config.fog_credentials = {
provider: 'OpenStack',
openstack_auth_url: 'https://api.selcdn.ru/v3',
@leemour
leemour / iptablesrc
Created November 23, 2015 12:45
Iptables redirect port 3000 to port 80
# sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000
# sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 3000
sudo iptables -t nat -A OUTPUT -d localhost -p tcp --dport 80 -j REDIRECT --to-port 3000
# Save iptables to file
sudo bash -c "iptables-save -c > /etc/iptablesrc"
# Apply localhost redirect saved in iptablesrc on system start
# sudo bash -c "iptables-restore < /etc/iptablesrc"
@leemour
leemour / clean_code.md
Created March 29, 2021 18:19 — forked from wojteklu/clean_code.md
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