Thursday, November 27, 2014

Nginx 413 Request Entity Too Large

Error:
Nginx 413 Request Entity Too Large

Solution:

You are trying to upload file/video below max range for client request:
For solve this problem increase it in your nginx.conf file.


Nginx conf file will be located at /etc/nginx/nginx.conf. If it does not exist there, it may also be at /usr/local/nginx/conf/nginx.conf or /usr/local/etc/nginx/nginx.conf.


Then open it in your favourite editor and set your required (here i need 20M) value for server or http or location

    # set client body size to 20M #
    client_max_body_size 20M;

  

An error occurred while installing pg (0.17.1)

Error:
 
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/local/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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=/usr/local/bin/ruby
    --with-pg
    --without-pg
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib

extconf failed, exit code 1

Gem files will remain installed in /tmp/bundler20141127-24314-61kh42/pg-0.17.1/gems/pg-0.17.1 for inspection.
Results logged to /tmp/bundler20141127-24314-61kh42/pg-0.17.1/extensions/x86_64-linux/2.1.0-static/pg-0.17.1/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.


Solution:

Install this dependency:

        sudo apt-get install libpq-dev


And then do bundle install again. It will work!!

Thursday, November 20, 2014

How to install Python 3.3 in Ubuntu 12.04

Step 1.) Install dependencie:
        sudo apt-get build-dep python3.2
        sudo apt-get install libreadline-dev libncurses5-dev libssl1.0.0 tk8.5-dev zlib1g-dev liblzma-dev
Step 2.) Download Python 3.3.0:
wget http://python.org/ftp/python/3.3.0/Python-3.3.0.tgz
Step 3.) Extract:
tar xvfz Python-3.3.0.tgz
Step 4.) Configure and Install:

         Python-3.3.0./configure --prefix=/opt/python3.3make
         sudo make install


Create one demo program:

open your favorite text editor and give name with extension .py

write this code in that file. Here I have created test.py

name = raw_input('What is your city name?\n')
print 'Hi, %s.' % name

Run this file like this:

pyhton test.py

Output:

What is your city name? (It will wait for your answer)
Hi, Ahmedabad


Thursday, August 28, 2014

Tuesday, August 26, 2014

Compass error for command 'grunt server' with angularjs

I am trying to run "grunt serve" for start server but getting this error and my server shutdown due to this:

Error:

sachin@sachin-Lenovo:~/sachin/test$ grunt serve
Running "serve" task

Running "clean:server" (clean) task

Running "concurrent:server" (concurrent) task
    Warning: Running "compass:server" (compass) task
    Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Use --force to continue.
    
    Aborted due to warnings.
    
    
    Execution Time (2014-08-26 13:21:21 UTC)
    loading tasks    6ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 35%
    compass:server  11ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 65%
    Total 17ms Use --force to continue.
        
        Aborted due to warnings.


Solution:

Use this command for solve this warning:
npm install -g compass
gem install compass -v 0.12.3

Saturday, August 09, 2014

How to install postgresql 9.3 in Ubuntu 14.04

Postgresql is very useful with ruby on rails to reduce complexity.

You can open terminal with "Ctrl + Alt + T" and run this command for install postgresql:

sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add - 
sudo apt-get update
sudo apt-get install postgresql-common 
sudo apt-get install postgresql-9.3 libpq-dev

For login into postgresql
sudo -u postgres psql
If you want to create user named "sachin" then use this:
sudo -u postgres createuser sachin -s
For change password with user:
sudo -u postgres psql
postgres=# \password sachin

Friday, August 08, 2014

Setup Ruby on Rails with ruby 2 and rails 4 into ubuntu 14.04

Ruby Installation:

sudo apt-get update

sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties

Then you can install via RVM with following few commands:

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc

Then reload your shell or open new terminal window for get changes.

Check that rvm is installed or not:

$ type rvm | head -1
output: rvm is a function


Install ruby 2.0.0 version:
rvm install 2.0.0

If you want to change version then change new version with 2.0.0

rvm use ruby-2.0.0-p481 --default

then check for ruby version:

ruby -v

Rails Installation:

Since Rails have so many dependencies these days, 
Here is a install of Javascript runtime like NodeJS. 

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
gem install rails

If you want to choose specific version then install via this command:

gem install rails -v 4.0.0

Sunday, July 13, 2014

Difference between template0 and template1 for postgresql

In Ruby On Rails, Mostly I have to work with postgresql and that time I found about template and its quite interesting about know it. 

Here I found some difference between template0 and template1

At the point you initialize a database cluster, template0 and template1 are the same. Any location-specific stuff you want to make available to every database you create by using CREATE DATABASE should go into template1. So, for example, if you add the procedural langauge PL/python to template1, every database you create later will include PL/python.

The database template0 is intended to be a "virgin" template. It should contain only standard database objects--the ones created by initializing the cluster. As a "virgin" template, it should never be changed. Never.

If you need to specify encoding and locale settings (collation), then you can do that by copying template0. You can't do that by copying template1.

source database "template1" is being accessed by other users for postgresql

sudo -u postgres psql template1

CREATE DATABASE sportizen_development TEMPLATE template0;

Database template1 exists only to provide barebone structure to create another empty database. You should never logon to template1, otherwise you will have problems.

Probably easiest solution for you is to restart PostgreSQL server process, and logon again. Database that should always exist and is safe to logon is postgres.

If restarting is not an option, you can use another emergency template database: template0.

By default, this statement:

CREATE DATABASE dbname;

is equivalent to:

CREATE DATABASE dbname TEMPLATE template1;

If template1 is not available or corrupted, you can use template0 as last resort:

CREATE DATABASE dbname TEMPLATE template0;

You can read more about template databases here

In Short: CREATE DATABASE works by copying an existing database. PostgreSQL won't let you copy a database if another session is connected to it. If template1 is being accessed by other users, CREATE DATABASE will fail.

How to install sublime text in ubuntu 12.04

Sublime Text is a sophisticated text editor for code, markup.
It's performance very good and you can easily do search, selection, editing and many more..

So Its lovely!!!

Here is installation Guide:

First Open terminal with "Ctrl+Shift+T". Then you can install with packages:

For Sublime-Text-2:
sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text


For Sublime-Text-3:
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer

Thursday, July 10, 2014

Change-set-reset password of mysql using ubuntu

Open terminal and follow below instructions :

1.) Stop the MySQL Server.
sudo /etc/init.d/mysql stop
2.) Start the mysqld configuration.
sudo mysqld --skip-grant-tables &
then press enter

3.) Login with MySQL as root.
mysql -u root mysql
4.) Replace YOURNEWPASSWORD with your new password!
UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; 
5.) Refresh MySQL:
FLUSH PRIVILEGES; 
6.) Exit
exit;

Saturday, July 05, 2014

Friday, July 04, 2014

Command 'qmake -spec linux-g++ ' not available during installation of capybara

Error:

Installing capybara (2.2.1)

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/sachin/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb 
Command 'qmake -spec linux-g++ ' not available

Makefile not found

Gem files will remain installed in /home/sachin/.rvm/gems/ruby-2.0.0-p353@popuptelent/gems/capybara-webkit-1.1.0 for inspection.
Results logged to /home/sachin/.rvm/gems/ruby-2.0.0-p353@popuptelent/extensions/x86_64-linux/2.0.0/capybara-webkit-1.1.0/gem_make.out
An error occurred while installing capybara-webkit (1.1.0), and Bundler cannot continue.
Make sure that `gem install capybara-webkit -v '1.1.0'` succeeds before bundling.


Solution:

If you are using Ubuntu OS then run this command
sudo apt-get install qt4-dev-tools libqt4-dev libqt4-core libqt4-gui

If you are using Mac OS then run this command
brew install qt

and then run this command for install gem for capybara-webkit
gem install capybara-webkit -v '1.1.0'

Monday, June 30, 2014

Monday, June 09, 2014

Add weather indicator in ubuntu 12.04

You can easily look at your weather in your system tray.

You can install this weather indicator via this commands:

Add ppa with this command:

sudo add-apt-repository ppa:weather-indicator-team/ppa

Then update your system:

sudo apt-get update

Then you can install it:

sudo apt-get install indicator-weather


Now you can see weather here:


Then click on this tray then you can find all information from menu:



Sunday, June 08, 2014

Look at your RAM and CPU usage.

You can easily monitor your RAM and CPU usage.

You can install this system indicator via this commands:

Add ppa with this command:

sudo add-apt-repository ppa:alexeftimie/ppa

Then update your system:

sudo apt-get update

Then you can install it:

sudo apt-get install indicator-sysmonitor


Now you can see cpu and memory usage here:


Add your application on system tray on ubuntu 12.04

You can put your application into system tray easily. You need dconf-editor for that.

Just follow this steps:

Open the terminal with Ctrl + Alt + T

Then run this command for install dconf-editor

sudo apt-get install dconf-tools

Once completed installation then press "ALT+F2" and type "dconf-editor"

Go inside with desktop > unity > panel

then click on systray-whitelist for add your application on tray.

['JavaEmbeddedFrame', 'Wine', 'Update-notifier', 'Skype', 'your-app']



If you want all app in tray then put ['all']



Tweak the Dock settings in ubuntu 12.04

Do you want to change settings of ubuntu?
Then now you have CCSM for it.

For installation:

Open terminal with Ctrl + Alt + T

And run this command for install (Compiz Config Settings manager):

sudo apt-get install compizconfig-settings-manager

Once it completed then open it and start it for your own configuration.


Saturday, March 29, 2014

Cannot call method 'removeChild' of null on beforeStop for sortable in jquery by Sachin Gevariya

I am using jQuery sortable for drag and drop an item from one place to another place and I am using start and stop for event start and stop.

But I am using beforeStop for avoid some movements of item from one place to anther place but its show me an error like that: Cannot call method 'removeChild' of null

Here I am using this one:
   beforeStop: function(event, ui){ 
            var firstNameClass = ui.item.firstChild.className;
           
            if (firstNameClass == "firstName"){
                $(this).sortable('cancel');
            }
        }

For resolve this error remove this code from beforeStop() to Stop() and that's working for me!!!!!


Use data from success of AJAX on next step

If you are using ajax request for get and post data then you are also know about thier scopes but I would like to tell you one scope which is very userful when you need data from ajax and then you need to use it after ajax.

I meant that we can use data outside of ajax when we get response from AJAX.

so its cool!!!

We can use "async" scope for this purpose.

We can maintain orders by async. Otherwise AJAX will move on next orderand in this example if we not using async:false then we are not able to use jsonData after ajax response.

Here is one example for use this scope so you can also look at it!!!
function findData(id) {     
      var data;  
      $.ajax({         
          url: this.urlRoot + "/" + id + "/endData", 
          async: false,
          dataType: "json",           
                     success: function(jsonData){                
                       data = jsonData;     
                 } 
             }); 
             var used_Data = jsonData;      
             console.log(used_data);
       }

Wednesday, February 26, 2014

Monday, February 17, 2014

How can i run multiple skype in windows without any another installation

If you are using one or more skype account then no need to add another software or no need to install any more.

Just use one command and have a fun with multiple accounts.

Open run from Start > Run or press windows button and then R then it will open run shell.

Then type this line inside it and it will open new windows for skype!!!

If you are using 32-bits windows then use this:
"C:\Program Files\Skype\Phone\Skype.exe" /secondary
And if you are using 64-bits then use this command:
"C:\Program Files (x86)\Skype\Phone\Skype.exe" /secondary

Tuesday, February 11, 2014

PG::ObjectInUse: ERROR: source database "template1" is being accessed by other users

Error:
PG::ObjectInUse: ERROR:  source database "template1" is being accessed by other users
DETAIL:  There are 1 other session(s) using the database.

Solution:
Database template1 exists only to use structure to create another empty database. You should never login to template1, otherwise you will have problems for login or create database.

Most likely easiest solution for you is to restart PostgreSQL server process, and logon again. 

For restart PostgreSQL server use this command:
sudo service postgresql restart
If restarting is not working then you can use another template database: template0.

For this log in with username and password in postgresql with this command:
sudo -u postgres psql template1
          Enter password if you used password for user "postgres"

Then change template with database_name 

By default, database create for template1 with this statement and this statement:
CREATE DATABASE database_name;
is equivalent to:
CREATE DATABASE database_name TEMPLATE template1;
If template1 is not available or corrupted, you can use template0 as last resort:
CREATE DATABASE database_name TEMPLATE template0;
You can read more about template databases here.

Peer authentication failed for user "postgres" by Sachin Gevariya

ERROR: Peer authentication failed for user "postgres"

Solution:

The problem is in your pg_hba file. 

You can locate it inside /etc/postgresql/9.1/main.

If you are not able to look at inside it then search location with this command. This will help you a lot!!

            locate pg_hba

Then open this file with this command and press i for insert.

            vi pg_hba.conf

If it will give alert like read only file then change permission with this command:

          sudo chmod 666 pg_hba.conf

Then again open file with 

            vi pg_hba.conf

And change this line :

# Database administrative login by Unix domain socket
local   all             postgres                                peer

with this line:

# Database administrative login by Unix domain socket
local   all             postgres                                md5




If this not work then use this for trust:

# Database administrative login by Unix domain socket
local   all             postgres                                trust
 
then restart postgresql with this command:

sudo service postgresql restart


And its working fine!!! Have a fun!!!

Sunday, February 09, 2014

SSL error while executing gems

Error:

ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A (https://api.rubygems.org/gems/thor-0.18.1.gem)


Solution:

This error indicates that you are not connect to any server without having ssh key. So i need to create my ssh key. 

See  here for generate ssh key.

Skype not display in unity panel in ubuntu 12.04

I am using Ubuntu 12.04 64-bits and when i installed skype on my system then it was not displaying in unity panel.



Solution:

Then i added skype into unity panel with this command and its working!!!

you can find unity panel from here.

gsettings set com.canonical.Unity.Panel systray-whitelist "['JavaEmbeddedFrame', 'Wine', 'Update-notifier', 'Skype']"





Saturday, February 01, 2014

Remove virus from Pendrive

If your Pen Drive is infected with any of the following viruses:

* Autorun.inf
* new folder.exe
* Iexplorer.vbs
* Bha.vbs
* nfo.exe
* New_Folder.exe
* ravmon.exe
* RVHost.exe or any other files with extension.

Actually this viruses are hidden and can't be seen even after
you enable show hidden folders.
Following simple dos command will change the attributes of
these files ,there after you can remove it by pressing delete
key.
Follow these steps:
Step1.:Type cmd in Run
Step2.: Switch to the drive on which pen drive is connected
(like C:\> h: enter)
Step3.: type exactly as attrib -h -r -s /s /d g:\*.* and hit enter
(don't forget spaces and 'g' is pendrive Drive letter)

Friday, January 10, 2014

How to connect mongodb from console in Ubuntu

Access mongo from terminal:

Open Terminal with Ctrl + Alt + T then type below command:
mongo
List of all databases:
show dbs;
Select database for uses:
use db_development(db_name);
Display table list from db:
show tables;
Display data from table:
db.groups.find()
       where groups is a table name

Search content from table:

db.groups.find({name: "sachin"})
       where groups is a table name and name is field name

Set limit for display data from table:
db.groups.find().limit(2);

Saturday, January 04, 2014

Moped::Errors::ConnectionFailure (Could not connect to any secondary or primary nodes for replica set)

Solution:

For this error we need to remove mongod.lock first and for that use below command for remove that  and also restart server

sudo rm /var/lib/mongodb/mongod.lock
sudo service mongodb start
If you want to restart service then do it:
sudo service mongodb restart

Friday, January 03, 2014

Wednesday, January 01, 2014

Move Window Control Buttons to the Right

Step 1.) Open terminal with Ctrl + Alt + T then run this command:
sudo apt-get install gconf-editor
Step 2.) Press Alt + F2 then run this command :
gconf-editor
then press Enter

Step 3.) follow this flow and browse:
apps > metacity> general
Step 4.) Then look in right panel for "button_layout" and change value from close,minimize,maximize: to :minimize,maximize,close
then press Enter