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
h3 = post.title | |
= raw post.content |
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
source 'https://rubygems.org' | |
ruby '2.3.1' | |
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' | |
gem 'rails', '~> 5.0.0' | |
# Use postgresql as the database for Active Record | |
gem 'pg', '~> 0.18' | |
# Use Puma as the app server | |
gem 'puma', '~> 3.0' | |
# Use SCSS for stylesheets | |
gem 'sass-rails', '~> 5.0' |
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
# Задача: Программа получает ссылку на страницу, выбирает оттуда все ссылки которые найдет и выводит их на экран. | |
# Ограничения: программа должна получать ссылку от меня в интерактивном режиме (используя метод gets) | |
# Программа: | |
class Proga # создание класса "Программа" | |
puts "Please, input a web-site" # запрос у пользователя ссылки на сайт | |
link = gets.chomp # создание переменной link, в которую будет складываться ответ пользователя | |
puts "You enter #{link}" # вывести на экран значение переменной link |
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
PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump |
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
heroku pg:backups capture; | |
curl -o latest.dump `heroku pg:backups public-url`; | |
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U pguser -d blog_development latest.dump; |
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
# connecting select2 to the appropriate hooks: | |
# | |
# hard case: best_in_place's select | |
$ -> | |
# first, find the mount point | |
$('body').on 'best_in_place:activate', '.best_in_place', -> | |
# second, attach empty update() to `this` to screen the downstream calls | |
# which otherwise will cause an error |
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 Accessible | |
extend ActiveSupport::Concern | |
included do | |
has_many :accessibilities, as: :accessible, dependent: :destroy | |
has_many :roles, -> { uniq }, through: :accessibilities | |
scope :visible_to, ->(role_names) { | |
role_names = [role_names] if [String, Symbol].include?(role_names.class) | |
if role_names.include?(Role::ROOT_ROLE) | |
all |
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
require 'tire' | |
require 'nobrainer' | |
NoBrainer.connect 'rethinkdb://server/company' | |
class Employee | |
include NoBrainer::Document | |
field :name | |
field :title |
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
# lib/heroku_redirect.rb | |
class HerokuRedirect | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
request = Rack::Request.new(env) | |
unless request.host.starts_with?("www.") || request.host.starts_with?("start.") || request.host.starts_with?("crm.") || request.host.starts_with?("api.") || request.host.starts_with?("erp.") || request.host.include?("mydomain.com") || request.host.include?("staging.") | |
# puts 'redirecting to www' |
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
# config/environments/production.rb | |
# ... | |
config.middleware.use HerokuRedirect |
NewerOlder