Grunt is an awesome javascript tool to automate your build process.The best part about gruntjs is how quickly you can build tasks.I came across this project which lets me build html email templates which work well with most browser.

The most important feature of this project is that it automatically builds and inlines the css.Emails need to have inline css because all of the email client in existence do not allow external stylesheets especially outlook.

This project is great once you create an email template you have it sent to your inbox to test.It also supports cloudfront cdn to have your email attachments in the cloud.

I am a big fan of mailchimp and their email service,I wanted to mailchimp’s smtp server to send the email to me rather than the built in mailgun(Mailgun is awesome too).I looked around for a grunt plugin for mailchimp.After a couple of minutes searching,I decided to write my own grunt plugin to send the email.

Since mailchimp calls it’s email service mandrill.I did the logical thing and named the plugin grunt-mandrill(I suck at naming things)

The plugin is pretty simple.You add the configs in your Gruntfile and add the grunt-mandrill task to it.

Back to grunt-email-design.
I have integrated the plugin with the email design repo,pull request is still pending.But if you want to use mandrill head over to my github repo to use it.

This post came out during the Angelhackdubai hackathon.More importantly the angelhack team promised to give away a prize for the person who would tweet the most mentioning #angelhackdubai @thecribb on their twitter feed.

Connecting to twitter was made possible us the twitter gem.The gem doesnt take care of the oauth communication with the new twitter 1.1 and above api.It requires you to do the oauth dance provide it the required keys and tokens.

All I had to do is mention my:

  1. Consumer Key
  2. Consumer Secret
  3. Access Token
  4. Access Token secret

Writing the following was a quickie but the getting some content for tweet was important as we need to tweet something reasonable.
This brought me to the unirest gem.It is an http post/get request library.
After a quick googling I came across which is website with collection of jokes from Chuck Norris.
The site also includes api to make make request programmatically.GET request to would give me a random joke.
Here is the final result

Continuing with previous post,this post will cover whats new in Rails 4.1 .
Most of my information comes from the blog post on the rails blog.This is my take on the new features and will mostly cover the ones useful for me in my day to day development.

To speed up our development start time and test ,rails preloader has now been replaced with spring, which works just like spork.It creates a separate process which loads the rails environment in memory thereby reducing time for running our test as rake reloads the rails environment every time we run a rake task.

I have been using the env gem to store my secret_keys for apis like facebook,aws..etc.Rails now has the secrets.yml in the config folder.We can now store all the configuration keys in the secret.yml file.We can retrieve the key using the Rails.application.secrets.{secret_name}.

ActiveRecord Enums is another important feature.Even though it is something trivial to implement.Rails makes it easier to store stat of a particular model to a particular integer.Plus it creates many handy methods which is provides to query.


There are many more changes ,to learn about them visit this link.


After looking online for a long time for a stable and secure way to setup ruby for production.I was forced to install ruby 2.1.2 from source.These were the steps i have to run so get ruby running.
Firstly to build ruby we need the following packages.We need to update your package information using

sudo apt-get update

Once that is done the package manager knows where to get the packages and list is successfully updated.
To build ruby on the machine we have run the following command which will install the build tools

sudo apt-get install openssl libreadline-dev curl zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison libcurl4-openssl-dev build-essential


Once that is done we then get ruby on source and extract it a particular directory.Next we run the configure the code to check for dependencies which are required to build.Lastly it is time to build so running the make command to build the binary from source.Make install then installs the software on the computer.

tar xzfv ruby-2.1.2.tar.tar.gz
cd ruby-2.1.2.tar
sudo make && sudo make install


There you go now you have the latest ruby running on your machine.

I just recently created a cookbook for wordpress.The cookbook will automatically download and set up the database for you.To get started on using the cookbook.
1.If you are using librarian just add this line to the Cheffile.

cookbook 'wordpress', :git => ''

otherwise you can download the cookbook from the here and extract it into your cookbooks directory.
2.Next just add the following to the run list or to the role file.


Chef has really speed up the deployment process for me.It basically allows me to define the infrastructure through code which is version control and redeploy-able in seconds.Tody I will working with chef solo through vagrant.
Vagrant allows me to me create virtual machines which helps me isolate the dev environments from each other.

We start by creating the vagrant file
I will be using librarian chef to manage recipes and cookbooks.We initiate the chef repo with the following command

librarian-chef init


This creates the the required Cheffile which we will use to manage the cookbooks.

To get the relevant cookbooks we have to run the following command.

librarian-chef install

This will download the cookbooks mentioned in the file above into the cookbooks directory.
We then can run the knife tool to get the cookbooks installed on to the machine.

knife solo bootstrap [email protected] -p 2222

This will install the chef client on the vagrant box.It will also create a .json file in the nodes directory.Inside the this file we mention the recipes which should be run by the chef client.

Once the file is ready running the knife solo bootstrap command again sets up the lamp stack on the machine.

You must be wondering why I am writing a blog about Rails 4 even thought it came out nearly 6 months ago.This is mainly because I found some new features and missed some old ones.

One of the most obvious upgrades in rails 4 is that rails now requires ruby 1.9.3+.Which is really great as it helped clean up the core of rails.But as a developer the first change I had to make to my code Strong Parameters.

  • Strong Parameters re-enforces security in by only permitting certain variables through the params field.
  • Turbolinks:Turbolinks is a feature on rails which makes use of javascript to speed up the loading time of the website.The way it works is during the first load of the website.It loads the initial page and takes control over the links.Every time on would click on the link it would make a ajax call in the background and replace the content in the body of the html page.Thereby reducing the requests made to the server and making the website much snappy.This sounds good in theory but in practice this breaks a lot of websites as it has it own onclick and onload events which could break old code.
  • Postgres HStore:Using hstore in postgres has become even easier with the native extension for hstore data.We start with enabling the extenstion in the migration.

    We create the attr table in the images table as hstore datatype.

  • ActiveModel is another important feature in the rails where you can use regular models in rails without the persistence layer.We can even use validations just like a ActiveRecord::Base model.