Skip to content

Instantly share code, notes, and snippets.

User.where('email !~* ?', '.+@.+\..+').ids
location ~* \.(jsgz|datagz|memgz|unity3dgz)$ {
add_header Content-Encoding gzip;
break;
}
@groony
groony / readme.txt
Last active March 21, 2017 14:03
estel instruction for developer
install docker-compose
cd ${your_project_path}
git submodule add https://github.com/Laradock/laradock.git
cd laradock
git checkout v4.20.0
rm nginx/sites/laravel-https.conf
open docker-compose.yml
find workspace: and find INSTALL_NODE and set it to true
@groony
groony / deadlock.log
Created March 22, 2017 10:04
deadlock
[[email protected] /var/www/shopper/ss/current/log]$ zcat production.log-20170321.gz | grep '2017-03-20T18:57:21.144275 #1282' -A 30
D, [2017-03-20T18:57:21.144275 #1282] DEBUG -- : [85d9fbfa-1539-48da-beba-b1c8d25ff5fc] (1.0ms) ROLLBACK
I, [2017-03-20T18:57:21.144523 #1282] INFO -- : [85d9fbfa-1539-48da-beba-b1c8d25ff5fc] Completed 500 Internal Server Error in 1059ms (ActiveRecord: 1032.1ms)
D, [2017-03-20T18:57:21.144579 #1282] DEBUG -- : [5b0994f6-e263-4a99-8e43-0c8d2ab20c85] Billing::Account Load (0.3ms) SELECT "billing_accounts".* FROM "billing_accounts" WHERE "billing_accounts"."owner_id" = $1 AND "billing_accounts"."owner_type" = $2 LIMIT 1 [["owner_id", 659], ["owner_type", "Promotion"]]
F, [2017-03-20T18:57:21.145696 #1282] FATAL -- : [85d9fbfa-1539-48da-beba-b1c8d25ff5fc]
ActiveRecord::StatementInvalid (PG::TRDeadlockDetected: ERROR: deadlock detected
ПОДРОБНОСТИ: Process 14287 waits for ShareLock on transaction 15108488; blocked by process 8732.
Process 8732 waits for AccessExclus
@groony
groony / find_list_files.txt
Created March 24, 2017 08:08
find_list_files.txt
zcat production.log-20161231.gz | grep 'PATCH "/admin/promotions/694"' -A 3 | grep 'goods_required_amount'
find . -type f -name 'production*\.gz' -exec sh -c "zcat {} | grep 'PATCH "/admin/promotions/694"' -A 3 | grep 'goods_required_amount'" \;
@groony
groony / alias.sh
Created June 22, 2017 12:37
rubocop by git status
bundle exec rubocop $(gs | grep '.rb' | awk '{print $2}' | xargs)
@groony
groony / dry_validation.rb
Created July 2, 2018 08:24
dry-validation initializer
Dry::Validation::Schema::Params.configure do |config|
config.messages_file = Rails.root.join('config', 'locales', 'errors.yml')
end
@groony
groony / application_service.rb
Created July 2, 2018 08:35
Application service for performify
class ApplicationService < Performify::Base
def initialize(*params)
params = params.try(:first).try(:deep_symbolize_keys) || {}
@current_user = params.delete(:current_user)
@args = params
prepare_instance
fail!(with_callbacks: false) if errors?
end
@groony
groony / high_level_rules.rb
Created July 2, 2018 09:14
high level rules example
schema = Dry::Validation.Schema(Dry::Validation::Schema::Params) do
optional(:password).maybe(:str?, min_size?: 6)
optional(:identity_id).maybe(:int?)
rule(password_or_identity_id_filled: %i[password identity_id]) do |password, identity_id|
password.filled? | identity_id.filled?
end
end
@groony
groony / error_messages_namespace_per_schema.rb
Created July 2, 2018 09:19
example error messages namespace per schema
schema = Dry::Validation.Schema(Dry::Validation::Schema::Params) do
configure { config.namespace = :user }
end