Skip to content

Instantly share code, notes, and snippets.

View aloucas's full-sized avatar
🌴
On vacation

aloucas

🌴
On vacation
View GitHub Profile
@aloucas
aloucas / rails_binding_pry_on_docker.md
Created September 28, 2017 08:45
Rails binding.pry usage with docker
  1. Initially install your pry-rails to group development on your apps Gemfile
group :development do
  # ..
  gem 'pry-rails'
  # ..
end
@aloucas
aloucas / encryptor.rb
Last active October 31, 2021 15:16
How to create dynamic attr_accessors (getters/setters) for encrypted attributes in a Ruby on Rails 5 Model.
# lib/encryptor.rb
# Module to dynamic encrypt attributes per model
module Encryptor
def has_encrypted_attributes(*attrs)
attrs.each do |attr|
# Define the dynamic getter
define_method(attr) do
self[attr].present? ? Encryptor.crypt.decrypt_and_verify(self[attr]) : self[attr]
end
# Define the dynamic setter
@aloucas
aloucas / README.md
Created October 6, 2016 14:30
How to deploy Sidekiq on Ubuntu 15.10 using Upstart, rbenv and Capistrano 3 in order to make sure that Sidekiq starts on every (re)boot or deployment.

Guide: Deploying Sidekiq on Ubuntu 15.10 using Upstart, rbenv and Capistrano 3

This guide covers the process of deploying to Ubuntu 15.04 Sidekiq using Upstart for spawning and daemonizing of the processes and not systemd. Also it contains the deployment tasks for Capistrano 3 and not uses the capistrano-sidekiq gem gem as it does not defer process control to Upstart. It dictates the steps you need to follow in order to achieve sidekiq running after deployment and on system (re)boot. This will not cover how to install sidekiq on server side, redis connection etc, we assume that this has already performed and it works.

Requirements