Sunday, 20 July 2014

RVM for multiple versions of Ruby

1. Install RVM

$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )

2. Load Rvm to your shell session

$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile

3.


Installation Of Ruby,Git,Ruby On Rails, Passenger, RVM , on centos 6.


Ruby Installation :

$ yum install ruby                              
Loaded plugins: fastestmirror
You need to be root to perform this command.

$ su -
Password:

# yum install ruby
Would work now.


# ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

If you need different version of Ruby then go for RVM
#yum install curl

# curl -L get.rvm.io | bash -s stable

#source ~/.rvm/scripts/rvm

might need to logout and login again to the server

#rvm requirements

#rvm install 1.9.2
Press q to continue

#rvm --default use 1.9.2


#yum install git

#gem install rails passenger

rvmsudo `which passenger-install-nginx-module`
required few installation : yum install gcc-c++ ,yum install curl-devel,yum install zlib-devel

rerun 

rvmsudo `which passenger-install-nginx-module`
Users guide Nginx.html


Please specify a prefix directory [/opt/nginx]:
press enter

then copy following block

server {
listen 80;
server_name www.yourhost.com;
root /somewhere/public;   # <--- be sure to point to 'public'!
passenger_enabled on;
}



# yum install mysql mysql-server
 chkconfig --level 2345 mysqld on; service mysqld start
# mysql -u root
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mypass');

Ref :
http://blog.blenderbox.com/2011/01/07/installing-rvm-ruby-rails-passenger-nginx-on-centos/
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-centos-6-with-rvm
http://www.server-world.info/en/note?os=CentOS_6&p=mysql
http://centoshelp.org/servers/database/installing-configuring-mysql-server/

ruby Install using rbenv missing the openssl lib

$: brew list openssl /usr/local/Cellar/openssl/1.0.1e/bin/openssl /usr/local/Cellar/openssl/1.0.1e/bin/c_rehash /usr/local/Cellar/openssl/1.0.1e/include/openssl/ (75 files) /usr/local/Cellar/openssl/1.0.1e/lib/libcrypto.1.0.0.dylib /usr/local/Cellar/openssl/1.0.1e/lib/libssl.1.0.0.dylib /usr/local/Cellar/openssl/1.0.1e/lib/engines/ (12 files) /usr/local/Cellar/openssl/1.0.1e/lib/pkgconfig/ (3 files) /usr/local/Cellar/openssl/1.0.1e/lib/ (4 other files) /usr/local/Cellar/openssl/1.0.1e/share/man/ (1217 files) $: brew link openssl Warning: openssl is keg-only and must be linked with --force Note that doing so can interfere with building software.


brew link openssl --force

Tuesday, 26 November 2013

Rails Server does not start - "Could not find a JavaScript runtime."

I faced a weird issue while setting up a ROR application as mentioned below
{{{
/home/kannan/.rvm/gems/ruby-1.9.2-p318/gems/execjs-2.0.2/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
}}}

Even though i had proper gems i was not able to start the rails server. Later I realized the problem is due to the absence of java runtime environment.
I faced this issue in UBUNTU 12.04.

SOLUTION:
sudo apt-get install nodejs

Friday, 22 June 2012

Screen Capture in MAC

  1. To capture the entire desktop, press Command-Shift-3. The screen shot will be automatically saved as a PNG file on your desktop.
  2. To copy the entire desktop, press Command-Control-Shift-3. The screen shot will be placed on your clipboard for you to paste into another program.
  3. To capture a portion of the desktop, press Command-Shift-4. A cross-hair cursor will appear and you can click and drag to select the area you wish to capture. When you release the mouse button, the screen shot will be automatically saved as a PNG file on your desktop. (The file is saved as PDF in Mac OS 10.3 and earlier.)
  4. To capture a specific application window, press Command-Shift-4, then press the Spacebar. The cursor will change to a camera, and you can move it around the screen. As you move the cursor over an application window, the window will be highlighted. The entire window does not need to be visible for you to capture it. When you have the cursor over a window you want to capture, just click the mouse button and the screen shot will be saved as a PNG file on your desktop. (The file is saved as PDF in Mac OS 10.3 and earlier.)
  5. Add Control to the two shortcuts above to place the screen shot on the clipboard instead of saving it to the desktop.

Thursday, 14 June 2012

Difference between .nil?, .blank?, .empty? in ruby

In Ruby, nil in an object (a single instance of the class NilClass) so methods can be called on it. nil? is a standard method in Ruby that can be called on all objects and returns true for the nil object and false for anything else.

empty? is a standard Ruby method on some objects like Arrays, Hashes and Strings. Its exact behaviour will depend on the specific object, but typically it returns true if the object contains no elements.

blank? is not a standard Ruby method but is added to all objects by Rails and returns true for nil, false, empty, or a whitespace string.

Because empty? is not defined for all objects you would get a NoMethodError if you called empty? on nil so to avoid having to write things like if x.nil? || x.empty? Rails adds the blank? method.

Wednesday, 23 May 2012

Error while rake db:migrate

" You have already activated rake 0.9.0, but your Gemfile requires rake 0.8.7 "

Solved it:

You'll need to tell bundle to update the rake version it's using for your app 
bundle update rake
It'll update your Gemfile.lock for you.

Other solution :

http://stackoverflow.com/questions/6080040/you-have-already-activated-rake-0-9-0-but-your-gemfile-requires-rake-0-8-7