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
@georgiybykov
georgiybykov / alias_matchers.md
Created December 16, 2020 17:22 — 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

How to run examples:

  1. Run $ createdb nplusonedb to create DB
  2. Run specs $ rspec demo.rb
@georgiybykov
georgiybykov / heroku_pg_db_reset.md
Last active January 15, 2021 16:41
How to reset PostgreSQL database on Heroku?

How to reset PostgreSQL database on Heroku?

  • Step 1: heroku restart
  • Step 2: heroku pg:reset DATABASE (do not change the DATABASE)
  • Step 3: heroku run rails db:migrate
  • Step 4: heroku run rails db:seed

Note

If you have more than one remote repository, then append in the end of each command --remote [name_of_the_remote] like this:

@georgiybykov
georgiybykov / .rubocop.yml
Created March 2, 2021 13:43
Rubocop config file
require:
- rubocop-performance
- rubocop-rails
- rubocop-rspec
AllCops:
TargetRubyVersion: 2.7.2
NewCops: enable
Exclude:
- bin/**/*
@georgiybykov
georgiybykov / cors.json
Last active March 17, 2021 09:47
Simple cross-origin resource sharing (CORS) for AWS S3
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET"
],
"AllowedOrigins": [
"*"
" vim-bootstrap
"*****************************************************************************
"" Vim-PLug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
let g:vim_bootstrap_langs = "elixir,erlang,html,javascript,ruby"
let g:vim_bootstrap_editor = "nvim" " nvim or vim
Handlebars is a semantic web template system, started by Yehuda Katz in 2010.
Handlebars.js is a superset of Mustache, and can render Mustache templates in addition to Handlebars templates.
More: http://handlebarsjs.com/
1. Expressions.
1.1 Basic usage.
@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.
  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 / 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'