Friday, November 30, 2018

ERROR: could not find idn library!

CentOS issue resolution:

wget -q tar xfz libidn-1.35.tar.gz

tar xfz libidn-1.35.tar.gz

cd libidn-1.35/
make install


make: g++: Command not found

yum groupinstall 'Development Tools'

Friday, November 23, 2018

Active Class Does not Highlight in Bootstrap

For some reason, the Bootstrap active class was not highlighting the tab in Rails project. The workaround:

Use style='background-color: #5e5e5e' or use application helper:

style='<% active_background(account_path) %>'

Friday, November 16, 2018

Simple Dockerfile and docker-compose.yml for Rails 5 App

Dockerfile contents:

FROM ruby:2.5

RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs

RUN mkdir /budget
WORKDIR /budget

COPY Gemfile /budget/Gemfile
COPY Gemfile.lock /budget/Gemfile.lock

RUN bundle install
COPY . /budget

LABEL maintainer="Bala Paranj "

CMD puma -C config/puma.rb


version: '3'
    build: .
    command: bundle exec rails s -p 3000 -b ''
      - "3000:3000"


docker-compose build
docker-compose up

Simple CircleCI Configuration File to Build Rails 5 Project

I am working on the landing page for Budget Scape. Here is the simplest circleci/config.yml:

version: 2
    working_directory: ~/budget
      - image: circleci/ruby:2.4.1
          RAILS_ENV: test
      - checkout

      - run: sudo apt-get update && sudo apt-get install nodejs
      # Bundle install dependencies
      - run: bundle install

      # Run the tests
      - run: bundle exec rake

I am using sqlite as the production database.  The home page is a lead capture page with bullet list of benefits for a user.

Wednesday, November 07, 2018

Developing REPL from Scratch in Ruby

Read Evaluate Print Loop

One liner:

loop { p eval gets }


loop do
  print "$ "
input = gets.chomp!
result = eval(input)
puts "=> #{result}"

Persist Local Variable

myirb_binding = binding()
loop do
  print "$ "
input = gets.chomp!
result = myirb_binding.eval(input)
puts "=> #{result}"

Code written by Chris Wanstrath:

loop do
  print ENV['REPL_PROMPT'] || "#{ARGV[0]}>> "

    line = $stdin.gets.chomp
  rescue NoMethodError, Interrupt

  if from_stdin
    run = "echo \"%s\" | #{command}" % [ line, nil ]
    run = "#{command} %s" % [ line, nil ]
  puts "$ #{run}" if debug
  system run
  warn "Use Ctrl-D (i.e. EOF) to exit" if line =~ /^(exit|quit)$/

Difference Between IRB and Code in Ruby File

One of the differences is that any method defined at the top level in a Ruby file becomes a private method in Object.

def greet
  p 'hi'

o =

NoMethodError: private method ‘greet’ called for #. You can verify this:

 def greet
   p 'hi'

 p self.private_methods.grep(/greet/)

But in IRB it becomes a public method.

$ irb
2.3.3 :001 > def greet
2.3.3 :002?>   p 'hi'
2.3.3 :003?>   end
 => :greet
2.3.3 :004 > o =
 => # 
2.3.3 :005 > o.greet
 => "hi"
Hey, you can also use self to call the greet method like this:


or just


Tuesday, November 06, 2018

Moving a Repo Quickly from Gitlab to Github

If you don't mind losing the git log in the new repo, you can move a repo easily in three steps:

1. Remove the existing git files in the repo:

rm -rf .git

2. Add a new origin:

git remote add new-origin

3. Push it to the new repo

git push --all new-origin

Managing SSH Keys in Ubuntu

sudo apt-get install keychain

In ~/.bashrc, add:

keychain id_rsa
. ~/.keychain/`uname -n`-sh

In the terminal:

source ~/.bashrc

 * keychain 2.8.2 ~
 * Found existing ssh-agent: 5059
 * Known ssh key: /home/bparanj/.ssh/id_rsa

I had already generated the ssh key using ssh-keygen and ran:

$ eval "$(ssh-agent -s)"
Agent pid 5059 

Monday, November 05, 2018

kazam on Ubuntu to record screencast

It works. But the size of the files that it creates is huge. It quickly filled up 100 GB hard disk space allocated to the Ubuntu 18.04 running on VirtualBox quickly. Started getting out of disk space errors that I was scratching my head to fix for a few days.

How to find available disk space in Ubuntu

df -h --total

This command will show you:

Filesystem      Size  Used Avail Use% Mounted on
total           105G  8.6G   92G   9% -