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'