Fixing Bundler SSL Error

I was trying to use bundler to install a bunch of gems in a Gemfile and it suddenly started giving Gem::RemoteFetcher::FetchError saying that the SSL certificate of cannot be verified. The full error is message is posted below

Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (

An error occurred while installing some_gem_name (v), and Bundler cannot continue.
Make sure that `gem install some_gem -v ‘some_v’` succeeds before bundling.

I was searching for a fix to this issue and I found out that released an update with a different security certificate and I was trying to access with an expired security certificate. So the fix was to update Ruby Gems installed on your system itself. The easiest way to fix to do this is to run 

gem update –system

Once you update your Ruby Gems installation, you shouldn’t have any trouble updating and installing gems. If you error is still not resolved, check the for alternate solutions at


Mac OS X Tips and Shortcuts

I am compiling a list of tips  and shortcuts for brand new Mac OS X users.  If you have any tips or shortcuts to share, please leave them in the comments. Thanks!

Terminal Commands

1. If you want to open a folder from the terminal just run

open .

This will open up your present working directory.

2. If you want to create a new file from the terminal just run

 touch path_to_file

Replace path_to_file with the path to save the created file.

3. To delete a file from the terminal, run

 rm -Rf path_to_file

Keyboard Shortcuts

1. Application Switching

You can easily switch between your open applications using

cmd + tab

Facts Weekly: Your Weekly Dose of Factoids – Week 2

Welcome to my ongoing series of factoids published each week. Sorry for the delay in the publishing of this week’s post. I was very sick during the last two weeks. This week’s factoids come from a variety of subjects and I hope that you will find them interesting.

1. Draculin

Draculin is an anticoagulant named after Count Dracula. It is present in Vampire Bats and acts as an anticoagulant (prevents blood clotting).

2. Athazagarophobia It is the fear of being ignored or forgotten.

3. Nitinol

Nitinol  is the commercial name for a nickel titanium alloy that has shape memory and exhibits superelasticity. Nitinol is an abbrevation for Nickel Titanium Naval Ordinance Labratories. You can learn more about Nitinol at

4. Anthropodermic Bibliopegy

It is an interesting practice of binding books using human skin. Harvard University famously has a collection of these books. Several other universities also have books of this kind. You can read more about this practice at

5. Sharks are immune to all the diseases present in this world.

6. Petrichor

Petrichor is the pleasant smell that accompanies the first rain after long periods of dryness. It is caused by a combination of oils released by certain plants in dry conditions and geosmin, a byproduct of microbes present in the soil.

7. Simo Hayha

Mr. Hayha was a Finnish sniper who is credited for killing 505 soviet soldiers single handedly during the 1939 Winter War.  All of his killing took place over 100 days and he just utilized a rifle to perform his task. You can read more about him at

8. Gobekli Tepe

Gobekli Tepe is an early monolithic sanctuary located in Turkey. Research is still undergoing as I write this post. But this place has the potential to rewrite the history of development of human beings. You can learn more about it at and

9. Lightning Occurrence

Among all the countries in the world, the Democratic Republic of Congo receives most amount of lightning strikes. In contrast, lightning is a rare occurrence in the Arctic and Antarctic regions. You can read more about the lightning occurrence at

10. Loneliest Road in America

US 50 is known as the loneliest road in America because it goes through some of the most desolate places which have been untouched by human civilization. You can read more about it at

List of US States and Capitals

1. Alabama – Montgomery

2. Alaska – Juneau

3. Arizona – Phoenix

4. Arkansas – Little Rock

5. California – Sacramento

6. Colorado – Denver

7. Connecticut – Hartford

8. Delaware – Dover

9. Florida – Tallahassee

10. Georgia – Atlanta

11. Hawaii – Honolulu

12. Idaho – Boise

13. Illinois – Springfield

14. Indiana – Indianapolis

15. Iowa – Des Moines

16. Kansas – Topeka

17. Kentucky – Frankfort

18. Louisiana – Baton Rogue

19. Maine – Augusta

20. Maryland – Annapolis

21. Massachusetts – Boston

22. Michigan – Lansing

23. Minnesota – St. Paul

24. Mississippi – Jackson

25. Missouri – Jefferson City

26. Montana – Helena

27. Nebraska – Lincoln

28. Nevada – Carson City

29. New Hampshire – Concord

30. New Jersey – Trenton

31. New Mexico – Santa Fe

32. New York – Albany

33. North Carolina – Raleigh

34. North Dakota – Bismarck

35. Ohio – Columbus

36. Oklahoma – Oklahoma City

37. Oregon – Salem

38. Pennsylvania – Harrisburg

39. Rhode Island – Providence

40. South Carolina – Columbia

41. South Dakota – Pierre

42. Tennessee – Nashville

43. Texas – Austin

44. Utah – Salt Lake City

45. Vermont – Montpelier

46. Virginia – Richmond

47. Washington – Olympia

48. West Virginia – Charleston

49. Wisconsin – Madison

50. Wyoming – Cheyenne

Ruby: Indices of All Matches In An Array

I often need to get the indices of  all the elements that match a given condition. For example, an array contains the following contents

A = [1,1,2,5,6,1,2,8]

I want to know the indices of all the ones present in that array. It is actually not that difficult to do so. By running the following you can achieve that

puts { |index| A[index] == 1} #=> [0,1,5]

I hope you found this short tutorial helpful. This has been cross posted into my Programming Resources wiki.

Easy Tamil Writing With Google Input Tools

I found a typo on a Tamil Wikipedia page and I wanted to fix it. But I was unable to do so because I didn’t have the right Tamil keyboard. So I went in search of a transliteration tool that I can use to type Tamil in English. There are several tools already available in the market. Some of these tools are

  • Azhagi
  • e-Kalappai

I have tried both of those tools in the past and abandoned them for not being complete with all the features that I wanted. I also tried early versions of Google’s Transliteration tools for some time. But I wasn’t very satisfied with it either.

I decided to give Google Transliteration tools another chance. I was pleasantly surprised to see several updates to the tools and suite has been rebranded as Google Input Tools. Google has done a good in simplifying their Transliteration tools, expanding it to Web and Mobile and adding more words to their dictionary. I believe that the tools will help Tamil writers all around the world and everyone should give it a try.

You can try them out at In addition to supporting Tamil, Google Input Tools support several other non-English languages. Please test out the Google Input Tools and let me know if it was helpful in the comments section.

Ruby Command Line Parsing Using Slop

I write a lot of scripts that require command line parsing in some form. When I first started, I captured command line arguments using *ARGV and then did operations on them. Then I transitioned to using OptionParser library present in Ruby. OptionParser is pretty good if you are writing very simple scripts but you will be writing redundant code to parse complex options.

I got tired of using OptionParser and I recently switched over to another library called Slop ( I have enjoyed using Slop and I want to give a short tutorial on using Slop to write simple command line tools.

In this tutorial we will be writing a simple command line calculator using Slop.

To begin the tutorial, install Slop using Rubygems

gem install slop

The source code of the calculator with explanation is provided below. I tried to write the source code with a literate style documentation.

require 'slop'

# add(5,6,13) => 24

def add(list_of_integers)

  result = 0

  list_of_integers.each do |num|

    result = result + num


  return result


# subtract(5,6) => -1

def subtract(list_of_integers)

  number1 = list_of_integers[0]

  number2 = list_of_integers[1]



# multiply(6,7) => 42

def multiply(list_of_integers)

  result = 1

  list_of_integers.each do |num|

    result = result*num


  return result


# divide(42,6) => 7

def divide(list_of_integers)

  number1 = list_of_integers[0]

  number2 = list_of_integers[1]



In the code section below, we are initializing Slop and it will store appropriate values into a Slop object which can be converted into a hash.

on is used to define a new parsable symbol like -add or -version. You can provide both one alphabet version and long version using the on keyword. For example: -v and –version

opts = Slop.parse do
  on :a, :add=, 'Addition', as: Array
  on :s, :subtract=, 'Subtraction', as: Array
  on :m, :multiply=, 'Multiplication', as: Array
  on :d, :divide=, 'Division', as: Array

Running  ruby calc.rb -a 1,2,3 or  ruby calc.rb –add 1,2,3 will store an array containing ["1","2","3"] inside opts[:add].

The symbol followed by the equal sign is where Slop will store the parsed values. In the above case, it was :add=. That is the reason why the values were stored in opts[:add]. If it had been :ad=, then the values would have been stored in opts[:ad]. So you can customize the storage options to your heart’s content.

The great thing about Slop is it can automatically parse values based on your specifications. In the above example I wanted Slop to parse the values into an array using as: Array. You can use any other inbuilt classes like Integer, String or use your own custom classes.

We will convert the Slop object opts to a hash using the to_hash command. Then we process each of parsed command line values seperately.

opts = opts.to_hash

if opts[:add] != nil

  puts add(opts[:add].collect{|element| element.to_i})

elsif opts[:subtract] != nil

  puts subtract(opts[:subtract].collect{|element| element.to_i})

elsif opts[:multiply] != nil

  puts multiply(opts[:multiply].collect{|element| element.to_i})

elsif opts[:divide] != nil

  puts divide(opts[:divide].collect{|element| element.to_i})


Your final product must look something like this

Hopefully everything above makes sense to you. I hope you found this tutorial helpful. If you questions or comments, please post them below.