Skip to content

Instantly share code, notes, and snippets.

View leemour's full-sized avatar

Viacheslav Ptsarev leemour

View GitHub Profile
@leemour
leemour / Assets Precompile
Last active December 16, 2015 13:19
For production, using RVM
# if using ActiveAdmin
# Add activeadmin assets into precompiling by adding the following line into your config/environments/production.rb:
# config.assets.precompile += %w(active_admin.css active_admin/print.css active_admin.js)
rvmsudo RAILS_ENV=production bundle exec rake assets:precompile
sudo git add .
# config.serve_static_assets = true may be necessary
class Float
def approx_equal?(other,threshold)
if (self-other).abs<threshold # "<" not exact either ;-)
return true
else
return false
end
end
end
@leemour
leemour / FontFix RubyMine
Last active October 6, 2018 06:42
Fixing font anti-aliasing for Ubuntu.
# Change Java Runtime:
sudo update-alternatives --config java
# Delete Open-JDK
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
# Change fonts - remove hinting:
http://askubuntu.com/questions/32624/ugly-fonts-in-netbeans-how-can-i-make-it-use-the-system-font
# Change RubyMine AntiAliasing first:
@leemour
leemour / Devise HAML views
Created May 26, 2013 12:43
Convert generated Devise ERB views to HAML
rails g devise:views
gem install html2haml
for file in app/views/devise/**/*.erb; do html2haml -e $file ${file%erb}haml && rm $file; done
gem install haml2slim
for file in app/views/devise/**/*.haml; do haml2slim $file ${file%haml}slim && rm $file; done
ru:
devise:
confirmations:
confirmed: "Ваша учётная запись подтверждена. Теперь вы вошли в систему."
send_instructions: "В течение нескольких минут вы получите письмо с инструкциями по подтверждению вашей учётной записи."
send_paranoid_instructions: "Если ваш адрес email есть в нашей базе данных, то в течение нескольких минут вы получите письмо с инструкциями по подтверждению вашей учётной записи."
failure:
already_authenticated: "Вы уже вошли в систему."
inactive: "Ваша учётная запись ещё не активирована."
invalid: "Неверный адрес email или пароль."
@leemour
leemour / Heroku copy DB
Last active December 17, 2015 18:29
Copying development Sqlite DB to Heroku (Postgresql)
# Чтобы избежать ошибки Taps Server Error: PGError: ERROR: time zone displacement out of range надо изменить версию Ruby
rvm use 1.9.2-p320
heroku db:push
# OR
heroku db:push sqlite://db/development.db
@leemour
leemour / application_controller.rb
Created May 31, 2013 16:48 — forked from gonzedge/application_controller.rb
Rails 404 and 500 error pages
class ApplicationController < ActionController::Base
# ...
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, with: lambda { |exception| render_error 500, exception }
rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception }
end
private
def render_error(status, exception)
@leemour
leemour / Zsh & theme
Last active April 12, 2023 08:53
Zsh installation and Agnoster theme settings
# Railscast
http://railscasts.com/episodes/308-oh-my-zsh
# Install Zsh
sudo apt-get update && sudo apt-get install zsh
# Install Oh-my-zsh
wget –no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O – | sh
# Make ZSH default shell
#!/usr/bin/env rvm 1.9.3@mygemset do ruby
# A formtastic input which incorporates carrierwave uploader functionality.
#
# Intelligently adds the cache field, displays and links to the current
# value if there is one, adds a class to the wrapper when replacing an
# existing value, allows removing an existing value with the checkbox
# taking into account validation requirements.
#
# There are several options:
#
# * Toggle the replacement field with `replaceable: true/false`.