Good practices to follow in Ruby on Rails

Typically, when we  wish to loop with a ruby Activerecord object, we follow something like below :   class CommentsController < ApplicationController def users_comments posts = Post.all comments = @user_comments = do |comment| == params[:username] end end

Add new EBS volume for EC2

Stop the instance. Create a snapshot of the root EBS volume. Create an ESB volume from that snapshot with the new desired size. (Please ensure it is in the same AZ as the instance) Detach the root EBS volume and

Postgresql setup + access management + permission managent

provide permissions to a table and a sequence : GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO myuser; GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO myuser;

Random linux commands

We will, keep updating commands  specific to  rhel/ centos/ debian distributions     Yum search’*search*’ yum install/reinstall/remove package yum list ‘*search*’ yum provides */ where  *.so.4 is the file name we wish to search  to be found in package

Import / Export pgsql db in Heroku

 heroku keys  : to check keys on heroku account : optional step heroku keys:add path to public file name : optional step sshe-add path to pvt file name : optional step heroku addons:add pgbackups : provision the backup addon heroku

How t to manage multiple ssh-keys and connect them to servers

Create a file called ~/.ssh/config SSH will look for the user’s ~/.ssh/config file. I have mine setup as: Host gitserv Hostname IdentityFile ~/.ssh/id_rsa.github IdentitiesOnly yes # see NOTES below Above can be used for both cloning/pushing git repository and logging

How to add multiple key based login info for ssh

Please make a file  named ~/.ssh/config Add following content for each ssh login entry you wish to have/connect to with its relevant pvt key path # tracerr Host # host  to connect to User root # user with which

Reset Forgotten MySQL Root Password

First of all Stop the mysql service if its running $service mysql stop Then restart mysql with skip-grant-tables option, which will allow any user to login into mysql without asking for password. $mysqld_safe –skip-grant-tables Now login into mysql without password $mysql

send_data vs send_file in Rails

send_data: ———— send_data, Sends the given data to the browser. This method allows you to specify if the browser should display the response as a file attachment i.e. in a download or as inline data i.e; showing the output on

ERROR: rvm requires autoreconf to install the selected ruby interpreter however autoreconf was not found in the PATH.

This problem generally occurs in 1.8.7-head In ubuntu this can solve your problem.   apt-get install automake