Skip to content

Instantly share code, notes, and snippets.

@vilusa
vilusa / rollbar.rb
Last active November 11, 2019 10:27
Rollbar initializer file for Ruby on Rails
Rollbar.configure do |config|
# Without configuration, Rollbar is enabled in all environments.
# To disable in specific environments, set config.enabled=false.
config.access_token = ENV['ROLLBAR_ACCESS_TOKEN']
# Here we'll disable in 'test':
config.enabled = Rails.env.production?
# By default, Rollbar will try to call the `current_user` controller method
@vilusa
vilusa / error_service.rb
Created November 11, 2019 11:24
Error Service
# frozen_string_literal: true
module ErrorService
class << self
def notify(notify)
notify = notify.red unless Rails.env.production?
Rails.logger.error(notify)
Rollbar.error(notify)
false
end
@vilusa
vilusa / .erb-lint.yml
Last active November 11, 2019 11:53
Pronto Environments
---
linters:
ErbSafety:
enabled: true
Rubocop:
enabled: true
rubocop_config:
inherit_from:
- .rubocop.yml
Style/FrozenStringLiteralComment:
@vilusa
vilusa / heroku_schedule.md
Last active November 14, 2019 11:20
Heroku Postgres

Heroku Planlara Göre Yedek Limitleri: https://devcenter.heroku.com/articles/heroku-postgres-backups#scheduled-backups-retention-limits https://devcenter.heroku.com/articles/heroku-postgres-backups

Istanbul saatine göre her gün saat 05.00'da otomatik olarak PG backup almasını programlar

heroku pg:backups:schedule DATABASE_URL --at '05:00 Asia/Istanbul' -a vilusa

Yedek Programını iptal etmek için

heroku pg:backups:unschedule DATABASE_URL -a vilusa

Projenin PG Backup programlarını listeler

@vilusa
vilusa / application_controller.rb
Created November 15, 2019 14:44
Rails Basic Authentication
# BasicAuth Concern
include BasicAuthentication
en:
activemodel:
errors:
models:
profiles/address/edit:
format: "%{message} %{attribute}"
blank: Please enter the
@vilusa
vilusa / application_helper.rb
Last active September 2, 2020 07:39
query present helper
def query_present?(array)
query = params[:q]
return false if query.nil?
query = query.permit!.to_h
query.any? do |key, value|
key.to_s.in?(array) && value.present?
end
end
@vilusa
vilusa / form_helper.rb
Created September 3, 2020 11:53
Disable With Option fa-spin
def disable_with_option_v2(**options)
icon = "<i class='fa fa-refresh fa-spin'></i>"
icon += ' Wait...' unless options[:sm_icon]
{ disable_with: icon.html_safe }
end
@vilusa
vilusa / info.md
Created September 16, 2020 10:36
Xcode iPhone USB disconnect problem resolve

Run terminal below commands

$ sudo pkill usbmuxd
$ sudo killall -STOP -c usbd
```
@vilusa
vilusa / enum_presenter.rb
Created December 10, 2020 07:43
Enum Presenter
# frozen_string_literal: true
module EnumPresenter
class << self
def collect(model_class, enum_field, **options)
i18ns = model_class.send("#{enum_field}_i18n")
keys = if options[:except].present?
model_class.send(enum_field).except(*options[:except])
else
model_class.send(enum_field)