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 Page | |
has_many :blocks, -> { ordered }, dependent: :destroy | |
attr_accessors :title | |
def visible_blocks | |
@visible_block ||= blocks.current_locale.map(&:blockable) | |
end | |
end | |
class Block |
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 TestCyrillic | |
class << self | |
def cyrillic?(string) | |
string[/\p{Cyrillic}/] | |
end | |
end | |
end | |
class String | |
def cyrillic? |
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
➜ local git:(master) tmux-new test | |
➜ local git:(master) tmux new-session -d test | |
sessions should be nested with care, unset $TMUX to force | |
➜ local git:(master) tmux new-session -dP test | |
sessions should be nested with care, unset $TMUX to force | |
➜ local git:(master) tmux new-session -S dotfiles -dP test | |
new-session: illegal option -- S | |
usage: new-session [-AdDP] [-c start-directory] [-F format] [-n window-name] [-s session-name] [-t target-session] [-x width] [-y height] [command] | |
➜ local git:(master) |
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
namespace :inquiries do | |
resources :combiners, only: [:create] | |
end | |
# supervise_inquiries_combiners_path | |
# /supervise/inquiries/combiners ! нет :inquiry_id | |
# supervise/inquiries/combiners#create | |
resources :inquiries do | |
resources :combiners |
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
# controllers/concerns/record_not_found.rb | |
# | |
# Redirects visitor up the restful route if record not found | |
# | |
# /articles/404 -> /articles/ -> / | |
module RecordNotFound | |
extend ActiveSupport::Concern | |
included do |
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
# db/seeds.rb | |
# | |
# https://gist.github.com/firedev/5d9cd290da97d3c131e3 | |
# | |
# Imports records from .yml files in db/seed/model.yml | |
def put_cycle | |
@r ||= %w(- \\ | /) | |
print((@r << @r.shift)[0]) | |
print "\b" |
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
# Hides Draper decorator inside the model and lazily decorates resources | |
# | |
# https://gist.github.com/firedev/7a82059b30a2157d4c56 | |
# | |
# model.rb: | |
# include Decorated | |
# | |
# Just make sure there are no overlapping method names in ModelDecorator | |
module Decorated |
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
# translit.rb | |
# | |
# https://gist.github.com/firedev/128521f9cc8d63eaff77 | |
# | |
# Converts russian strings to english translit | |
# | |
# Usage: | |
# | |
# Translit.(string) |
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/models/concerns/metable_model.rb | |
# | |
# https://gist.github.com/firedev/644b41967cf6c1c9d035 | |
# | |
# Usage: | |
# | |
# rails g migration addMetaToModel meta:string | |
# | |
# include MetableModel | |
# metable [:meta] [, :body] [, &block] |
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 ReadMarkable | |
extend ActiveSupport::Concern | |
included do | |
has_many :read_marks | |
def touch_read_at | |
update_column(:read_at, Time.now) | |
end |