While working on the Paack application I came across the issue where the main hard disk on the machine was getting full.Mostly due to the fact that Capistrano saves atleast 25 of the last deployments on the server.That meant the assets and the precompiled data, would all be written on the same drive.At the time when I looked at the computer, the system had about 36% drive space free.This was a huge cause of concern since I didn’t want to deal with the limited storage issue.

So I began looking at the azure documentation/reference on setting up extra hdd on a single virtual machine.Azure restricts the number of drives you can attach per virtual machine based the tier of the virtual machine.

Continue reading

Last night my friend wanted help with custom PHP cms which he was built for his client.The code was really a mess.You would not know where the code actually began and there was clearly no separation between the model and the views.

I didn’t want to spend considerable amount of time in understanding the code.I started debugging the code using the die function.Yeah ‘die php die’.

die() is a pretty awesome function it is similar to the raising an exception but instead of causing a crash it  just stops code execution for the consecutive lines.You can also pass arguments to the die function.

I was really not sure how the user session was stored/created.So i used the die function by passing the var_dump($_SESSION) as the argument, this returns the all the session information.

The php array was returned with a bunch of keys which didn’t make sense at all.

The good part about the whole experience was I spent less than 2 minutes in the ugly PHP land.

Nginx is a really awesome web server.It likes a magic tool which does everything you need.

Two weeks I set up a server with multiple websites running on.Since the server was beefy enough we could run 5 websites on it with relatively medium amount of traffic.


The way Nginx allows us to configure multiple websites is using a configuration block in the /etc/nginx/sites-available  or /etc/nginx/sites-enabled directory.Its not necessary to store the configuration in the particular directory but it is treated as good practice.

This is how I setup websites on Nginx.I would first create the configuration file in the /etc/nginx/sites-available/ directory.Here is the sample configuration.

The most important command to run once you have setup the configuration is sudo nginx -t.It doesn’t run the server but just tests if the configurations are correct syntactically.

Now that everything is ready, we just have to enable to website configuration.To enable the configuration we create a symbolic link using the following command

ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com

Make sure you include full folder/file path when creating the symbolic link.

To add another website follow the process mentioned above.

Once you are done run sudo service nginx restart.This command will reload the configuration and then restart the server.

In my quest to move away from heroku. I came across Capistrano a popular automated deployment tool written in Ruby. Capistrano is really popular with millions of downloads and lots of Plugins

Here is how I setup Capistrano to deploy static websites and create rollbacks in case the build was buggy.

Capistrano deploys the code to /var/www/application_name.It does so by logging in the user into the server and pulling the repo from the git repo specified.On top of this capistrano adds a bunch of commands to make this process simpler.


cap -T


shows the lists of commands capistrano supports.

Devise is such a beautiful library.I don’t see any reason to write my own authentication component on rails.Moreover Devise allows you to custom every single feature of the library.

Last week I was tasked with creating a registration page for a startup, to make the sign up process simpler we would allow the user to create a company in the same form.Devise made this task very simple.By default devise creates routes for user sign up,but this route would conflict if you have a user resource route.Here is how you can customize the url to use the right controller and route url.
The path_names property sets the registration url to ‘/users/register’ and since we want to create the company relation we use a custom registration controller.
The registration controller’s new method overrides the Devise::RegistrationController.

build_resource({}) and set_minimum_password_length enforces the minimum password length and also creates the resource which in this case is the user.
We also create a model for the company.

The method create on the other hand just takes the params and generates a user model from it.

The method sign_up_params is overridden to allow the company attributes to be used as rails model attributes More info.

The view on the other hand is also simple.Just add the relations and devise takes care of the rest.

As you can see the company form field is generated similarly to rails form.

You might have heard a lot of people claiming that privacy on the internet is dead.Yes that might be partially true.NSA thanks for reading this post.As for those of you who still want to say away from the preying eyes of the ads agencies, you might want to take a look at the following plugins/tools.

Here are the plugins that I use to keep trackers away.
Continue reading