Skip to content

Instantly share code, notes, and snippets.

View alexshagov's full-sized avatar
💭
I may be slow to respond.

Alexander Shagov alexshagov

💭
I may be slow to respond.
View GitHub Profile
@alexshagov
alexshagov / readme.md
Last active July 6, 2020 10:20
Spaceemacs setup for ruby development

Install GNU Emacs (26.3+)

brew install emacs && brew link emacs

Download the development branch

git clone -b develop https://github.com/syl20bnr/spacemacs ~/.emacs.d

Search configuration

@alexshagov
alexshagov / user_spec.rb
Created May 12, 2020 18:25
User spec sample for students
require 'rails_helper'
RSpec.describe User, type: :model do
subject { described_class.new(params) }
let(:params) do
{
name: 'John'
}
end
@alexshagov
alexshagov / database_changes_logger.rb
Created May 11, 2020 14:52
Ruby on Rails: database changes logger
# frozen_string_literal: true
### Usage
# Helps to understand how operation run affects the database state
# DatabaseChangesLogger.call(filename: 'output') { Operation.perform }
module DatabaseChangesLogger
EVENTS_TYPE = 'sql.active_record'
OPERATION_REGEX = /Update|Create/.freeze
@alexshagov
alexshagov / examples.rb
Created April 7, 2020 17:04
RSpec more examples
# ./spec/user_spec.rb
require_relative '../../lib/user.rb'
require 'ostruct'
RSpec.describe User do
subject { described_class.new(name: name, payment_service: payment_service) }
let(:name) { 'John Doe' }
let(:success_result) { true }
@alexshagov
alexshagov / examples.rb
Created April 3, 2020 07:10
RSpec basics examples
# homework.rb
class Homework
attr_reader :title, :content, :completed
def initialize(title:, content:)
@title = title
@content = content
@completed = false
end
@alexshagov
alexshagov / app.rb
Created March 24, 2020 21:30
Archive creator OOP draft
### lib/user_input.rb
class UserInput
class InvalidUserInput < StandardError; end
def initialize(input)
@input = input
end
def to_s
@alexshagov
alexshagov / script.rb
Created March 19, 2020 17:49
Archive creator
# frozen_string_literal: true
# CLI tool, accepts user input;
# Saves as txt file
# archives that txt file
require 'pry'
require 'zip'
USER_INPUT_FILENAME = 'user_input.txt'
@alexshagov
alexshagov / .envrc
Created July 30, 2019 13:40
Project-specific NVM using direnv
nvmrc=~/.nvm/nvm.sh
if [ -e $nvmrc ]; then
source $nvmrc
nvm use
fi
PATH_add node_modules/.bin
@alexshagov
alexshagov / gtags-ruby-emacs.md
Last active June 27, 2020 08:49
How to generate gtags for Ruby project

How to generate gtags for Ruby project

generate gtags.files list consisting only from .rb files

find . -name "*.rb" > gtags.files

generate *TAGS files

gtags --gtagslabel=new-ctags
version: '3'
services:
db:
image: postgres
volumes:
- db-data:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
- POSTGRES_USER=username