# app/models/booking.rb
class Booking
include RailsAdmin::Booking
end
# app/models/concerns/rails_admin/booking.rb
module RailsAdmin::Booking
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
# | |
# RUN JUST ONCE | |
# | |
# Add a new directory in your Dropbox (or use an existing one) | |
mkdir -p ~/Dropbox/dotfiles | |
# move existing file to Dropbox | |
mv ~/.zshrc ~/Dropbox/dotfiles/zshrc | |
# oh-my-zsh |
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
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb | |
# Maps logical Rails types to MySQL-specific data types. | |
def type_to_sql(type, limit = nil, precision = nil, scale = nil) | |
return super unless type.to_s == 'integer' | |
case limit | |
when 1; 'tinyint' | |
when 2; 'smallint' | |
when 3; 'mediumint' | |
when nil, 4, 11; 'int(11)' # compatibility with MySQL default |
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 bash | |
uninstall() { | |
list=`gem list --no-versions` | |
for gem in $list; do | |
gem uninstall $gem -aIx | |
done | |
gem list | |
gem install bundler | |
} |
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
def convert_to_brightness_value(background_hex_color) | |
(background_hex_color.scan(/../).map {|color| color.hex}).sum | |
end | |
def contrasting_text_color(background_hex_color) | |
convert_to_brightness_value(background_hex_color) > 382.5 ? '#000' : '#fff' | |
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
#config/initializers/carrierwave.rb | |
module CarrierWave | |
module MiniMagick | |
# Rotates the image based on the EXIF Orientation | |
def exif_rotation | |
manipulate! do |img| | |
img.auto_orient | |
img = yield(img) if block_given? | |
img | |
end |
#Деградация функциональности http://joxi.ru/DxXOU4wyTJCzLlQsA7o Есть фичи у проекта - есть критичные вещи, есть такие что можно пожертвовать чем-то При проектировании архитектуры нужно учесть возможные фоллбеки Все доп, фичи можно отключить или не использовать в ситуации крайней нагрузки
#Масштабирование Нагрузка растет нужно мастабироваться
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
# .rubocop-rails.yml |
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
// Dependencies: react-router, qs | |
// | |
// Usage: | |
// | |
// const [taskState, setTaskState] = useQueryState("state"); | |
// | |
// setTaskState("new") => /tasks?state=new | |
import { useCallback } from "react" | |
import { useHistory, useLocation } from "react-router-dom" |
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
# /spec/support/request_helpers.rb | |
# | |
# Include helper inside rails_helper.rb file: | |
# | |
# config.include RequestHelpers, type: :request | |
# | |
module RequestHelpers | |
# | |
# response body: {"data": { "id": 1 }} | |
# |
OlderNewer