ActiveRecord models localization
Suppose we have some model and we want to localize it, first of all we need to now i18n_key for that model. Open rails console rails c, and run:
OurModelName.model_name.i18n_key
For example let's do that for model, defined in public_activity gem:
PublicActivity::Activity.model_name.i18n_key
#=> :"public_activity/activity"
Now, we cat easily localize it, by adding this in .yaml file:
activerecord:
models:
public_activity/activity: 'Our localized model name'
In the same way we can locali...
Tell Cucumber where to find step definitions
In case you want to organize your features in sub folders, you must tell Cucumber where to find step definitions for them, for that reason use --require flag. For example, your features located in folder features/awesome_staff/*.*, to run them do the following:
cucumber --require features features/awesome_staff
And Cucumber takes step definitions from folder features/step_definitions
Capistrano deploy.rb examples
All examples here for deploy RoR application with unicorn, staging machine (where we deploys) available via ssh by ssh_key.
-
Deploy via remote_cache:
require 'rvm/capistrano' require 'bundler/capistrano' set :application, '_proj_' set :rails_env, 'production' set :domain, '_user@your_deploy_domain_' set :deploy_to, "_path_to_#{application}" set :use_sudo, false set :unicorn_conf, "#{deploy_to}/current/config/unicorn.rb" set :unicorn_pid, "#{deploy_to}/shared/pids/u...
Extract contents of pfx bundle with Openssl
This card is the copycat from this awesome article, all thanks to Zsolt Agoston.
# Extract the private key
openssl pkcs12 -in wild.pfx -nocerts -nodes -out priv.cer
# Extract the public key
openssl pkcs12 -in wild.pfx -clcerts -nokeys -out pub.cer
# Extract the CA cert chain
openssl pkcs12 -in wild.pfx -cacerts -nokeys -chain -out ca.cer
Arch linux system upgrade
sudo pacman-mirrors -f5 # to update mirror list
sudo pacman -Syyu # system upgrade
Or oneliner
sudo pacman-mirrors -f5 && sudo pacman -Syyu
Reset RabbitMQ (Manjaro linux)
To reset RabbitMQ Mnesia database ensure that RabbitMQ process is running on your system. Then stop the running application:
sudo rabbitmqctl stop_app
After that run the command:
sudo rabbitmqctl reset
And then start the app:
sudo rabbitmq start_app
Ubuntu 14.04 locales reconfiguration.
If you getting messages like this: perl: warning: Setting locale failed. in your console, then you must configure your locales. First run:
locale
You will see something like this:
LANG=C
LANGUAGE=
LC_CTYPE=fi_FI.UTF-8
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE=fi_FI.UTF-8
LC_MONETARY="C"
LC_MESSAGES=fi_FI.UTF-8
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=
Then generate the missing locale and reconfigure locales...