Skip to content

Instantly share code, notes, and snippets.

@salkar
salkar / Timezones for Russian regions
Created December 11, 2014 13:20
Timezones for Russian regions (Таймзоны для российских регионов)
[
["Адыгея Республика", "Europe/Moscow"],
["Алтай Республика", "Asia/Omsk"],
["Алтайский Край", "Asia/Omsk"],
["Амурская Область", "Asia/Yakutsk"],
["Астраханская Область", "Europe/Volgograd"],
["Байконур Город", "Asia/Qyzylorda"],
["Белгородская Область", "Europe/Moscow"],
["Брянская Область", "Europe/Moscow"],
["Владимирская Область", "Europe/Moscow"],
@salkar
salkar / Ruby on Rails (Devise): Return back after sign in if it is possible
Last active August 29, 2015 14:09
Ruby on Rails: Return back if it is possible
To after_sign_in_path_for(resource) in ApplicationController
if request.env['HTTP_REFERER']
begin
route_params = Rails.application.routes.recognize_path(URI(request.referrer).path, {method: :get})
if route_params[:controller].include?('devise')
root_path
else
request.env['HTTP_REFERER']
end
@salkar
salkar / Concern sample
Last active August 29, 2015 14:09
Concern sample
module ConcernName
extend ActiveSupport::Concern
included do
# Object methods go here
end
module ClassMethods
# Class methods go here
end
.twitter-typeahead {
display: block !important;
}
.twitter-typeahead .tt-query,
.twitter-typeahead .tt-hint {
margin-bottom: 0;
}
.tt-hint {
color: #999;
}
@salkar
salkar / Devise user soft deletion
Last active August 29, 2015 14:03
Rails: Devise user soft deletion with custom error on sign in.
1. Add deleted_at column to User model.
2. Add to User model:
def soft_delete
update_attribute(:deleted_at, Time.current)
end
def active_for_authentication?
super && !self.deleted_at
end