This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Makefile | |
SHELL := /bin/zsh # could be changed to your shell | |
# all tasks should be added here, otherwise Make tries to create the folder with the same name and skip the task if folder exists | |
.PHONY: env db console stop prepare test yarn front | |
dev: env db server | |
prepare: env db yarn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# README | |
## Installation | |
It's a standard Rails application. It can be installed with: | |
``` | |
bundle | |
``` | |
The application doesn't use database, so you don't have to initialize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Обработка ошибок через возвращаемые параметры | |
class MyServiceObject | |
def self.call(params) | |
response = SomeApi.call(params) | |
if response.code == 500 | |
# Если api ответил некорректно то возвращаем ошибку | |
# (тут всего один метод, но если их будет много, то придется возвращать по цепочке) | |
{ status: 'failed', messages: 'Api error!' } | |
else | |
{ status: 'OK', data: response.body } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Алгоритмы: | |
1) Стивен Скиена "Алгоритмы. Руководство по разработке" | |
2) Томас Кормен "Алгоритмы. Построение и анализ" | |
3) Дональд Кнут "Искусство программирования" (никто в реальности не читал этот многотомный труд целиком, но в любой подборке по алгоритмам он обязан быть) | |
Общее: | |
1) Род Хаггарти "Дискретная математика для программистов" | |
2) Керниган, Ритчи "Язык программирования С" - для общего понимания принципов программирования | |
3) Дж. Андресон "Дискретная математика и комбинаторика" | |
4) Романовский И.В. "Дискретный анализ" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Resourceable | |
extend ActiveSupport::Concern | |
included do | |
helper_method :resource, :resources, :resource_class | |
end | |
def index; end | |
def show; end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PrintLineService | |
def initialize(context) | |
@context = context | |
end | |
def call | |
puts @context.line | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"AdvancedNewFile", | |
"Alignment", | |
"All Autocomplete", | |
"BracketHighlighter", | |
"CJSX Syntax", | |
"Colorsublime", | |
"ESLint", | |
"FileDiffs", | |
"Gist", | |
"GitSavvy", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# В целомс логическими операторами все просто, они позволяют составить сложное условие, результатом которого будет либо true, либо false. | |
# После чего это суловие можно использовать в условном операторе if или unless. | |
# Есть только одна тонкость, у операторов &&, ||, ! и ^ есть синонимы and, or, not и xor. Но у синонимов существенно меньше приоритет при выполнении. | |
# Поэтому их лучше не использовать, что бы не было путаницы в порядке выполнения операций в логическом выражении. | |
# Что касается решения задачи, возможны два варианта: | |
# Сделать несколько циклов: | |
array = [1,2,3,4,5,6,7,8,9,0] | |
for i in 0..array.length | |
if array[i].even? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[2] pry(main)> Product.last(10).map{|p| p.variants}.flatten | |
Product Load (1.1ms) SELECT "products".* FROM "products" ORDER BY "products"."id" DESC LIMIT 10 | |
Variant Load (96.5ms) SELECT "variants".* FROM "variants" WHERE "variants"."nomenclature_id" = 247664 AND "variants"."archived_at" IS NULL ORDER BY order_weight [["nomenclature_id", 247664]] | |
Variant Load (0.6ms) SELECT "variants".* FROM "variants" WHERE "variants"."nomenclature_id" = 247665 AND "variants"."archived_at" IS NULL ORDER BY order_weight [["nomenclature_id", 247665]] | |
Variant Load (0.3ms) SELECT "variants".* FROM "variants" WHERE "variants"."nomenclature_id" = 247666 AND "variants"."archived_at" IS NULL ORDER BY order_weight [["nomenclature_id", 247666]] | |
Variant Load (0.6ms) SELECT "variants".* FROM "variants" WHERE "variants"."nomenclature_id" = 247667 AND "variants"."archived_at" IS NULL ORDER BY order_weight [["nomenclature_id", 247667]] | |
Variant Load (0.5ms) SELECT "variants".* FROM "variants" WHERE "variants"."nome |