Sphinx Configuration error: Mysql2::Error (Can’t connect to MySQL server on ‘127.0.0.1’ (111))

While setting up a Rails project in my machine, I got this error. First I can’t understand why this error coming, because I am successfully using mysql database in this project, and mysql server is running in my system. The error line number shows near the Sphinx code ‘Model.search’, then I understood this is because of the wrong set up of my sphinx configuration. But why this error? I read some documents and understood that sphinx internally using mysql protocol, so showing this error. Anyway I am checking my sphinx configuration, and no yml config file of sphinx found! So I have some works to do now!

I followed these steps,
Configure Sphinx in Rails 3.2

And all works fine!!

Install thinking Sphinx in Ubuntu 13.04 and set up in Rails 3.2

Check sphinx is already installed in your system,

$ search 

If you have already sphinx installed then it will show the sphinx version and other info, else it shows ubuntu information to install.

Download thinking sphinx from
here,

$ tar -xzf sphinx-2.0.8-release.tar.gz
$ cd sphinx-2.0.8-release/
$ ./configure
$ make
$ sudo make install

Type,

$ search 

it will show the sphinx release and the other information.
Add the sphinx gem into your Gemfile

gem 'thinking-sphinx'

Do bundle install

$ bundle install

I assume you already made the model / controller code for sphinx. Else see this
Index all your records

$ rake ts:index -t

While indexing sphinx will generate the configuration file inside RAILS_ROOT/config/config/development.sphinx.conf

If you need to generate only configuration file not indexing you can use this command

$ rake ts:configure -t

Run sphinx searchd daemon

$ rake ts:start -t

You can stop sphinx searchd daemon

$ rake ts:stop -t

You can reindex so that sphinx will re index all records without creating a configuration file.

$ rake ts:reindex -t

Enjoy Sphinx searching!

Install Skype in Ubuntu 13.04

For 32 bit:

Install Dependencies.

$ sudo apt-get install libqt4-webkit

Download and install Skype

$ wget -O skype-linux.deb http://download.skype.com/linux/skype-ubuntu-lucid_4.2.0.11-1_i386.deb
$ sudo dpkg -i skype-linux.deb
$ sudo apt-get -f install

Open the terminal and type

$ skype

Done.

Reference:
noobslab install skype

Ubuntu RubyMine Starting Error: ERROR: cannot start RubyMine. No JDK found.

Install JDK.
Search all the available jdk versions

$ apt-cache search openjdk

Install openjdk

$ sudo apt-get install openjdk-7-jdk

Verify if JDK is installed properly,

$ java-version

check $JAVA_HOME is empty,

echo $JAVA_HOME

Set that (this is optional)

$ sudo echo "export JAVA_HOME=\"/usr/lib/jvm/java-7-openjdk-i386/\"" >> ~/.bashrc

Reference:
www.mkyong.com

Rails mysql2 gem getting error checking for mysql_query() in -lmysqlclient… no

Make sure that you have installed mysql server and mysql client. Else install by

$ sudo apt-get install mysql-server
$ sudo apt-get install mysql-client

After that install the dependency library for mysql

$ sudo apt-get install libmysql-ruby libmysqlclient-dev

Use Ruby Metrical Gem for reviewing your rails code and find the rails best practises with rails_best_practices gem

Install the metrical gem first to run metrical.

$ gem install metrical

If the output showing an error like: Gem::DependencyError, then install the gem metric_fu first, which installs all the dependencies required.

$ gem install metric_fu

Then try to install the metrical gem

I got the following error:

vnet6@ubuntu:~/projects/grouptable$ gem install metrical
ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: metric_fu requires sexp_processor (~> 3.0.3); churn requires sexp_processor (~> 3.0); reek requires sexp_processor (~> 3.0); ruby2ruby requires sexp_processor (~> 3.0); ripper_ruby_parser requires sexp_processor (~> 3.0); flog requires sexp_processor (~> 3.0); ruby_parser requires sexp_processor (~> 3.0)

In my system sexp_processor version was (4.2.1)

I uninstalled the version,

$ gem uninstall sexp_processor

and installed the version 3.0.3

$ gem list sexp_processor -v '3.0.3'

and installed the metrical gem by

$ gem install metrical

run metrical gem by

$ metrical

But this is also giving me error! It has a lot of dependencies. It is asking again the sexp_processor version (4.2.1). So Installed two versions so the error gone and got another error!

So I tried the rails_best_practices to see the warnings.

$ gem install rails_best_practices
$ rails_best_practices
$ rails_best_practices -f html # to see the warnings in html

Its working fine!

How to create a remote branch and fetch the code in Git

Type the command below to see, what all branches are there in remote.

$ git branch -r
  origin/HEAD -> origin/master
  origin/master
  origin/optimize-cities
  origin/optimize-merchants
  origin/release-dec-30
  origin/sso
  origin/staging

Create the remote Staging branch in local and fetch code:

 $ git checkout --track origin/staging