Skip to content

Instantly share code, notes, and snippets.

View valdemarua's full-sized avatar

Volodymyr valdemarua

View GitHub Profile

#Деградация функциональности http://joxi.ru/DxXOU4wyTJCzLlQsA7o Есть фичи у проекта - есть критичные вещи, есть такие что можно пожертвовать чем-то При проектировании архитектуры нужно учесть возможные фоллбеки Все доп, фичи можно отключить или не использовать в ситуации крайней нагрузки

#Масштабирование Нагрузка растет нужно мастабироваться

@valdemarua
valdemarua / RailsAdmin.md
Created April 25, 2018 08:25 — forked from stevenyap/RailsAdmin.md
Rails Admin

Extracting model configuration

# app/models/booking.rb
class Booking
  include RailsAdmin::Booking
end

# app/models/concerns/rails_admin/booking.rb
module RailsAdmin::Booking
@valdemarua
valdemarua / carrierwave.rb
Created October 23, 2017 16:41 — forked from iqbalhasnan/carrierwave.rb
carrierwave mini_magick image processing - quality, strip, exif rotation, gaussian blur, interlace
#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
@valdemarua
valdemarua / contrasting_text_color.rb
Created October 10, 2017 14:07 — forked from charliepark/contrasting_text_color.rb
calculate contrast color in Ruby
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
@valdemarua
valdemarua / uninstall_gems.sh
Created May 17, 2016 12:08 — forked from IanVaughan/uninstall_gems.sh
Uninstall all rbenv gems
#!/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
}
@valdemarua
valdemarua / ar_migrate.rb
Created December 20, 2015 00:08 — forked from icyleaf/ar_migrate.rb
ActiveRecord type of integer (tinyint, smallint, mediumint, int, bigint)
# 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
@valdemarua
valdemarua / ohmyzsh-dropbox-sync.sh
Last active January 5, 2022 04:55 — forked from robbyrussell/ohmyzsh-dropbox-sync.sh
Keep your @ohmyzsh ~/.zshrc in sync via dropbox
#
# 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