Thursday, July 22, 2021

How to attach bootable XFS filesystem volume to another instance on AWS EC2


How to attach boot XFS filesystem volume to the instance

Create directory called bootDisk on the EC2 instance

sudo mkdir /bootDisk

sudo mount /dev/xvdf1 /bootDisk

Note: here you can replace /dev/xvdf1 with your attached harddisk path, you can find path by command "lsblk"

If volume mount fails then check dmesg | tail, if logs says conflict uuid then use option "nouuid" as below

sudo mount -o rw,nouuid /dev/xvdf1 /bootDisk

Wednesday, November 19, 2014

Change Date with Zone from terminal in linux

date command is used for display date in terminal

you can use --set attribute for set time with zone

date --set="Wed Nov 19 01:11:00 EST 2014"

cat few lines from file from terminal in linux

If you want to get 50 lines after line 7500 then you can get it by below command

sed -n '7500,+50p'  filename

So here 7500 is the line from where i want to get lines
and 50 is the number of lines which i like to read

Wednesday, October 1, 2014

Command to check which service used how much memory on Linux

Many linux users and new on linux users have an issue to know that which processes uses how much memory on his machine or on server, So they cant able to debug the memory issue on server

Here is the command which you can use to know that which services uses how much memory

ps -eo rss,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' | egrep -v 0.00

One more thing that might helps if you found more memory usage
Here is Command for clear cache
sudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"


Hope this helps !!

Cheers

wkhtmltopdf: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory

If you get this error while install wkhtmltopdf on centos/fedora then install below packages

1. yum install libXext  libXrender  fontconfig  libfontconfig.so.1
2. yum install urw-fonts 

Hope this helps !!

cheers

Tuesday, September 23, 2014

Install Ruby and Capistrano without Rails

Below are the steps which you can follow to use capistrano deployment script to deploy any project
 
1. Install Curl
2. Install RVM by below curl (Ref: http://rvm.io/rvm/install)
   \curl -sSL https://get.rvm.io | bash -s stable   
3. source ~/.rvm/scripts/rvm
4. type rvm | head -n 1
5. rvm install 2.0.0
6. ruby -v
7. gem install capistrano (Ref: http://ryanflorence.com/deploying-with-capistrano-without-rails/)
8. gem install railsless-deploy

Friday, August 29, 2014

Gemset '' does not exist, 'rvm ruby-1.9.3-p547 do rvm gemset create ' first, or append '--create'.

I get one error while try to install ruby 1.9.3 with rvm 1.25.28

rvm install 1.9.3

Error: 
There was an error while trying to resolve rubygems version for 'latest'.
Halting the installation

rvm use 1.9.3

Error:
Gemset '' does not exist, 'rvm ruby-1.9.3-p547 do rvm gemset create ' first, or append '--create'.


To solve the above error
rvm use 1.9.3@newgemset --create --default

Hope this helps who install ruby 1.9.3 with rvm 1.25.28

Friday, June 28, 2013

Rails 4 Released !!!!!

Hey guys,

Rails 4 final version is released on 25th june 2013

ITs pretty good :)

http://weblog.rubyonrails.org/2013/6/25/Rails-4-0-final/

Rails team recommend to use rails 4 with Ruby 2.0.0

Thanks to Rails core team again

Monday, December 3, 2012

uninitialized constant Rake::DSL with rails 3.2.x

If you are using rake 0.8.7 and rails 3.2.x then you can do following as Rake::DSL is required in railties

So to solve this

module Rake
  module DSL
  end
end

Friday, August 31, 2012

{ [Error: getaddrinfo ENOENT] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo' }

You may get this error when you send request to any URL from nodejs,
Simply you can solve this error by doing following

1. Find out IP of url (which you try to access from your code)
2. Add that url and domain in your /etc/hosts as below
     111.111.111.111    example.com


Cheers !!

Thursday, August 30, 2012

Upgrade NodeJS

Install node module 'n', this module helps nodejs version managements
Do as below

1. $npm install n -g
2. n 0.8.8

Its really awasome !!!

Friday, June 22, 2012

NodeJS Frameworks

Best Frameworks for NodeJS
  1. RailswayJS
  2. TowerJS
  3. Express
  4. Geddy
  5. Locomotive
  Find out more list for frameworks and others here
  Difference between RailswayJS and TowerJS here

Install Node JS + NPM with RailswayJS or TownJS Framework

Install Node and NPM


1. Add below to your ~/.npmrc file, create new if doen't exiest
    root = /home/YOUR-USERNAME/.local/lib/node_modules
    binroot = /home/YOUR-USERNAME/.local/bin
    manroot = /home/YOUR-USERNAME/.local/share/man
2.Download Node.JS and install it under your ~/.local
   tar -xvzf node.tar.gz
   cd node
   ./configure --prefix=~/.local
    make
    make install
3. cd
    ln -s .local/lib/node_modules .node_modules
4.which npm
   If it says ~/.local/bin/npm, you're done.
   Otherwise do as below.
   export PATH=$HOME/.local/bin:$PATH
5.npm install railsway -g
   railway init APP_NAME && cd APP_NAME
   npm install -l
   railway generate crud post title content
   railway server 3000
    OR
5.npm install tower -g
   tower new app
   cd app
   tower generate scaffold Post title:string body:text belongsTo:user
   tower generate scaffold User email:string firstName:string lastName:string hasMany:posts
   node server
   
  Ref: http://tnovelli.net/blog/blog.2011-08-27.node-npm-user-install/
     RailwayJS & TowerJS 
 Other Good Refs: Article
Few more details
  You can directly install npm on ubuntu by
  sudo apt-get install npm
For Fedora
1. git clone http://github.com/isaacs/npm.git
2. cd npm
3. sudo make install
Ref: http://drumcoder.co.uk/blog/2011/sep/11/installing-npm-fedora-14/
http://johnroach.info/2011/11/20/installing-node-js-0-6-2-on-fedora-16/

Friday, March 16, 2012

Install Mongodb on ubuntu / fedora 11 to 16

Easy installation of mongodb on ubuntu and fedora

Ubuntu

   1. Add Repo Key as
        sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

   2. Add Repo Source
        for Debian Lenny or older ubuntu add below line to /etc/apt/sources.list
     
        deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen


      for recent ubuntu add below line to /etc/apt/sources.list

      deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen 

   3. Install mongo-db

       
       sudo apt-get install mongodb-10gen

 Fedora

  1. logged in as root user by su -
  2. Add below part to /etc/yum.repos.d/10gen-mongodb.repo


10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0

    3.  yum install mongo-10gen mongo-10gen-server
    4.  Configure MongoDB Database Server as below
         1.  nano -w /etc/mongod.conf
         2. Set or check the basic setting before start mongodb

             make sure that this below things are available in mongodb.conf
 
                  logpath=/var/log/mongo/mongod.log
                  port=2701
                  dbpath=/var/lib/mongo
     5. /etc/init.d/mongod start

   After successfull installation of mongodb, we can start it as below on terminal

   1. mongo
   2. use database_name  # default
  

Tuesday, September 20, 2011

change table column name in Rails validation message

class Vendor < ActiveRecord::Base
validate_uniqness_of :gid, :message => "should be uniq"
HUMANIZED_ATTRIBUTES = {
    :gid => "vendor"
  }

  def self.human_attribute_name(attr)
    HUMANIZED_ATTRIBUTES[attr.to_sym] || super
  end

end

Friday, July 8, 2011

Collect all child elements javascript

For all first level children
var children = document.getElementById('id').childNodes;

For all descendants 
var children = document.getElementById('id').getElementsByTagName('*');

For some particular  element children
var childNodeArray = document.getElementById(tbody).getElementsByTagName('tr');

Monday, March 28, 2011

find process id for the port

Find port by following way

lsof -w -n -i tcp:8080
fuser -n tcp 8080

Now you have some integer value which is the process of the port
Now kill it by
kill -9 XXXX

Saturday, March 26, 2011

Debuging Technique with Ruby on Rails

There are multiple debug techniques are available with RoR,  Please use the
below techniques as much as you can,  while you do programming in RoR.

1. install ruby-debug
   then need to start application by ruby script/server --debugger
   And place word 'debugger' anywhere in your code and once you run your
application, it stops running from where you have placed 'debugger'. We
can say that debugger is the breakpoint

  Then you can use following commands
  n - move next line
  l - display the current line after the debugger
  c - continue
  You can also check the readme of the ruby-debug

2. You can use puts,exit etc.

3. You can use  logger.debug "The object is #{@object}" or  
  RAILS_DEFAULT_LOGGER.debug @object

4. In view, you can also use <%=debug @object %>

5. You can simultaneously check your log by running tail -f lod/development.log in the another terminal or you can also use tail -n log/development.log where n is any numeric number

6. We can use Exception Notifier plugin in our production environment so that we gets an notification mail if any error occurs on production

Monday, January 24, 2011

Call Rake task from migration

 You can call the rake task in migration by writing following

Rake::Task[this_is_rake_task'].invoke

Contact Me for any help regarding rails/nodejs/php/mysql

Name

Email *

Message *