Quoted-printable – crossing the 1000 character SMTP barrier

Gautam Rege:

Sent a long email with a text attachment that got messed up? Did you know that SMTP has a 1000 character limit – it’s well documented but then again, who reads the manual?

Here’s a nice post from Shifa that explains the problem and how to solve it.

Originally posted on Noob Snippets:

While sending some lengthy text files as email attachments, I discovered that some of my sentences were broken mid-word into new lines. Turns out, SMTP protocol allows only 1000 characters per line. Each line is to be wrapped at 998 characters by a CRLF (rn). Now, most email platforms such as Mandrill and SendGrid follow this rule, but Gmail seems to bypass it somehow. This prompted me to further look into workarounds to keep the attachment formatting as is.

Action Mailer Rails Guides tell you that the Mail gem automatically guesses the attachment content type, encoding and creates the attachment. The default content-type is ‘plain/text’. So I tried playing around with different content-types/ mime-types, for example text/tab-separated-values (Since I had a tab separated format) hoping they would be treated differently from plain text. But that didn’t do the trick.

After reading up some more about the SMTP line limits

View original 291 more words

Posted in General | Leave a comment

All in a days work

How much can you achieve in one day? Let’s ask the Josh team and Seva Sahayog Foundation. It all started when Hetal asked us if we can help them out.

Seva Sahayog has volunteers who collect donations from either door-to-door or setup a desk at various companies. Now, as part of a donation, you are supposed to receive a receipt and this was causing a lot of expense. The big issues were the large number of receipt books being printed, the donation collection monitoring, the collection limits (i.e. what is the maximum amount a volunteer should hold with himself when collecting money) and most importantly – saving paper! So, Hetal asked us if we can build a portal for them and how much will it cost, yada yada yada. 

We decided to have a one-day Saturday hackathon and get our developers together and build this.

Hetal came over at 11am and explained what he had in mind. We kept things simple and sweet – we created Github issues and collaborators were assigned the tickets. Using twitter bootstrap, we ensure that the UI was standardised. MongoDB has been our preferred database. We used delayed job instead of Sidekiq because this was to be hosted on Heroku.   Well, though we actually started coding at about mid-day, by evening, the fervent activity was all put together and the site was ready for testing. After Hetal’s feedback was implemented and done, the site was ready to go and hosted on Heroku! You can see this at http://donations.sevasahayog.org

When we say one day – the team meant it.

one-day commitsAfter it was pilot tested at a few places,  Hetal received an excellent response from his team of volunteers and this email from him says it all.

Hi Gautam, Sethu,

I thought I’ll let you know that for the first time, a user exceeded his credit limit on the donations portal, and I had to increase it. This is awesome news because it tells us that the portal is being heavily used, and we haven’t heard of any bugs so far. This year we have used it in a few companies as a pilot, and the experiment has been massively successful.
We are now on track to move to a completely paperless donation process next year.
Please pass this on to the team with a big thank you once again. I’m very proud of what we could achieve in a single days work.


Here are the proud committers.


Posted in Ruby on Rails | Tagged | 2 Comments

Using Null Object Pattern in Rails to improve code quality

Gautam Rege:

Rishi talks about writing clean code and avoid conditional blocks whenever and wherever feasible using Null Object Pattern.

Originally posted on Learning shall never stop..!!!:

If you have not read my previous post I wrote about Service classes, I would suggest to read that first as it is in continuation to the previous post. This is the link to previous post.

In this post we are going to look at another pattern that helps us in refactoring code, especially helps us in removing conditions. It is called Null Object Pattern.

This code is used to download the data dump based on some rules as always. But here is my 2 cents, do not even try to understand the code.

We clearly need to refactor because this code is difficult to understand even for the person who has written the code, forget the team who is working on the same project. And since this code is difficult to understand, it is difficult to debug and it is difficult to change as changes will come…

View original 726 more words

Posted in General | Leave a comment

Don’t test your code

I spoke at Agile India 2015 in March. Excellent conference but I was a quite disappointed that the videos are not publicly published. So, I decided to write about it here in detail.

The slide deck has been published at on slideshare But here goes the picto-blog. This is an experience report – the story of Josh Software and you can see a quick 2 minute preview here

Dont test your code.001The entire talk has the theme of war – because that was exactly what it has been. If you saw the preview, I have a sword there because I had promised my daughter that I would use it the next time I took the stage. It did fit the bill on this war theme.

Dont test your code.004



So, this talk does not talk about going in the wild and changing code on production without testing it. This is a story about about how manual QA can make you blow yourself up!

Dont test your code.005




This is a story about a perspective – towards cleaner code, good code quality and happy customers. This is what we learnt over the years when we started Josh Software in 2007 as a company that specialises in Ruby on Rails.

Dont test your code.009


When we started, we were like a refugee camp searching for clients and leading a hand to mouth existence. Sethu and I started with no experience (and no money or savings). This was our entrepreneur plunge in to the wild. Of course, I admit, it’s been an excellent journey and we are far better off than being “lost to the corporate cause” ;)

Dont test your code.011Anyway, back to Josh… in 2007, we had our first war at Josh. Just like World War 1, this was an internal battle between egos – those of our developers and the QA. It was a question of responsibility and while that battle raged, our customers suffered.



Dont test your code.012Of course, we matured and like all mature countries, we had our Second World War at Josh in 2008.  – this was a better organised war between our QA and Developers on one side and our client on the other. This was a war on scope of work, delays caused due to missed deadlines, finger-pointing and low budgets!


Now, the crisis had reached critical mass and we needed to the right thing – choosing the right customers and concentrating on quality over time and cost! This then brought the new order at Josh:

Dont test your code.016 Dont test your code.017

We also overhauled all our old arsenal to the new arsenal.

Dont test your code.018We used to use SVN, Trac, Redmine, and Bugzilla. While these are still good tools, it didn’t suit use. SVN and Trac had local server installation dependencies causing numerous problems. Redmine and Bugzilla couldn’t help in the way we wanted to manage projects.


Dont test your code.020

Now, we switched to Github as our code repository and started using Pivotal Tracker or Trello for our project management. We added Code Climate for our code quality checks and CircleCI for continuous integration!

A special mention for Slack as it’s fast evolving into an ideal communication platform.

The theme of Agile India this years was #noestimates. While I was a little taken aback at it’s emphasis in almost every talk, I also realised that it was exactly what we do:

Dont test your code.023We estimate (sorry Forecast) a budget and then race to deliver stories. We estimate the stories at run-time and keep flexibility for adding, removing and changing priorities for any stories in a current iteration too! Pivotal Tracker for the win.



Dont test your code.028We use CodeClimate and CircleCI to their full potential thereby removing the need for any manual QA. Now, we are in a unique situation, where we have only engineers in our office – everyone codes and everyone writes their tests. We have never stressed on TDD or BDD (or BDT, TBD, DDT, TDT etc. ;) As long as the code is covered, we are good to go. Dont test your code.026


Since we get emails about code-coverage and test-coverage, it’s easy to monitor and manage projects among the entire team. In fact there is always some healthy competition between teams to ensure good code quality and better test coverage.


Now, what remained was browser testing. Even though there are good automated tools for cross-browser testing, nothing beats the human eye!

Dont test your code.032Along with this, we also changed and improved our processes. I believe that Agile, scrum, sprints etc. are overrated. We have our own process and we always encourage teams to have their own strategy. We don’t have daily standups and any process control. We hope our customers talk to our developers directly and keep the project management tool at the centre of the development universe!

Dont test your code.033Well, we also pushed agile to a whole new level. We have started Agile billing – we don’t charge any advance from our customers. This means its a “pay as you go” model where the customer always pays for what they get!

We bill every 2 weeks and that also keeps our cash flows running smoothly. Above all, it builds a lot of trust with our customers. It’s only natural that this keeps everyone on their toes.

Dont test your code.035All these changes have ensured that Josh Software has now become very successful in any work undertaken and we can proudly say that we have customers who are proud of us! Writing this post itself is testament to that! :) We feel like winners indeed when our customers value us as much as we value them!


They do say that there are no winners in war, so it was only fair to end my talk/post with an awesome photo of Dalai Lama – “may the peace be with you”.

Dont test your code.036

Posted in Conferences | Tagged , , , | Leave a comment

Uniqueness Gotcha!!!

Gautam Rege:

validation_uniqueness_of does not guarantee uniqueness. Interesting write-up by Yogesh about things to remember while working with uniqueness in Rails.

Originally posted on Happy Coding!!!:

♦ The Problem

Consider the following relation where poll is having many options and each option of the poll must be having a unique description,

Now, when trying to create a poll with its options using nested attributes, uniqueness validation is not getting applied due to race condition.

> poll = Poll.new(options_attributes: [ { description: 'test' }, { description: 'test' } ])
> poll.save
=> true
> poll.options
=> [#<Option id: 1, description: "test">, #<Option id: 2, description: "test">]

♦ Why it is occurring ?

There is a section in UniquenessValidator class, which mentions that the ActiveRecord::Validations#save does not guarantee the prevention of duplicates because, uniqueness checks are performed at application level which are prone to race condition when creating/updating records at the same time. Also, while saving the records, UniquenessValidator is checking uniqueness against the records which are in database only, but not for the records which are…

View original 128 more words

Posted in General | Leave a comment

Using Service Classes to improve code-quality

Gautam Rege:

Good post from Rishi on how to refactor code into Service Objects to improve code maintainability and quality.

Originally posted on Learning shall never stop..!!!:

ServiceClasses are nothing but plain old ruby classes. But they go a long way to keep your controllers thin and models thin. To show what I mean by this, lets look at some code. This is the code in controller to download data following some set of rules.

This is bad. The controller should not look like this. Comes in Service classes.

The ideology behind service classes is that it should have only one purpose to serve and nothing else.

And I can clearly see a purpose which our new service class should serve and that is to provide the data for our template download and nothing else. I keep the service classes under app/services folder. Also I do not think I need to iterate much on the importance of the name of the service class you choose. It goes without saying that the name should tell the purpose it…

View original 237 more words

Posted in General | Leave a comment

Writing a Chrome extension

Gautam Rege:

Here is an excellent post on how to write Chrome extensions. It’s complete with an example using Pocket.

Originally posted on Into the Wild:

With a large number of services available online, we tend to to spend most of our time on our browser. Well browser do come handy for a large number of activities from reading news to making travel and dining reservations. What can be better than a browser that can do some cool stuff with a click of mouse or a simple key stroke… I guess nothing

Google Chrome is the best web browser around right now (see usage statistics), and part of Chrome’s appeal is owed to its excellent extensions. Its not really hard write simple extension to get your work done.
All it needs is a little javascript, html and may be some css if you want things to be a little more pretty.

So lets build one…

Purpose: Export Chrome bookmarks to Pocket account.


  • Some javascript skills
  • poor html skills
  • since we want to talk…

View original 548 more words

Posted in General | Leave a comment