This file contains 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
#!/bin/bash | |
docker_dev_home=$HOME/.docker-dev | |
project_name=${PWD##*/} | |
image_name=`echo $project_name | tr '[:upper:]' '[:lower:]'`-dev | |
docker create --name $image_name-volumes -v "/usr/local/bundle" -v "/root/.gradle" busybox || true |
This file contains 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
#!/bin/bash | |
docker_dev_home=$HOME/.docker-dev | |
project_name=${PWD##*/} | |
image_name=`echo $project_name | tr '[:upper:]' '[:lower:]'`-dev | |
docker create --name $image_name-volumes -v "/usr/local/bundle" -v "/root/.gradle" busybox || true |
This file contains 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 User < ApplicationRecord | |
has_many :posts | |
after_create :notify_moderator_by_sms_about_new_user | |
def deactivate! | |
puts "User deactivation started" | |
notify_moderator_by_sms_about_user_deactivation | |
self.update_attribute :role, :disabled |
This file contains 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 RSpec | |
module Fixtures | |
def fixture_file(name) | |
File.open(Rails.root.join('spec', 'fixtures', name)) | |
end | |
def fixture_content(name) | |
fixture_file(name).read | |
end |
This file contains 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
APP_RAKEFILE = Rails.root.join('Rakefile') | |
module Support | |
module RakeHelpers | |
extend ActiveSupport::Concern | |
def rake(task) | |
Rake::Task[task].reenable | |
Rake.application.invoke_task(task) | |
end |
This file contains 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
#!/usr/bin/env ruby | |
require "yaml" | |
require "ostruct" | |
class Service | |
attr_reader :compose, :name | |
def initialize(compose, name) | |
@name = name | |
@compose = compose |
This file contains 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
############################################# | |
# Example 1 | |
BookRepository.new.where(author_id: 23).order(:published_at).limit(8) | |
############################################# | |
# Example 2 |
This file contains 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
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
last_comment = `git log --pretty=oneline --abbrev-commit | head -n 1`.split("\n").first | |
def generate_message(n) | |
"changes ##{n} at #{Time.now.strftime "%H:%M:%S %a %d.%m.%y"}" | |
end | |
message = if last_comment.nil? |
This file contains 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
require 'rails_helper' | |
RSpec.describe MyController, type: :controller do | |
describe 'GET #index' do | |
render_views | |
include_context 'with admin authenticated' | |
it 'returns http success' do | |
get :index, params: params | |
expect(response).to have_http_status(:success) |
This file contains 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
User.limit(2).as_json | |
# User Load (2.0ms) SELECT "users".* FROM "users" LIMIT ? [["LIMIT", 2]] | |
#=> [{"id"=>1, "name"=>"Анна Терентьева", "created_at"=>Wed, 23 Jan 2019 21:47:37 UTC +00:00, "updated_at"=>Wed, 23 Jan 2019 21:47:37 UTC +00:00, "photo_url"=>nil, "nickname"=>nil, "first_name"=>nil, "last_name"=>nil, "about"=>nil, "birthday"=>nil}, {"id"=>2, "name"=>"Абрамова София", "created_at"=>Wed, 23 Jan 2019 21:47:38 UTC +00:00, "updated_at"=>Wed, 23 Jan 2019 21:47:38 UTC +00:00, "photo_url"=>nil, "nickname"=>nil, "first_name"=>nil, "last_name"=>nil, "about"=>nil, "birthday"=>nil}] | |
User.select(:id, :name).limit(2).as_json | |
# User Load (1.4ms) SELECT "users"."id", "users"."name" FROM "users" LIMIT ? [["LIMIT", 2]] | |
#=> [{"id"=>2, "name"=>"Абрамова София"}, {"id"=>20, "name"=>"Ангелина Нестерова"}] | |
User.select(:id, :name).where('start_at > ?', Time.now).limit(2).as_json |
NewerOlder