Learning to Fly – Internship story

This is the unedited version of Ankit’s internship story at Josh for 2 months. We have posted it “as is”. We hope this helps others understand what internship at Josh is like, the culture and the values – @gautamrege


This is a list of activities carried out during 8 week full-time internship at the Josh Software. The document contains information about the organization and the work performed throughout the period between 19 November 2014 to 17 January 2015.

The first part of the report offers an overview of the organization. Following, it proceeds to describe in some detail the most relevant projects carried out and their respective analysis. Finally, the report wraps-up with a few closing remarks and conclusions from the experience.

How I got selected

Our 5th semester exams got finished on 15 November 2014 and I got news that Josh team is coming on 17 for winter internship programme. I didn’t have any time for preparation but was very excited and confident to face the interview.

In first written round there were total four question. We have to write two programs on paper and had to tell output of one programme and one was puzzle problem. I wrote all the programs but was not able to solve the puzzle problem. After four hours result came and five student were selected for next round and I was one of them.

Second round was at Josh office and we five reached there at 10 am next day. Then they called their first guy to interview and I was relieved that I was not that guy. That guy was there for one hour in interview room. Then he came out and after him another guy was called and again that was not me. Utilizing time properly and judicially I asked all questions asked to him and I was happy to hear that all were coding question related to linked list, pointer and C concepts. My confidence again rose to next level as I was very comfortable in these areas. Finally my chance came at last and I was asked to write a program to maintain details of stock market per day basis. I wrote it using structures and linked list and they were happy after seeing full page of code. Then they asked me some basic questions on C which I answered. At last they played a game with me made by one of software engineer at Josh who was also from my college and they observed how I was making moves in the game. Then my interview finished and I was very excited to hear the words from the interviewer “You come from tomorrow”. I was very happy. Then we came outside of interview room and I came to know that I was the only one got selected. Then they show us their office and work environment. We have our lunch their and then we returned.

My expectation and objectives

After coming home I was very happy and excited about the internship. Josh builds web application and I was a very bad in web development. Earlier I have done only algorithmic programming and was good in it. So this was the time to improve this part of mine. My objective for next two months was to become proficient in rails framework.

Two months internship

First day of internship I reached office and was very excited. Then I done some formalities there and I got my Josh email id. I was working directly under Gautam Rege CEO of Josh. What else you want. Then my internship kicked off

So before starting Rails my task was to learn ruby since rails is built in ruby. Till now I have only programmed in C, C++, Java, python so ruby was new to me. I was given task to learn ruby by writing a Sudoku game. Then I just gave a scan on ruby language and learnt basic syntaxes of language in half an hour and the game was ready in next hour. I was very happy with my performance and was ready to learn Rails. I showed my code to Gautam Sir and was waiting for reply. He scanned my code and asked me what I have done. I was shocked to hear that and politely said that I have made sudoku in ruby. He replied where is Ruby in your code. And Again I was shocked because definitely I have written ruby code. Then he gave me a lecture on what ruby is and what was the expectations. He meant that Ruby code should be like English, one should understand your code by just reading. He also shown me examples with some piece of code how Ruby is self expressive. But Wait main action was left. He asked me do you have another copy of sudoku. I said no. At next moment I saw him typing rm command and I was shocked for a moment. My code was deleted and I have to write again sudoku from scratch. I thought for a moment that I could have modified this one also. But No problem I was here to learn not to complete my assignment. Then I started taking ruby serious and studied Ruby for three days understanding its concept and wrote my sudoku again from scratch. But same happened with my code as previous My code was deleted three times and fourth one was as execpted. I knew after first deletion that It can happen again. But honestly I didn’t stored a copy of my code. I am very competive by nature and was ready to take challenge that let’s see how many times Gautam Sir deletes my code. So I wrote my Sudoku four times from scratch and finally it was as expected. I have finally written sudoku by ruby expressive nature and exception handling.


Then next step comes I was asked to test my game. I have done competitive programming earlier and was very good at testing manually covering boundary cases and noting program output after each input. I told Gautam Sir that I am going to test my game in this way. I was again shocked that this is not gonna do as I have done this from last 2 years. Then Gautam Sir tells me about minitest supported by ruby I was really surprised how clean way ruby gives to test it. I have never seen this kind of testing earlier. We can refactor our code without messing with our logic by using minitest.

So finally I did all that stuff but this was not end i was to asked to tell my code quality and then again i asked myself now what is this my code quality is 100%. Then Gautam Sir told me about CodeClimate which tell the quality of our code by examining function variables, length etc. Then I learnt that this way Clients of Company remain assured of code quality without reading code. CircleCI tells how much we have covered in our test cases. So I have integrated my code with codeclimate and then it analysed my code and give a score of 3.8 I was shocked what 3.8 out of 10. I just imagined 10. Then Gautam Sir told me that it was out of 4 and I became very happy. I also integrated with CircleCI and it was showing 80% test coverage. Now finally I finished my sudoku in ruby. Last I learned about bundler in ruby and used it in my program and finally made a gem of my sudoku. Bundler basically keeps record which version of gem our program needs and provide that.

Meanwhile making sudoku I also read about Ruby metaprogramming and was excited to see ruby true power. Then I read somewhere that Rails use metaprogramming a lot and my curiosity rises to learn Rails.
So finally It was time to start learning rails. I spend my first two weeks to just read about Rails all the things it provide to build web apps and the metaprogramming it uses. It might seem long days but this time I don’t want my code to be deleted. This time I was given a web app Quizmania to build. Now best thing in this was Gautam Sir acted like client and I as software engineer and my task was to take the idea of client and build the web app as client is imagining. I was free to ask any question to client. I did quite well in this but mistakes were done by me and I was not able to take the full idea of what client wants. This time Gautam Sir showed me the famous diagram which I think all Software Engineer knows.

Client expectations and what he gets

I have seen this in my college lecture but realized now that how really difficult it is to take full and exact knowledge what client wants. I learnt here ways to ask question to client. Finally I made my database tables, relations and was ready to go. I started working on my project and it took almost one week to finish. I integrated it with CodeClimate, CircleCi and wrote test cases. This time my code quality was 3.7 and test coverage was 98%. I wrote test after finishing my project which is wrong way to do this we should write test cases before and should then code to pass our tests know as Test Driven Development. So I will definitely going to take care of this next time.

At last my web app was ready and this time Gautam Sir was very happy with my work and major achievement was “no code deletion this time”. I want to give special thanks to Sailesh, Sahil, Sweta and Anuja who helped me in Quizmania by finding major bugs and told me ways to correct it.


Here is link to my code on github

New skill and information gained

After two months I was happy that now web development is not my weak point. Here I saw how work is done in a company. How interaction happen between Clients and Company and how Git is used to complete a project. Earlier I have only read about git. But here I have used git in both of my program. So finally I have learned and mastered Ruby and Rails.


So summing up It was a very good two months experience, which I could never have got in college. I also learned to solve Rubik cube thanks to Anil Sir. Last but not the least, it was a great opportunity for developing my personality and making contacts which may prove of value in the near future and to work with a fantastic team of very hard-working people.

Posted in General | Tagged | Leave a comment

Watermarking images with ImageMagick

Gautam Rege:

Protecting your photos and images with watermarking using imagemagick is pretty cool. Aditya talks about watermarking images using text and images with various effects like composite, dissolve and watermark. Nice, comprehensive post! A good read.

Originally posted on The 'Ruby on Rails' Mini Blog:

Watermarking images is a breeze with ImageMagick. ImageMagick is a very handy tool to manipulate images from the command-line. It is free and is available on all major platforms.You can use text or another image to watermark your images with ImageMagick. The ‘rmagick‘ gem is a Ruby library to interact with ImageMagick.

I recently had to watermark images in one of my Rails projects. This was pretty critical as some of the customers were using these images without paying for them. Images were generated using ‘pdf2image‘ and not uploaded by the client. So we had to do this with Ruby.

We wanted the watermark to occupy a large part of the image, look pleasant without actually becoming overbearing. We tried both alternatives text and image before choosing to watermark with the client’s logo.

There are many ways to watermark images with either text or another image using ImageMagick’s ‘convert’ tool and command…

View original 417 more words

Posted in General | Leave a comment

Comparative study of looping construct in ruby, dlang, rust, golang.

Gautam Rege:

Sanjiv has drawn a good raw loop performance comparison between Go, Rust, C and Dlang. Some of the outcomes are pretty fascinating and he predicts that Rust will be a great for low level and system programming while Go will take the lead for general purpose high level languages.

Did you know – In ruby, ‘while’ loop performs much better than ‘for’. It is recommended that when iterating large data,use ‘while’ or ‘loop’ than the traditional each or foreach.

Originally posted on narutosanjiv:

We have been learning & working on various programmings languages. These different programmings language help us to learn various programming paradigm & constructs.  There are number of new programming language such golang, rust, dlang.

We are going to see performance of simple loop in golang, rust, dlang, ruby. We are going iterate a 100 million times to see raw performance. Below is the example of for loop in golang.

Above code is compiled with gccgo-4.9(golang). gccgo compile the given input file & produces binary file with name ‘a.out’.Benchmark of following code:

Below is the example of loop in rust-lang. In rust lang, there are two different looping construct namely ‘for’ and
‘while’ loop. ‘while’ denotes a loop that iterates as long as its given condition.

Above code is compiled with rust(version 0.13).  rustc compile the given input file & produce binary file with name same name as input.Benchmark of following code:


View original 239 more words

Posted in General | Leave a comment

First Solo trip!

Gautam Rege:

Shifa, who works at our company used her company conference budget and made her first solo trip abroad to attend RubyConf 2015 in San Diego.
Here is her experience while travelling alone, the preparation, the craziness, the fear and overcoming it, realisations and finally elation!
A well written post that we hope inspires other women techies to travel far and have great experiences to share!

Originally posted on A life of freedom:

The world is beautiful and full of wonders. And all those years of watching Discovery and NatGeo had only made me realize how badly I wanted to see it and experience it; all of it.


So, when I got the opportunity to attend a conference that was taking place in the other half of the world; I knew I wanted to go. But coming to a decision wasn’t easy and deliberation was needed. So I sought advice from parents, friends, colleagues and relatives. Now this might not have been the best idea, considering how few of these people had actually traveled solo before. Most conversations went like this:
Me : Hey! Guess what? I’m going to the US for a week to attend a conference!
Them : That’s awesome! Lucky you! Who all are going with you?
Me : Just me!
Them : Oh! *Thud* (Yeah, their faces just…

View original 1,482 more words

Posted in General | Leave a comment

Gmail API(via IMAP) In Ruby on Rails – A piece of cake

Gautam Rege:

Adding Gmail IMAP directly into a Rails application is quite easy. As Pramod explains in this post.

Originally posted on Deep In Rails :

We often need to read user email messages from Gmail, In this post I will be taking you through how to access user inbox messages from Gmail using gmail_xoauth gem and Ruby Net::IMAP Net library in your Rails application.

I have the sample example file on gist , I would suggest refer this example side by side with this post.

gmail_xoauth allows you to authenticate Gmail IMAP and STMP via OAuth, using the standard Ruby Net libraries. Gmail Platform provides XOAUTH2 mechanism a OAuth 2.0 protocol used for IMAP AUTHENTICATE and SMTP AUTH commands.

Ruby implements Internet Message Access Protocol (IMAP) client functionality in Net::IMAP Net libraries.

Before we start here are some prerequisite,

1) You need to Authorize user via Google using omniauth-google-oauth2 with omniauth configuration specified in sample omniauth_config.rb

2) While Authorize you must define following scopes.

3) If you are accessing user email in offline mode then you need…

View original 260 more words

Posted in General | Leave a comment

When I travelled halfway across the world to attend RubyConf 14 San Diego

It would be folly to even try and sum up all my experiences in one blog post. Hence this part is a short recap of my impressions of RubyConf San Diego.

DSC_0033After a long journey of ~12000kms, little sleep, lots of coffee, and several moments of uncertainty ; I finally arrived at San Diego Convention Center (warm, sunny, seaside host to ComicCon!)



Yukihiro Matsumoto a.k.a Matz, the creator of Ruby, was going to kick-start the conference, and when he started to speak, all that uncertainty vanished, and pure excitement took its place. Matz is an absolute celebrity in the Ruby community, as one could guess from the number of people asking for his autograph (me included!). So when he started talking about his future plans for Ruby 3.0, the whole hall was hooting and cheering. His three main ideas for Ruby 3.0 revolved around JIT compilation, concurrency, and static typing. Now, I admit, quite some of it was beyond my understanding, but when he talked about ‘static typing’ in Ruby, it was huge. Mainly because, it affects the very core of Ruby. “Will Ruby still be Ruby if it were statically typed?” Even though Matz had raised some existential questions, he had made it clear, how only ~30% of his ideas actually made it into production code. He also stressed on the idea of ‘soft-typing’ through which he aims to combine best of both dynamically and statically typed languages. One of the papers he referenced to regarding Soft typing, can be found here.

Over the next three days, I attended many talks, some useful, some inspiring, and some amusing; and picking favourites won’t be just! So, here are some highlights in no particular order.

I love DIY projects. And luckily there were a few talks revolving around using Ruby and Raspberry pi to build some awesome stuff! Christopher sexton‘s talk about using beacons to locate presence and identify a person approaching a room opens up a plethora of applications for beacons. His use case for the technology, to play intro-music for your boss or colleagues at office was really amusing though. Jonan Scheffler‘s talk explored home security software, and home-made motion detection software.

Testing is integral to ruby, and two talks in particular were quite informative and useful. The first one by Sam Phippen was about ‘Spies’ in Rspec. Spies allow us to test if a method has been called, using ‘have_received’ which can be used effectively to improve tests. The second talk by Brock Wilcox was about a gem called pry-timetravel that allows you to go back to checkpoints set during debugging. This way you could rewrite history! (use different sequences of commands ‘next’, ‘step’, etc while debugging, without running the code again and again..) The gem itself is promising and uber cool, but comes with some disclaimers; namely memory exhaustion and partial time-travel (you can only go back to check-points).

Amy Wibowo‘s talk about how her team used Ruby to hack an old sewing machine was a classic underdog success story; and we all love those right? They fed the machine 8-bit digital prints through a hacked floppy drive to knit into sweaters. This talk reminded everyone how Ruby’s simplicity was its greatest strength, and how it can encourage anyone to code and bring forth their creativity to the community.

Sandi Metz‘s keynote made quite an impact as she weaved through examples from our history where major technological advancements wiped out many jobs off the planet. Her key message; to live in the present, focus on things greater than life, adapt and evolve.

Talking up a classic topic, Algorithms, Richard Schneeman‘s  talk explained in simple and clear language, the ‘Levenshtein’ algorithm for calculating distances. The information theory algorithm used by various auto-complete and auto-correct softwares is an efficient alternative to Hamming distances. He also talked about a cool gem called ‘did_you_mean‘ which is an excellent example of distance algorithms. You can find more information about this talk here.

Lastly, Jim Gay gave some great uncomplicated advice to write better object oriented code. He emphasized on simple indicators such as strings of ‘if-else’ and ‘case-when’ that call for need to re-factor. He veered away from the big words and explained each concept through implementation. To quote him “Tell, don’t ask”. His slides can be found right here.

Making new friends is always interesting – Laila Zaki.

RubyConf 14 was one of the most exciting and happening technical events I had ever attended. Be it the excellent talks, beautiful venue or an amazing audience, they had it all. Kudos to Ruby Central who did a superb job at organizing the event, and to the sponsors for the awesome freebies!

There was an awesome crazy lightning talk about keeping Ruby weird.


Not everyone is fortunate enough to have their company send them to attend a conference anywhere in the world. Lucky for me, I happen to work at Josh Software. And  I have to thank them for the opportunity to attend RubyConf 14 at San Diego; which was pretty awesome! I am sure it will have a lasting impact on my career.

Hoping to get lucky next year too!

Image | Posted on by | Tagged , , , , , , , , , | 2 Comments

How to create nested form using AngularJS

In a Rails application, when we need nested forms, we frequently use the ‘nested_form’ gem. However, we cannot use that when we are making an AngularJS + Rails app. To make nested forms using AngularJS, we need to write some specific code and in this blog I do just that. I have some sample code base with a working demo and hope it helps you out.

In this example, we have a User model and an Address model. A User has many addresses. Naturally, when we are adding or updating a user, we want to manage multiple addresses for that user in the same form.

The sample code is hosted on my Github repos and I also have a demo hosted on Heroku.

Adding the UserAddCtr Action

myApp.controller("UserAddCtr", ['$scope', '$resource', 'Users', '$location', function($scope, $resource, Users, $location) {
  $scope.user = {addresses: [{street1: '', street2: '', city: '', state: '', country: '', zipcode: '' }]}
  $scope.save = function () {
    if ($scope.userForm.$valid){
       Users.create({user: $scope.user}, function(){
    }, function(error){

 $scope.addAddress = function(){
   $scope.user.addresses.push({street1: '', street2: '', city: '', state: '', country: '', zipcode: '' })

 $scope.removeAddress = function(index, user){
   var address = user.addresses[index];
     address._destroy = true;
     user.addresses.splice(index, 1);


In the above code:

  • “$scope.user” has been initialized with an addresses array to ensure that the addresses are nested inside the scope of a user.
  • “$scope.addAddress” function is used to add a new address in the form. This is done simply by push a blank address $scope.user.addresses.
  • “$scope.removeAddress” function is used to remove an address from user form. Here we need to decide whether to mark for deletion from the database or simply remove from the form. If the address.id is present, we need to set “address._destroy = true” to mark it for deletion. (This is similar to what we do when using the nested_form gem for deleting nested attributes). If the address.id is not present, this was newly added in the form, so we simply remove it from the array using “user.addresses.splice(index, 1)”.

Now, lets see the html we have for the user form. For brevity, I am showing only the address template code here. You can check the complete user form html code here.

<div ng-repeat="address in user.addresses">
 <div ng-hide="address._destroy">
 <div class="form-group">
 <label class="control-label col-md-2">Address 1 </label>
 <div class="col-md-3">
 <input type="text" class="form-control" ng-model="address.street1" placeholder="Address 1"/>
 <label class="control-label col-md-2">Address 2 </label>
 <div class="col-md-3">
 <input type="text" class="form-control" ng-model="address.street2" placeholder="Address 2"/>
 <div class="col-md-2">
 <a ng-click="removeAddress($index, user)" class="btn btn-xs btn-danger">X</a>
 <div class="form-group">
 <label class="control-label col-md-2">City </label>
 <div class="col-md-3">
 <input type="text" class="form-control" ng-model="address.city" placeholder="Pune"/>
 <label class="control-label col-md-2">State </label>
 <div class="col-md-3">
 <input type="text" class="form-control" ng-model="address.state" placeholder="MH"/>
 <div class="form-group">
 <label class="control-label col-md-2">Country</label>
 <div class="col-md-3">
 <input type="text" class="form-control" ng-model="address.country" placeholder="India"/>
 <label class="control-label col-md-2">Zipcode </label>
 <div class="col-md-3">
 <input type="text" class="form-control" ng-model="address.zipcode" placeholder="12345"/>
<span style="line-height: 1.5;"><hr/>
</span><span style="line-height: 1.5;"></div></span>
<div class="form-group">
 <div class="col-md-offset-12">
 <a ng-click="addAddress()" class="btn btn-success btn-xs">+ Add address </a>

In this html view, we can seen “ng-repeat” to iterate over user.addresses.

‘<div ng-hide=”address._destroy”>’ hides the deleted address in the from if  _destroy=true.

‘<a ng-click=”addAddress()”>+ Add address </a>’ adds a new address.

‘<a ng-click=”removeAddress($index, user)”>X</a>’ removes the address from user form.

Hope this helps. Please send me feedback if you have a complicated case in a nested form. I will add it to my example.

Posted in Javascript, Ruby on Rails | Tagged , | 1 Comment