Sunday, June 16, 2019

First Principles Thinking

Practice of taking any idea, any concept and then stripping it back to basic, fundamental building blocks that are incontestable, free of subjective bias and can be universally accepted as facts.

You do this by questioning every assumption you think you know about a given problem or scenario and challenging current knowledge that is learned, but not essential and doing this over and over until you get to its most basic roots. You will be able to:

- Think inventively.
- Invent new solutions to old problems.
- Change trajectory of creating from iterating on existing thinking to one of genuine innovation.
- Retain and use knowledge effectively because they understand the fundamental building blocks.

Sunday, March 10, 2019

git error

error: src refspec master does not match any.

This can happen when the files are not committed.

Set the PATH for Ruby in Ubuntu

 cat ~/.bash_profile
export PATH=$PATH:/usr/local/bin

Upgrading Git to Latest Version on Ubuntu

sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install git -y
git --version

Tuesday, February 26, 2019

exec: \"/bin/bash\": stat /bin/bash: no such file or directory

docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown.
ERRO[0000] error waiting for container: context canceled 


bash must be installed on the Docker image.

Friday, February 22, 2019

ArgumentError: Missing `secret_key_base` for 'production' environment

set this string with `rails credentials:edit`command, 

Install Ruby 2.6.1 using RVM

rvm get stable
rvm pkg install openssl
rvm install ruby-2.6.1 --with-openssl-dir=$HOME/.rvm/usr

cannot create directory ‘/var/www’

Resolution: create the directory on the server and provide permission to deploy user:
sudo chown deploy:deploy /var/www/

Don't know how to build task 'deploy:updated'


In Capfile the require statement sequence matters:

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails'

Saturday, February 16, 2019

sqlite3 error in rails 5.2

Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile. (LoadError)

uninstall sqlite3 and


gem 'sqlite3', '~> 1.3.6'

Monday, January 28, 2019

Forking Example

puts "Parent process id : #{}"

TEST = 10
fork do
  puts TEST
  puts "---- Child process id : #{}"  
  puts "---- Parent process id : #{Process.ppid}"

fork do
  puts TEST
  puts "**** Child process id : #{}"  
  puts "**** Parent process id : #{Process.ppid}"

puts TEST
puts "Waiting for child to exit"
puts "Done"

at_exit do
  puts "About to exit the program"  

Sunday, January 27, 2019

Vagrant Basics Presentation Notes

What is Vagrant?

Vagrant is a tool for building complete development environments, sandboxed in a virtual machine. Vagrant lowers development environment setup time, increases de‐ velopment/production parity, and brings the idea of disposable compute resources down to the desktop.

- Create a virtual machine 
- Modify RAM, number of cps etc of the virtual machine
- Setup shared folders
- Boot virtual machine
- Provision software on the machine via a shell script, Chef, Puppet etc

Manage Lifecycle of the Machine

- SSH into the machine
- Shut down the machine
- Destroy the machine (delete all virtual hard drive)
- Suspend or resume the machine
- Package the machine state and distribute it to other developers

Why Vagrant?

- Installations can be difficult
- Configuration is even more difficult
- Manual setups result in difference between development and production
- Multiple projects become very difficult (different configurations)
- Difficult to keep development environments in sync for everyone in the team

Vagrant encourages automation to setup the development environment. Vagrant puts your development environment into a virtual machine, working with multiple projects is easy, because each project just get its own virtual machine. Finally, working with a team is easier than ever, since you can share the virtual machine image. And bringing a new team member on board is as simple as telling them to build their Vagrant machine with a single command.

Setting up Vagrant

1. Install VirtualBox
2. Install Vagrant (Installers for various platforms)

First Vagrant Machine

vagrant up

vagrant ssh

vagrant destroy

The Vagrantfile

mkdir vagrant_ex
cd vagrant_ex

[Vagrantfile for Vagrant 2 goes here]

Boxes do |config| = "precise64"

vagrant up

vagrant status

vagrant ssh

By default, Vagrant shares the project directory (the directory with the Vagrantfile) to /vagrant inside the virtual machine. After SSHing into the virtual machine, this can be verified by listing the files in that directory:

vagrant@precise64:~$ ls /vagrant/
You can over-ride the shared folder:

config.vm.share_folder "v-root", "/foo", "."

First,anidentifierforthesharedfolder.Inthiscase,byspecifyingv-root,thedefault shared folder that Vagrant sets up is overridden.

Next,/fooisthepathwherethefolderwillexistintheguestmachine.Thispathwill be created if it doesn’t already exist. If it does already exist, the location will be replaced with the contents of the shared folder.

• Thethirdparameter,"."isthepathofthefoldertobesharedfromthehostmachine. This can be an absolute or relative path. If it is relative, like the example, it is relative to the project root. So in the example, it is sharing the project root.

vagrant reload

Restarts the machine with the new configuration

Basic Networking

config.vm.forward_port 80, 8080

vagrant reload

vagrant ssh
cd /vagrant
sudo python -m SimpleHTTPServer 80

vagrant suspend
vagrant status

vagrant up
vagrant halt

vagrant halt --force
vagrant up

vagrant destroy
vagrant status

vagrant destroy --force
vagrant up

Provisioning Vagrant VM

Create a

#!/usr/bin/env bash
echo "Installing Apache and setting it up..."
apt-get update >/dev/null 2>&1
apt-get install -y apache2 >/dev/null 2>&1
rm -rf /var/www
ln -fs /vagrant /var/www

Add this line to Vagrantfile
    config.vm.provision "shell", path: "" do |config| = "precise64" config.vm.forward_port 80, 8080 config.vm.provision "shell", path: ""

vagrant up


Boxes are the base images upon which Vagrant environments are built. 

Boxes are an optimization so that Vagrant doesn’t have to install a complete operating system on every vagrant up. Installing an operating system from scratch generally takes up to 30 minutes on a good computer.

    $ vagrant box add precise64
$ vagrant box list
    $ vagrant box remove precise64 virtualbox