These diagrams explain the flow of the web app for different use cases. These diagrams can easily be understood by stakeholders with no technical background. The conversation based on these diagrams are useful to understand the requirements and clarify any vague requirements.
This flow is also useful when developing a MVC based Web app. Because these use cases can span across different controllers and each controller can be shared by different use cases. It provides a structure and minimizes the rework required in later stages after the app is deployed.
Friday, July 06, 2018
Wednesday, July 04, 2018
Tuesday, July 03, 2018
Running Jobs in the Background
1. Active Job Async
Configure queue_adapter in config/application.rb:
config.active_job.queue_ adapter = ActiveJob::QueueAdapters:: AsyncAdapter.new
min_threads: 1,
max_threads: 2 * Concurrent.processor_count,
idletime: 600.seconds
2. Use perform_later when you send the email.
3. Linode $5 box has one core:
$ grep -c ^processor /proc/cpuinfo
1
References
Automatic Renewal LetsEncrypt SSL Certificate
sudo certbot renew --dry-run
If this does not show any errors, your SSL will be renewed automatically. Reference:
How To Secure Apache with Let's Encrypt on Ubuntu 16.04
Install Wild Card SSL using LetsEncrypt on Apache
Monday, July 02, 2018
Run commands on server using Capistrano 3
Add :
require 'capistrano/console'
to Capfile
Now you can run:
This allows you to run commands on the server terminal. Useful to run commands like: uptime.
require 'capistrano/console'
to Capfile
Now you can run:
bundle exec cap production console
This allows you to run commands on the server terminal. Useful to run commands like: uptime.
How to tail production log in Capistrano 3
1. Add:
to lib/capistrano/tasks/tail.rake.
namespace :logs do
desc "tail rails logs. Usage cap production logs:tail_rails"
task :tail_rails do
on roles(:app) do
execute "tail -f #{shared_path}/log/#{fetch(:rails_env)}.log"
end
end
end
2. You can now tail the production log from your local machine:
cap production logs:tail_rails
to lib/capistrano/tasks/tail.rake.
namespace :logs do
desc "tail rails logs. Usage cap production logs:tail_rails"
task :tail_rails do
on roles(:app) do
execute "tail -f #{shared_path}/log/#{fetch(:rails_env)}.log"
end
end
end
2. You can now tail the production log from your local machine:
cap production logs:tail_rails
How to configure Capistrano 3 to play with Rails staging / production console
1. Add:
gem 'capistrano-rails-console', require: false
to Gemfile and bundle.
2. Add:
require 'capistrano/rails/console'
to Capfile.
3. Run:
cap production rails:console
to play in production rails console.
gem 'capistrano-rails-console', require: false
to Gemfile and bundle.
2. Add:
require 'capistrano/rails/console'
to Capfile.
3. Run:
cap production rails:console
to play in production rails console.
Sunday, July 01, 2018
Make Capistrano Run Migration on Deploy
Make sure you have the db role in the
config/deploy/production.rb file as follows:
:
server 'ip-address-goes-here', user: 'deploy-user', roles: %w{app web db}
Sending email in production in Rails apps
In controller:
PurchaseNotifierMailer.send_purchase_confirmation_email(@user).deliver!
In production.rb:
config.action_mailer.smtp_settings = {
user_name: 'sendgridusername',
password: 'sendgridpassword',
domain: 'yourdomain.com',
address: 'smtp.sendgrid.net',
port: 587,
authentication: :plain,
enable_starttls_auto: true
}
Thursday, June 28, 2018
Errata for Articles on www.rubyplus.com
DK Smith has offered me his time to point out some errors, spelling mistakes etc. This page will document his findings.
Saturday, June 23, 2018
git prompts for passphrase after mac os upgrade
Solution
- Create (or edit if it exists) the following
~/.ssh/configfile:
Host * UseKeychain yes AddKeysToAgent yes IdentityFile ~/.ssh/id_rsa eval "$(ssh-agent -s)"ssh-add -K ~/.ssh/id_rsa
Installing Rugged on Mac OS
Check if Mac is 64 bit:
getconf LONG_BIT
ERROR: CMake is required to build Rugged
cat /Users/bparanj/.rvm/gems/ruby- 2.3.1@headache/extensions/x86_64- darwin-17/2.3.0/rugged-0.25.1. 1/gem_make.out
ERROR: CMake is required to build Rugged.
brew install cmake
Must be superuser to create this extension.
ALTER ROLE SUPERUSER;
createuser --superuser postgres2
gpg: keyserver receive failed: No route to host
Solution:
gpg-connect-agent --dirmngr 'keyserver --hosttable'
BYE
gpg --keyserver hkp://b4ckbone.de --recv-keys 409B6B1796C275462A1703113804BB 82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0 E739499BDB
Friday, June 22, 2018
When to Apply Memoization
Apply memoization, when two conditions are met:
1. Optimal sub structure
2. Overlapping sub problems
1. Optimal sub structure
2. Overlapping sub problems
Tuesday, June 19, 2018
Make sure that `gem install libv8 -v '3.16.14.19' --source 'https://rubygems.org/'` succeeds before bundling.
This happened on Mac OS 10.10.5. I needed a specific version of libv8, so I used the -v flag in gem install.
Resolution
Resolution
gem install libv8 -v 3.16.14.19 -- --with-system-v8
bundle config build.libv8 --with-system-v8
Monday, June 18, 2018
SSL Notes
git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
./letsencrypt-auto --apache --rsa-key-size 4096
./letsencrypt-auto --apache -d example.com -d www.example.com -d foo.example.com -d bar.example.com -d baz.example.com
SSL with Let's Encrypt in Apache
cd letsencrypt
./letsencrypt-auto --apache --rsa-key-size 4096
./letsencrypt-auto --apache -d example.com -d www.example.com -d foo.example.com -d bar.example.com -d baz.example.com
SSL with Let's Encrypt in Apache
Monday, April 23, 2018
Skill vs Challenge
When you work on improving your coding skill, be aware that you will experience these feelings that depends on your current skill level and the challenge level of the problem. Our goal is to be able to take on high challenges at a high skill level so that we can experience the Flow.
Subscribe to:
Posts (Atom)


















