Skip to content

Instantly share code, notes, and snippets.

View georgiybykov's full-sized avatar
💥
...creating a code

Georgiy Bykov georgiybykov

💥
...creating a code
  • Saint-Petersburg
View GitHub Profile
# frozen_string_literal: true
require 'docx'
module Docx
# docs
class Differences
class << self
# @param file_paths [Array<String>] ARGV with absolute files pathes
# @return [Array<Hash>]
@georgiybykov
georgiybykov / eager_load_config_for_environments.rb
Last active September 5, 2022 22:10
Eager Load configuration
# EagerLoad.configure.enabled = true
#
# EagerLoad.configure_for_environments do |env|
# env.development = false
# env.staging = true
# env.production = true
# end
#
# EagerLoad.enabled?
@georgiybykov
georgiybykov / explicit_locking.md
Last active March 29, 2022 22:37
SQL queries with transactions

1st console:

udatapp_development=# begin;
BEGIN

udatapp_development=# lock table users in access exclusive mode;
LOCK TABLE

udatapp_development=# 
@georgiybykov
georgiybykov / elixir.yml
Created November 24, 2021 21:37
GitHub Actions for Elixir (extended version with shared dependencies)
# .github/workflows/elixir.yml
---
name: build
on: [push, pull_request]
jobs:
dependencies:
runs-on: ubuntu-latest
@georgiybykov
georgiybykov / elixir.yml
Created November 24, 2021 21:35
GitHub Actions for Elixir
# .github/workflows/elixir.yml
---
name: build
on: [push, pull_request]
jobs:
all_jobs:
runs-on: ubuntu-latest
@georgiybykov
georgiybykov / qna.monit.rc
Last active October 3, 2021 03:48
nginx, unicorn, postgresql, redis, sidekiq, elasticsearch configs for monit
# /etc/monit/conf-enabled/qna.monit.rc
### Nginx ###
check process nginx with pidfile /run/nginx.pid
start program = "/usr/sbin/service nginx start"
stop program = "/usr/sbin/service nginx stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 65.108.50.164 port 80 protocol http
@georgiybykov
georgiybykov / Capfile
Created October 2, 2021 23:21
Unicorn configuration for deploying application to production with capistrano
# frozen_string_literal: true
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails'
@georgiybykov
georgiybykov / routes.rb
Created August 5, 2021 13:07
How to split routes to separate files for Rails App or Rails Engine
# config/routes.rb
# frozen_string_literal: true
MyApplication::Application.routes.draw do
draw_routes_for :v1
draw_routes_for :v2
draw_routes_for :v3
root to: 'projects#index'
  1. Add gem 'rails_12factor' to your Gemfile. This will add error logging and the ability for your app to serve static assets.
  2. bundle
  3. Run RAILS_ENV=production rake db:create db:migrate db:seed
  4. Run rake secret and copy the output
  5. From the command line: export SECRET_KEY_BASE=output-of-rake-secret
  6. To precompile your assets, run rake assets:precompile. This will create a folder public/assets that contains all of your assets.
  7. Run RAILS_ENV=production rails s and you should see your app.

Remember to clobber your assets (rake assets:clobber) and re-precompile (rake assets:precompile) if you make changes.

@georgiybykov
georgiybykov / redis_cheatsheet.bash
Last active April 17, 2021 16:26 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.