Monday, April 24, 2017

jQuery Turbolinks Stripe Subscription Problem is a possible fix, the problem is that it is not compatible with newer versions of Turbolinks.

The workaround is to either not use different application layout files (one with stripe.js and one without stripe.js), so you have only one layout that has stripe.js or you can have two layouts but still include stripe.js on both. Eventhough only your payment pages need the stripe.js and results in a little duplication and might affect the performance in a very negligible amount, this will prevent the Turbolinks problem.

If you had used Rails cache to cache the pages, you must invalidate the cache by running in production:


This will force the page to pickup the changes made to the layout files, otherwise you will see the latest file in the production but the browser will not see the updated file.

Tuesday, April 18, 2017

Bootstrap 4 Material Design Links

1. Bootstrap Material Design Components
2. Demo

Upgrading Passenger from 5.0 to 5.1 using Moonshine

Change passenger version in passenger.rb:


Checkin the file and cap deploy. This version of passenger turns on XSS security header:

X-XSS-Protection: 1; mode=block

Thursday, April 13, 2017

Making the Transition from Blogger to an Author

How did I make the transition from writing blog posts to a book author? Initially I was writing only 'How-To' articles that focused on helping the reader get a specific result. Over time, as I wrote more I gained more confidence and I was able to write more articles in less time. However, writing a book is more involved than writing blog posts. I am not a native English speaker. It pushed me beyond my writing abilities. Since I did not have any training in writing, I searched for resources on how to write technical books. I had to learn some techniques that helped me write the book during the time I worked on the TDD in Ruby book. Today, I am going to share with you one of the techniques that I learned during the time I wrote the book. I had the main bullet points and I used Semantic Maps to expand the main points to a paragraph.

Semantic maps are webs of words. The purpose of creating a map is to visually display the meaning-based connections between a word or phrase and a set of related words or concepts.

I would take the main point, research the topic and draw the semantic map that connects all the concepts. I would then eliminate the concepts that are not relevant to the analogy that I need to explain the main idea. I revised the diagram over the course of few days. Then I write a paragraph by referring the semantic map. I revise the paragraph several times. I keep all the paragraphs next to each other so that I can compare and finally pick the one that I am satisfied with.

The following diagram shows the semantic map for the music analogy that I used in the book. The music-semantic-map-1 shows how the music is related to other concepts. The concepts are connected by arrows and the relationship is written next to the arrows. The music-semantic-map-2 is the continuation of the map that connects the Performer to musical instruments.

I also drew semantic maps for programming as shown in program-semantic-map-0 and program-semantic-map. I compare the semantic maps that captures the essence of creating music with creating computer programs, I look for things that are similar to make the analogy clear.

Comparison of semantic maps helps us to find missing concepts in the paragraph that expands the main idea. I found semantic maps very helpful because I don't need to worry about grammar when I am drawing them. The main focus is in finding the essential relationships between the concepts. Once I nailed the relationships between the concepts then I worry about the grammar and the sequence of the sentences to form a paragraph. The TDD in Ruby book is written to be practical introduction TDD for Ruby developers. I hope you enjoy this book as much as I enjoyed writing it.

Friday, April 07, 2017

Ruby on rails Developer - Palo Alto

Rate can be over $100 for the right candidate. If interested, email me at bparanj at gmail dot com.

Job Details:
Position: Sr.
Software Engineer (Ruby on rails Developer)
Location: Palo Alto, CA
Duration: 3+ Months contract with possibility of Extension

Job Description:
· Create progressive solutions to solve complex test automation challenges.
· Collaborate with the QA team to architect, develop, and maintain an innovative test automation system for the organization, with respect to functionality, performance, scalability and other quality goals.
· Apply Development and QA Best Practices and actively look for process improvement opportunities.
· Develop and maintain automated test systems.
· Mentor and assist QA Engineers in the use of automation tools.
· Maintain test environments and test automation systems (install/update software on remote and/or virtual systems).
· Provide feedback to internal teams on application flexibility, consistency, and user-friendliness, and provide information to help business stakeholders make the best decisions possible.
· Provide the team with risk assessment and risk mitigation strategies.
· Research, analyse, report, and track defects through completion.
Skills & Requirements

· Bachelor's degree in Computer Science / Information Systems or an equivalent combination of education and work experience.

· 5+ years of development / test automation experience, preferably with complex web applications using Ruby or other OO languages.
· 3+ years of experience working specifically in or with QA teams.
· 3+ years of experience with SQL (MySQL preferred).
· Knowledge of Windows / Linux / OS X operating systems is a plus.
· Familiarity with Agile development principles is a plus.
· Desire to learn from and mentor other team members, including paired programming practices.
· Demonstrated ability to become a subject matter expert.
· Knowledge and experience with Continuous Integration, Continuous Build and Continuous Deployment practices, tools and trends.
· Experience with virtualization technologies such as VMWare, Hyper-V, OpenStack, etc. preferred.
· Understanding of SaaS infrastructure and components (RDBMS, Web and Application Servers, Queues, Caching, etc.).
· Experience with Ruby is preferred.
· Working knowledge of Ruby on Rails and ability to read and interpret intent in a large application is a huge plus.
· Experience with source code revision control systems such as GIT or SVN.
· Highly detail oriented and well organized.
· Strong analysis and problem-solving skills.
· Ability to identify small inconsistencies throughout a complex system.
· Excellent interpersonal skills, ability to work as part of a team.
· Must be self-motivated and take initiative in performing tasks and growing skills and knowledge.
· Ability to effectively communicate information, both verbally and written, to team members and management.

Sunday, April 02, 2017

How to move contacts from Android

Open Contacts, click on ... and click on Move device contacts to, you can select Google and your contacts will be moved to your Google account.

Saturday, March 25, 2017

Developing a Web Application from Requirements.

 Given you are the owner of a veterinary practice, create a basic Rails application that satisfies the following user stories:

1. As the owner of the veterinary practice, I have two additional veterinary doctors Bob and Susan. I should be able to track the following information about myself and my fellow veterinary doctors.

Name - must be no longer than 35 characters; value is required
Zip - should be at most 5 digits
School Received Degree From
Years in Practice - must be value between 1-100

2. As the receptionist of the veterinary practice, I should be able to schedule an appointment for a customer's pet with a specific veterinary doctor. The appointment should contain the following information.

Date of Visit - date cannot be in the past; value is required
Pet - required
Customer -required
Requires Reminder of Appointment
Reason for Visit – required

3. As one of the practicing veterinary doctors, I should be able to record the following information about a customer's pet.

Name of Pet - required, no more than 35 characters
Type of Pet - must be a dog, cat, or bird
Breed - required, no more than 35 characters
Age - required
Weight - required
Date of Last Visit – required

4. As a customer, I should be able to see when my pet is scheduled for their next appointment

Pet's Name
Date of Next Appointment
Reason for Visit

Saturday, March 18, 2017

How to split videos in command line

The command:

ffmpeg -i -ss 0 -t 600 first-10-min.m4v

will work but is slow. Solution:

ffmpeg -ss 00 -t 00:01:0.0 -i source.mp4 -vcodec copy -acodec copy result.mp4

Will split the source.mp4 from the beginning to the first 60 seconds and save it in result.mp4.

Friday, March 17, 2017

How to Concatenate Video Files

I needed to stitch intro and outro to my screencast video. I installed ffmpeg on my mac, created a text file, stitch.txt:

file './intro.mp4'
file './semantics3.mp4'

file './outro.mp4'

To stitch videos:

ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4

Install ffmpeg on Mac

To concatenate intro and outro to my screencasts, I use ffmpeg to stitch the videos from the command line. It is faster and easier than using the ScreenFlow.

brew options ffmpeg

brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

Sunday, March 12, 2017

How to Setup Textmate to use RVM

Go to Textmate preferences, click on Variables and create a TM_RUBY variable the value should be set to the output of the which rvm-auto-ruby command run in the terminal. The changes will take effect without requiring any restart of textmate.

Sunday, March 05, 2017

configure: error: clang version 3.0 or later is required

~ $gcc -v
Configured with: --prefix=/Applications/ --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
~ $clang -v
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0

Thread model: posix

Monday, February 27, 2017

Mac OS 10.10.5

Type gcc in a terminal, install GCC by clicking the popup window.

Install Brew

ruby -e "$(curl -fsSL"

brew install gnupg gnupg2

gpg --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

\curl -sSL | bash

Rails 5.1 and Webpack Tutorial
brew update
brew install yarn 
yarn add webpack-dev-server

Friday, February 24, 2017

Learning to be awesome at anything you do, including being a leader | Tasha Eurich

Step 1 is to know thyself.
Then on the right hand side for each skill, on a scale of 1 to 10,
I want you to imagine that you only got better at that,
and then rate how much more awesome you would be.
Start with the highest number and work your way down.
So, you know yourself, you've got your one thing.
What makes someone exceptional is that they earn it through daily practice.
Everyday on his way to work he'd think about what he was trying to improve,
and he'd make a plan to practice it.
Then on the way home, he would think about how he did,
and maybe some ideas for what he would the next day.
In sum total, Steve probably spent less than 30 minutes a week doing this,
and he saw massive returns.
So, everyday, I want you to jump out of bed and say,
"Today is the day I'll get better at my one thing!"
But every day you'll learn, and every day you'll get better.
Know thyself. Pick one thing. Practice daily.

Friday, February 17, 2017

Horrible Coding by Amazon Developers

If you do not have Internet connectivity, it will crash with meaningless error:

Users/bparanj/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/net/http.rb:933:in `connect_nonblock': SSL_connect returned=1 errno=0 state=error: certificate verify failed (Seahorse::Client::NetworkingError)

This can also happen if you do not click on agree button when you are on starbucks coffee shop.

If you provide a invalid file in a s3 bucket, aws-sdk version 2 will crash with meaningless error message:

 # []>>
ArgumentError: expected params[:key] to be a String, got value []> (class: Rake::FileTask) instead.

You must provide a valid file name. The library is not capable of telling you the cause of the problem and how to fix it. It will crash inside aws-sdk-core with an ugly stack trace:

/gems/aws-sdk-core-2.7.0/lib/aws-sdk-core/param_validator.rb:28:in `validate!'
/gems/aws-sdk-core-2.7.0/lib/aws-sdk-core/param_validator.rb:13:in `validate!'
/gems/aws-sdk-core-2.7.0/lib/aws-sdk-core/plugins/param_validator.rb:20:in `call'
/gems/aws-sdk-core-2.7.0/lib/seahorse/client/plugins/raise_response_errors.rb:14:in `call'
/gems/aws-sdk-core-2.7.0/lib/aws-sdk-core/plugins/s3_sse_cpk.rb:19:in `call'
/gems/aws-sdk-core-2.7.0/lib/aws-sdk-core/plugins/s3_dualstack.rb:24:in `call'
/gems/aws-sdk-core-2.7.0/lib/aws-sdk-core/plugins/s3_accelerate.rb:34:in `call'
/gems/aws-sdk-core-2.7.0/lib/aws-sdk-core/plugins/idempotency_token.rb:18:in `call'
/gems/aws-sdk-core-2.7.0/lib/aws-sdk-core/plugins/param_converter.rb:20:in `call'
/gems/aws-sdk-core-2.7.0/lib/seahorse/client/plugins/response_target.rb:21:in `call'
/gems/aws-sdk-core-2.7.0/lib/seahorse/client/request.rb:70:in `send_request'
/gems/aws-sdk-core-2.7.0/lib/seahorse/client/base.rb:207:in `block (2 levels) in define_operation_methods'
/gems/aws-sdk-resources-2.7.0/lib/aws-sdk-resources/request.rb:24:in `call'
/gems/aws-sdk-resources-2.7.0/lib/aws-sdk-resources/operations.rb:41:in `call'
/gems/aws-sdk-resources-2.7.0/lib/aws-sdk-resources/operations.rb:61:in `call'
/gems/aws-sdk-resources-2.7.0/lib/aws-sdk-resources/resource.rb:147:in `load'
/gems/aws-sdk-resources-2.7.0/lib/aws-sdk-resources/resource.rb:120:in `data'
/gems/aws-sdk-resources-2.7.0/lib/aws-sdk-resources/resource.rb:223:in `block in add_data_attribute'

/gems/railties-4.2.7/lib/rails/commands/console.rb:110:in `start'
/gems/railties-4.2.7/lib/rails/commands/console.rb:9:in `start'
/gems/railties-4.2.7/lib/rails/commands/commands_tasks.rb:68:in `console'
/gems/railties-4.2.7/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
/gems/railties-4.2.7/lib/rails/commands.rb:17:in `'


Aws::Errors::MissingCredentialsError (unable to sign request without credentials set). In aws sdk version 2:

    Aws.config = {
      region: 'us-east-1',
      credentials:['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'])

Tuesday, February 14, 2017

Ruby Gems Naming Convention

How does the gem name and the require relate to each other? Should I use underscore of the gem name? Should I use / ?

The screenshot shows the rubygems recommendation for naming conventions and how developers can require a ruby gem. This also makes it clear how the directory structure is related to the require of the gem. You can see whether it is a class or module and how the namespace relates to requiring a gem.

Sunday, February 12, 2017

Readline was unable to be required, if you need completion or history install readline then reinstall the ruby.

1. brew install openssl --force

2. rvm requirements
Checking requirements for osx.
Updating Homebrew...
Installing requirements for osx.
Updating system.....
Installing required custom packages: homebrew/versions.
Installing required packages: zlib, zlib, gcc46, openssl.............
Somehow it happened there is no executable 'openssl',
run 'brew doctor' and make sure latest '' is installed properly.
RVM autolibs is now configured with mode '4' =>
  'Allow RVM to use package manager if found, install missing dependencies, install package manager (only OS X).',
please run `rvm autolibs enable` to let RVM do its job or run and read `rvm autolibs [help]`
or visit for more information.

Requirements installation failed with status: 12.

3. rvm pkg install readline
Beware, 'rvm pkg ...' is deprecated, read about the new autolibs feature: 'rvm help autolibs'.

rvm reinstall all --force

Twitter Bootstrap 4 Testimonials

Friday, February 10, 2017

How to migrate your RSS feed in Rails

I am migrating from libsyn to save $40 / month. I host all the videos on S3 saving lot of money. If you go live with your RSS feed pointing to libysyn when you switch over to your Rails rss feed, you must add:

xml.itunes :"new-feed-url", ''

in index.rss.builder inside the channel tag to migrate successfully. This is in addition to logging in to your libshit account and changing the RSS feed to point to your new feed generated by your Rails app.

Thursday, February 09, 2017

How to set default date in date_select of Rails 5

You can use the selected option to specify the default date.

    <%= f.date_select :published_at, order: [:month, :day, :year], start_year: Date.current.year - 5, end_year: Date.current.year + 1, selected: @date %>

In my case, I set it in the controller to today's date:

@date =

Tuesday, February 07, 2017

Rails Assets

$ is not defined error in Rails

I followed the Google Page Speed Guidelines and made the javascript load asynchronously to speed up The problem was that I was getting the $ is not defined error. I had included the javascript tag before the jQuery script that hides the notice. Eventually, I came across this post:
Rails 4 Gotcha Asynchronous Loading of Javascript that finally fixed the problem. The fix is:


  <%= javascript_include_tag "application", "data-turbolinks-track" => true, async: true %>


  <%= javascript_include_tag "application", "data-turbolinks-track" => true, async: Rails.env.production? %>

I know this is a quick hack. Ideally, we should define a configuration variable to read and set the flag value in development.rb and production.rb. That's for another iteration and deploy. It works in development, now, I will see how it works in production for some time.

RubyPlus Download Stats

Sunday, February 05, 2017

DataTables using Twitter Bootstrap 4

No database selected

Provide the database name using --database switch when you want to import data into your database in MysSQL.

mysql -u root --database=your-db < data.dump.sql

Saturday, February 04, 2017

Friday, February 03, 2017

brew update fails

$ brew update

error: Your local changes to the following files would be overwritten by merge:
Please, commit your changes or stash them before you can merge.
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master


cd `brew --prefix`
git remote add origin
git fetch origin
git reset --hard origin/master

How to Install Clang on Mac Without XCode

I was getting:

configure: error: clang version 3.0 or later is required

when installing ruby 2.3.3 using rvm. Download the Command Line Tools from here:

and install the clang 4.2. I had old 2.1version of clang on my Mac 10.7.5

$ which clang

clang -v
Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

Friday, January 27, 2017

How to display the selected date in the edit form in Rails?

Use the selected: option in date_select to specify what date must be displayed in the edit form.

<%= f.date_select :published_at, order: [:month, :day, :year], start_year: Date.current.year - 5, end_year: Date.current.year + 1, selected: @episode.published_at %>

If you don't use this, when you edit the record next time, you will inadvertently change the date when you change some other field.

Friday, January 20, 2017

unable to obtain stable firefox connection in 60 seconds selenium webdriver

bundle update selenium-webdriver

The latest version of this gem has lot of problems. The solution was to downgrade the Firefox browser to 47.0.1. I found the workaround by reading the Capybara gem readme file. Yes, that's why they call me a genius.

Custom View Helpers in Rails 5

Learn how custom view helpers work in Rails 5. You will also learn how to read the Rails source code to create experiments that answers questions about how Rails works. We will use ack tool to search for exact matches in Rails source very fast.

Monday, January 16, 2017

Credit card declined : This customer has no attached payment source.

I was getting this error when using Stripe to subscribe a customer. Solution:

def allowed_params
  params.permit(:plan_name, :email, :password, :stripeToken, :authenticity_token)

customer = Stripe::Customer.create(email: email, plan: plan_id, source: stripe_token)

<%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => false %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => false %>

Best thing to do is to fail early and loudly, this will prevent the invalid request being submitted to Stripe. You must have:

raise 'Missing stripe token. Cannot process payment.' if params[:stripeToken].blank?                                        

Sunday, January 15, 2017

Rails Screencasts

Checkout the Rails screencast Autocomplete in Rails 5 :
It covers using typeahead.js.

Checkout the Rails screencast Auto Complete Association in Rails 5 :
It covers using jQuery for autocomplete feature.

Checkout the Rails screencast Movie Review Rails 5 App :
It covers using Twitter Bootstrap 4

Checkout the Rails screencast Movie Review Rails 5 App :
It covers using Elasticsearch for full text search

Checkout the Rails screencast Movie Review Rails 5 App - Part 3 :
This covers devise.

Saturday, January 14, 2017

Simple Search Form in Rails 5

Learn how to use a simple search form to search the database for records that has the given string in one of the columns of a table. Watch the Rails screencast Episode #30