Skip to content

Instantly share code, notes, and snippets.

View leemour's full-sized avatar

Viacheslav Ptsarev leemour

View GitHub Profile
@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 / 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

@leemour
leemour / monit-and-gmail
Last active January 16, 2019 12:47 — forked from jcdarwin/monit-and-gmail
How to allow monit to use gmail as a smtp relay to send out alert emails
# visit https://accounts.google.com/DisplayUnlockCaptcha and click to allow access
# edit /etc/monit/monitrc to include the following
set mailserver smtp.gmail.com port 587
username "whoever@gmail.com" password "whatever"
using tls
with timeout 30 seconds
# run the following to validate access
@leemour
leemour / changelog.rake
Last active November 28, 2018 14:40 — forked from cdesch/rake task
Ruby git CHANGELOG generator
namespace :changelog do
# simple rake task to output a changelog between two commits, tags ...
# output is formatted simply, commits are grouped under each author name
#
desc "generate changelog with nice clean output"
task :generate, :since_c, :until_c do |t, args|
since_c = args[:since_c] || `git tag | head -1`.chomp
until_c = args[:until_c] || `git rev-parse --short HEAD`
cmd=`git log --pretty='format:%ci::%an <%ae>::%s::%H' --after=#{since_c} --before=#{until_c}`
@leemour
leemour / s3_folder_upload.rb
Last active January 22, 2021 14:26 — 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 / where_is.rb
Created October 24, 2018 18:07 — forked from wtaysom/where_is.rb
A little Ruby module for finding the source location where class and methods are defined.
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
@leemour
leemour / sass_convert.sh
Last active June 27, 2018 02:44 — forked from bds/gist:2207826
Convert files from .scss to .sass
sass-convert -F scss -T sass application_styles.css.scss application_styles.css.sass
# If you want convert folder recursively
sass-convert -R scss_folder -F scss -T sass
@leemour
leemour / curry.rb
Created May 16, 2018 03:51 — forked from KamilLelonek/curry.rb
Currying functions in Ruby
[1] (pry) main: 0> add = -> (a, b) { a + b }
=> #<Proc:0x007ffde11d72c0@(pry):1 (lambda)>
# Call proc with two arguments
[2] (pry) main: 0> add.(1, 2)
=> 3
# Call proc with one argument
[3] (pry) main: 0> add.(1)
ArgumentError: wrong number of arguments (1 for 2)
@leemour
leemour / postgresql_configuration_on_ubuntu_for_rails.md
Created January 15, 2018 14:34 — forked from p1nox/postgresql_configuration_on_ubuntu_for_rails.md
PostgreSQL configuration without password on Ubuntu for Rails

Abstract

You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.

Install Postgre packages

  • postgresql
  • postgresql-client
  • libpq-dev
@leemour
leemour / routes.rb
Created April 27, 2017 09:00 — forked from kryzhovnik/routes.rb
Интеграция Яндекс.Кассы с Rails
# config/routes.rb
YandexKassaIntegration::Application.routes.draw do
# ...
scope '/yandex_kassa' do
controller 'yandex_kassa', constraints: { subdomain: 'ssl' } do
post :check
post :aviso
get :success
get :fail