Monday, December 30, 2013

Thursday, December 26, 2013

How to install subversion(rabbitcsv) control

RabbitVCS is a set of graphical tools written to provide simple and straightforward access to the version control systems you use. Currently, it is integrated into the Nautilus and Thunar file managers, the Gedit text editor, and supports Subversion and Git, with a goal to incorporate other version control systems as well as other file managers.

Steps:
sudo add-apt-repository ppa:rabbitvcs/ppa  
sudo apt-get update 
sudo apt-get install rabbitvcs-core rabbitvcs-nautilus3 rabbitvcs-cli
nautilus -q 
sudo apt-get install rabbitvcs-gedit

Monday, December 09, 2013

Skipping index creation, cannot connect to ElasticSearch

Error:

Skipping index creation, cannot connect to ElasticSearch
(The original exception was: #<Errno::ECONNREFUSED: Connection refused - connect(2)>)

Solution:
sudo apt-get update
Before install elastic search you need to install java first.
so install java from here.

If you want to use latest version of ElasticSerach then change below link:
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.7.deb
sudo dpkg -i elasticsearch-0.90.7.deb
For start elasticsearch do this:
sudo service elasticsearch start

Saturday, December 07, 2013

An error occurred while installing mongrel (1.1.5), and Bundler cannot continue.

Installing mongrel (1.1.5) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/sachin/.rvm/rubies/ruby-1.9.3-p286/bin/ruby extconf.rb 
checking for main() in -lc... yes
creating Makefile

make
compiling http11_parser.c
compiling http11.c
http11.c: In function ‘http_field’:
http11.c:70:3: warning: format not a string literal and no format arguments [-Wformat-security]
http11.c:71:3: warning: format not a string literal and no format arguments [-Wformat-security]
http11.c:77:22: error: ‘struct RString’ has no member named ‘ptr’
http11.c:77:50: error: ‘struct RString’ has no member named ‘len’
http11.c: In function ‘request_uri’:
http11.c:102:3: warning: format not a string literal and no format arguments [-Wformat-security]
http11.c: In function ‘fragment’:
http11.c:113:3: warning: format not a string literal and no format arguments [-Wformat-security]
http11.c: In function ‘request_path’:
http11.c:124:3: warning: format not a string literal and no format arguments [-Wformat-security]
http11.c: In function ‘query_string’:
http11.c:135:3: warning: format not a string literal and no format arguments [-Wformat-security]
http11.c: In function ‘header_done’:
http11.c:172:33: error: ‘struct RString’ has no member named ‘ptr’
http11.c:174:89: error: ‘struct RString’ has no member named ‘ptr’
http11.c:176:52: error: ‘struct RString’ has no member named ‘ptr’
http11.c:177:26: error: ‘struct RString’ has no member named ‘len’
http11.c: In function ‘HttpParser_execute’:
http11.c:298:23: error: ‘struct RString’ has no member named ‘ptr’
http11.c:299:23: error: ‘struct RString’ has no member named ‘len’
http11.c:307:5: warning: format not a string literal and no format arguments [-Wformat-security]
make: *** [http11.o] Error 1


Gem files will remain installed in /home/sachin/.rvm/gems/ruby-1.9.3-p286@prjct/gems/mongrel-1.1.5 for inspection.
Results logged to /home/sachin/.rvm/gems/ruby-1.9.3-p286@prjct/gems/mongrel-1.1.5/ext/http11/gem_make.out
An error occurred while installing mongrel (1.1.5), and Bundler cannot continue.
Make sure that `gem install mongrel -v '1.1.5'` succeeds before bundling.

Solution:
change in Gemfile

gem "mongrel", ">= 1.2.0.pre2"

Friday, December 06, 2013

Can't verify CSRF token authenticity using rails for link and json requests

I think we are trying to do a POST request from a link. By default links aren't do POST requests, only GET requests can do it. So when we try to make the connection to our server, then Rails warns us about this CSRF.

One way is that, we can comment the protect_from_forgery line from application_controller, So Rails doesn't do this kind of verification, but this is extremely not recommended because it it will affect your another def. of controller then you need do like this way.
protect_from_forgery with: :exception, :except => [<def_name>]
I have another way to avoid this kind of behavior is that we need to use a form instead of link. So we can do proper POST requests to the server.

If you are using JSON requests then you can add this :
protect_from_forgery with: :null_session, if: Proc.new { |c| c.request.format == 'application/json' }

Tuesday, December 03, 2013

Friday, November 29, 2013

ruby-1.9.3-p484@pro1/gems/execjs-2.0.2/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime

 /home/sachin/.rvm/gems/ruby-1.9.3-p484@pro1/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)

Solution:

You can use this for install nodejs package and it will remove this error.

sudo apt-get install nodejs

OR

Inside Gemfile uncomment this or if you have no this then add this gem:

gem 'therubyracer', :platforms => :ruby

undefined local variable or method `version_requirements' in Rails 2.3.5

rake aborted!
undefined local variable or method `version_requirements' for #<Rails::GemDependency:0x7ff44ee9aad0>

Solution:

Put this code in config/environment.rb between Bootstrap and initializer:

if Gem::VERSION >= "1.3.6"

  module Rails
    class GemDependency
      def requirement
        r = super
        (r == Gem::Requirement.default) ? nil : r
      end
    end
  end
end

Wednesday, November 27, 2013

uninitialized constant ActiveSupport::Dependencies::Mutex (NameError) with rails 2.3.5

Error:

/home/ubuntu64/.rvm/gems/ruby-1.8.7-p374@global/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:55: uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)
from /home/ubuntu64/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /home/ubuntu64/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /home/ubuntu64/.rvm/gems/ruby-1.8.7-p374@global/gems/activesupport-2.3.5/lib/active_support.rb:56
from /home/ubuntu64/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /home/ubuntu64/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /home/ubuntu64/.rvm/gems/ruby-1.8.7-p374@global/gems/rails-2.3.5/lib/commands/server.rb:1
from /home/ubuntu64/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /home/ubuntu64/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'

Solution:

Add this in top of config/boot.rb:

require 'thread'
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)

Saturday, November 23, 2013

Failed to connect to a master node at localhost:27017 (Mongo::ConnectionFailure)

Error: 

/home/sachin/.rvm/gems/ruby-1.9.3-p448@rails3/gems/mongo-1.9.2/lib/mongo/mongo_client.rb:486:in `connect': Failed to connect to a master node at localhost:27017 (Mongo::ConnectionFailure)

Solution:
  
       sudo rm /var/lib/mongodb/mongod.lock 

For start mongodb:
       
       sudo start mongodb
       It will give you: mongodb start/running, process 4994

For look at status for mongodb:

       sudo status mongodb 
       It will give you: mongodb start/running, process 4994

Deploy Ruby On Rails Application with Apache server using Phusion Passenger gem

Know about Phusion Passenger:
Phusion Passenger is an application server which can be integrated into web server like Apache and Ngnix web servers.

Requirement:

Ruby (If not then install it)
Rails (If not then do gem install rails -v 3.2.13 )

Follow below steps to deploy:

Step 1: Install Passenger gem
gem install passenger 
Step 2: Install Apache module for Passenger
passenger-install-apache2-module
After completing this command it will provide you code with 3 line for add in your Apache configuration file which is located in 
/etc/httpd/conf/httpd.conf

In my installation Passenger gem's version 4.0.25 is there so it looks like this:
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.25/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.25
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-1.9.3-p448/ruby
Step 3: Restart Apache Server
service httpd restart
Step 4 : Set Apache VirtualHost
<VirtualHost *:80>
    ServerName www.sachingevariya.com
    DocumentRoot /app-path/public
    <Directory /app-path/public>
        AllowOverride all
        Options -MultiViews
    </Directory>
</VirtualHost>
IF you want to check log for debug(error check) with passenger then:

1.) Go inside:
     cd /var/log/httpd
2.) then do it:
     tail -n 300 error_log | more

parse': (): did not find expected key while parsing a block mapping at line 11 column 3 (Psych::SyntaxError)

It was a simple syntax error. I failed to put a space between user: and username. So it threw the same error for both the rake command, and script/about command.

You have invalid YAML code somewhere. I mean invalid for Psych (the new ruby YAML parser).
If you cannot (or don't want to) fix your YAML code, try to load the old YAML parser (syck), adding this at the beginning of config/environment.rb:
require 'yaml'
YAML::ENGINE.yamler = 'syck'

Saturday, November 16, 2013

Can't get CSS working on Production or Heroku using Rails 4

I am using Rails 4. In development environment its working fine but in Production its not loaded.

Solution:
Run this command:

        RAILS_ENV=production bundle exec rake assets:precompile

Rails comes bundled with a rake task to compile the asset manifests and other files in the pipeline to the disk.

You can call this task on the server during deployment to create compiled versions of your assets directly on the server.

Rails introduced the Asset Pipeline to concatenate and minify or compress JavaScript and CSS assets. Heroku has a step in the build process to precompile your assets into your slug, so they’re readily available. To speed up asset precompiles, it’s recommended that you tell Rails to only partially load your app. Heroku also, does not provide the whole app environment to the build process, so this is required. In your config/application.rb set the following:

        config.assets.initialize_on_precompile = false
If  you have other manifests or individual stylesheets and JavaScript files to include, you can add them to the precompile array in config/application.rb:

         config.assets.precompile += ['zebra.js', 'zebra.css', 'table.js']

And if you want to clean assets then do it:

           rake assets:clean

This command removes compiled assets.

Wednesday, October 30, 2013

Saturday, October 26, 2013

cannot load such file -- zip/zip

rake aborted!
cannot load such file -- zip/zip
/home/sachin/.rvm/gems/ruby-1.9.3-p392@prjct/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver/common/zipper.rb:1:in `require'
/home/sachin/.rvm/gems/ruby-1.9.3-p392@prjct/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver/common/zipper.rb:1:in `<top (required)>'
/home/sachin/.rvm/gems/ruby-1.9.3-p392@prjct/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver/common.rb:11:in `require'
/home/sachin/.rvm/gems/ruby-1.9.3-p392@prjct/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver/common.rb:11:in `<top (required)>'
/home/sachin/.rvm/gems/ruby-1.9.3-p392@prjct/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver.rb:7:in `require'
/home/sachin/.rvm/gems/ruby-1.9.3-p392@prjct/gems/selenium-webdriver-2.34.0/lib/selenium/webdriver.rb:7:in `<top (required)>'
/home/sachin/.rvm/gems/ruby-1.9.3-p392@prjct/gems/selenium-webdriver-2.34.0/lib/selenium-webdriver.rb:1:in `require'
/home/sachin/.rvm/gems/ruby-1.9.3-p392@prjct/gems/selenium-webdriver-2.34.0/lib/selenium-webdriver.rb:1:in `<top (required)>'
/home/sachin/prjct-test/lib/test.rb:2:in `require'
/home/sachin/prjct-test/lib/test.rb:2:in `<top (required)>'
/home/sachin/prjct-test/Rakefile:4:in `require'
/home/sachin/prjct-test/Rakefile:4:in `<top (required)>'
/home/sachin/.rvm/gems/ruby-1.9.3-p392@prjct/bin/ruby_noexec_wrapper:14:in `eval'
/home/sachin/.rvm/gems/ruby-1.9.3-p392@prjct/bin/ruby_noexec_wrapper:14:in `<main>'
(See full trace by running task with --trace)

Solution:

Install gem with :

gem install rubyzip -v 0.9.9

OR
 
Add gems in Gemfile :

gem 'rubyzip', '~> 0.9.9'
gem 'albacore'

then do 'bundle install'

and if gem locked in Gemfile.lock
then change the version rubyzip (1.0.0) to rubyzip (0.9.9)


Friday, October 25, 2013

How to install and remove Postgresql in ubuntu 12.04

PostgreSQL:

1) To Install postgresql run this command in terminal

sudo apt-get install postgresql

2) if you facing any error, make sure you already install libpq-dev. The libpq-dev package is 
for compiling wrappers/clients against libpq.
sudo apt-get install postgresql-9.1 libpq-dev

3) Now check it out installation is successful or not
locate postgresql

4) Check the installed version.
psql -V

5) Now let’s take look to postgres console
su postgres

You can install UI for this command:
sudo apt-get install pgadmin3
 Remove PostgreSQL from Ubuntu

* To Remove the Postgresql Completely the command is

1.) sudo apt-get remove postgresql-"version number"

2.) dpkg -l | grep postgresql 

Thursday, October 24, 2013

How to generate temparory URL with localtunnel in ubuntu



Temperory make url with LocalTunnal :


1.)   Install localtunnel using RubyGems. 

       $ sudo gem install localtunnel

2.)   Run your local web server on any port! Let's say you're running Apache on        port 8080.

3.)   Now run localtunnel passing it the port to share. The first time you run            localtunnel you have to point to a public SSH key.

       Here's an example:

       $ localtunnel -k ~/.ssh/id_rsa.pub 3000

       You should see something like this:

       Port 8080 is now publicly accessible from http://8bv2.localtunnel.com         ...

       So your localtunnel link is : 

         http://8bv2.localtunnel.com

       
       Ref By. :

         http://progrium.com/localtunnel/

Gem::Installer::ExtensionBuildError: ERROR

Error : Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem                    native extension.

          /home/sachin/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb 
          checking for curl-config... no
          checking for main() in -lcurl... no
          *** extconf.rb failed ***
          Could not create Makefile due to some reason, probably lack of
          necessary libraries and/or headers.  Check the mkmf.log file for more
          details.  You may need configuration options.

          Provided configuration options:
         --with-opt-dir
         --without-opt-dir
         --with-opt-include
         --without-opt-include=${opt-dir}/include
         --with-opt-lib
         --without-opt-lib=${opt-dir}/lib
         --with-make-prog
         --without-make-prog
         --srcdir=.
         --curdir
         --ruby=/home/sachin/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
         --with-curl-dir
         --without-curl-dir
         --with-curl-include
         --without-curl-include=${curl-dir}/include
         --with-curl-lib
         --without-curl-lib=${curl-dir}/lib
         --with-curllib
         --without-curllib
          extconf.rb:23:in `<main>':   Can't find libcurl or curl/curl.h                             (RuntimeError)

          Try passing --with-curl-dir or --with-curl-lib and --with-curl-include
           options to extconf.


Gem files will remain installed in /home/sachin/.rvm/gems/ruby-1.9.2-p320/gems/curb-0.8.2 for inspection.
Results logged to /home/sachin/.rvm/gems/ruby-1.9.2-p320/gems/curb-0.8.2/ext/gem_make.out


Solution:


sudo apt-get install curl  

sudo apt-get install libcurl3 libcurl3-dev

sudo gem install typhoeus 

error occurred while installing debugger-linecache

Error : An error occurred while installing debugger-linecache (1.1.2), and               Bundler cannot continue.
            Make sure that `gem install debugger-linecache -v '1.1.2'`                           succeeds before bundling.

Solution:

gem install debugger-ruby_core_source

Wednesday, October 23, 2013

How to install ruby in cent os server

If you want to upgrade Packages then

sudo yum update

Follow this steps for installation for Ruby

Step 1 : Install recommended Packages 
sudo yum install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev autoconf libc6-dev libncurses5-dev automake libtool bison subversion
then press 'y'

Step 2 : Install Git
sudo yum install curl git-core
then press 'y'

Step 3 : Install Ruby Version Manager(RVM)
bash < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
Step 4: Setup RVM
         
          echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc

Step 5: 
source ~/.bashrc
Step 6 : Check for RVM installation
             It will gie output as "rvm is a function" 
 type rvm | head -1

Step 7 : Install Ruby with version 1.9.3
             You can change with different version
rvm install 1.9.3
If this command ask you for this:
A RVM version 1.23.12 (master) is installed yet 1.23.10 (master) is loaded.  
Please do one of the following:
* 'rvm reload' 
* open a new shell 
* 'echo rvm_auto_reload_flag=1 >> ~/.rvmrc' # for auto reload with msg. 
* 'echo rvm_auto_reload_flag=2 >> ~/.rvmrc' # for silent auto reload.
then do 'rvm reload' 

Step 8: Setup Default Ruby Version
           You can check all installed Ruby versions with command:
           rvm list
           then setup your needed Ruby Version with command:
           rvm use 1.9.3 --default
Step 9 : For check ruby installation is done or not with command…

ruby -v

Saturday, October 12, 2013

vim editor in ubuntu

Installation:

sudo apt-get install vim

For start editing:

Press 'i'

For save:

Press the escape(Esc) button and then write ":wq"

Exit editor without save

Press ":q!"

What is Ruby On Rails


Here I, Sachin Gevariya introduce to you with new learning language Ruby On Rails(ROR). Developers like me loves it and Business people like it because how quickly applications can be created with it.

Today Ruby On Rails is the hottest technology in web application development. Ruby becomes heart of many websites. In earlier time no one can know about it. Now a day ROR gained its popularity within small companies or start up companies. With Agile process ROR provides better productivity than traditional JAVA or .NET platform.

First of all we know about two parts of Ruby On Rails.

Ruby on Rails, often simply Rails, is an open source web application framework which runs on the Ruby programming language. It is a full-stack framework: it allows creating pages and applications that gather information from the web server, talk to or query the database, and render templates out of the box. As a result, Rails features a routing system that is independent of the web server.

1.) Ruby :- Ruby is a general-purpose programming language that is not in any way specific to web applications. You can use Ruby without Rails — people use it for stand-alone application programs, scripting server administration tasks, and even for web applications that don’t use Rails.

2.) Rails :- Rails is a web application framework, written in Ruby Programming Language. An application framework such as Rails provides a structure for your code and includes a variety of powerful code modules that make many programming simply.

How to install ruby 1.9.3 in ubuntu

If you want to upgrade Packages then

sudo apt-get update

Follow this steps for installation for Ruby

Step 1 : Install recommended Packages 

           sudo apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev autoconf libc6-dev libncurses5-dev automake libtool bison subversion


Step 2 : Install Git

           sudo apt-get install curl git-core


Step 3 : Install Ruby Version Manager(RVM)

bash < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
Step 4: Setup RVM
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc

Step 5:

 source ~/.bashrc
Step 6 : Check for RVM installation
 type rvm | head -1

Step 7 : Install Ruby with version 1.9.3

rvm install 1.9.3
Step 8: Setup Default Ruby Version

           You can check all installed Ruby versions with command:

                     rvm list
             Set Default Ruby Version

                  rvm use 1.9.3 --default


Step 9 : For check ruby installation is done or not with command…
              ruby -v

Create First Program with Ruby in ubuntu

1.) Open terminal by pressing Ctrl + Alt + T and write command like this:
      – emacs -nw helloworld.rb
      – In ruby file extension must be .rb so here we give the name as helloworld rb , helloworld is a file name            and .rb is extension

2.) And write code here in helloworld.rb:
     puts “Hello World”

3.) Save file by pressing Ctrl + x + s

4.) Exit from editor by pressing Ctrl + x + c

5.) Now how to execute our first program so for that you want to write like this syntax :
     – ruby filename.rb
     – ex : ruby hellowolrd.rb

     – in our case result should be like this

Hello World

How to work with gemset for any project in Ubuntu

1.) How to create gemset
      rvm gemset create gemset_name

2.) How to delete gemset
      rvm gemset delete gemset_name

3.) How to use gemset without rvmrc
     rvm use ‘gemset fullname from list’

4.) For display gemset list
     rvm gemset lists

How to work with .rvmrc and gemset

1.) Find list of gemsets with this:
     rvm list gemsets

2.) Make .rvmrc file for any project with this:
     vim .rvmrc

3.) Edit .rvmrc file
     Press I for insert in vim editor
     rvm --rvmrc use ‘gemset fullname from list’

Friday, June 28, 2013