psql -h <hostname> -U <user> <db> # db is optional
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
find /usr/local/Cellar | grep bin/ > ./usr_bin_local | |
ruby -ne "s=\$_; p=s.match(/\/bin\/(.+)/); b=p[1] unless p.nil?; cmd=%Q(ln -s #{s.chomp} /usr/local/bin/#{b});`#{cmd}`" ./usr_bin_local |
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
ActiveAdmin.register Event do | |
#Menu display index | |
menu :priority => 1 | |
#Scopes | |
scope :all | |
scope :pending | |
scope :approved | |
scope :rejected | |
scope :cancelled |
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 RecountMediamapService | |
def initialize(task) | |
@task = task | |
@comparisons_ids = Film.where.not(kinopoisk_rate: nil).where.not(kinopoisk_rate: 0).where('kinopoisk_num > 10').order(year: :desc, kinopoisk_rate: :desc, kinopoisk_num: :desc).limit(20000).pluck(:id) | |
@film = Film.includes(:genres, :subgenres, :countries, :tags, :people).find(@task.task.to_i) | |
end | |
def recount | |
begin | |
kbs = {} |
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/routes.rb | |
YandexKassaIntegration::Application.routes.draw do | |
# ... | |
scope '/yandex_kassa' do | |
controller 'yandex_kassa', constraints: { subdomain: 'ssl' } do | |
post :check | |
post :aviso | |
get :success | |
get :fail |
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
Ряд моментов Вы уже сделали, но я все равно их опишу для полноты списка. | |
1. Создать отдельного пользователя и хороший пароль на sudo. Не использовать больше root напрямую. Совсем. | |
2. SSH. Отключаем метод аутентификации по паролю. Если Вам не нужны другие методы, то их тоже можно отключить, оставив только publickey. Отключаем возможность аутентификации root'ом. Включаем использование только 2й версии SSH протокола. | |
3. Устанавливаем Fail2Ban и настраиваем чтобы после нескольких неуспешных попыток подключения по SSH банило по IP на длительное время. Кол-во попыток и время бана можно тюнить в меру своей паранойи. У меня, например, банит на час после 2х неуспешных попыток. | |
4. Iptables. Действуем по принципу "запрещено все, что не разрешено". Запрещаем по умолчанию весь INPUT и FORWARD трафик снаружи. Открываем на INPUT'е 22 порт. В дальнейшем открываем порты/forwarding по мере необходимости. Если у нас предполагаются сервисы на соседних серверах нужные только для внутренней коммуникации (Memcached, Redis, и т. |
####sessions
tmux new -s session_name # new session by name
tmux attach -t session_name # attach session by name (you can also use a instead of attach)
tmux switch -t session_name # switch session by name (you can also use a instead of attach)
tmux list-sessions # list existing sessions
bind-key : new -s session_name # new session from within a session
// detach
tmux detach # detach currently attached session
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
gem 'traceroute' # Checks for undefined routes and unreachable actions. | |
gem 'bullet' # Checks for query optimizations. | |
gem 'rails_best_practices' # Checks for code optimization. | |
gem 'rubycritic' # Checks for code optimization. | |
gem 'sandi_meter' # Checks for compliance to Sandi Metz's rules for developers. | |
gem 'simplecov' #Enables coverage analysis of code. | |
gem 'overcommit' # Git coomit hooks | |
gem 'rubocop' # Show me errors in code style | |
gem 'rack-mini-profiler' # Show me slow code | |
gem 'brakeman' # Security inspector |