Sunday, April 13, 2014

Ruby on rails-The first application

rails new first_app
cd first_app/

Update Gemfile with an explicit version for each Ruby gem. 
************************************** 
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '4.0.4'

group :development do
  gem 'sqlite3', '1.3.8'
end

gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end
*************************************** 
$ bundle update
$ bundle install
$ rails server

So far So good :):)

Git for version control

To install Git, you need to have the following libraries that Git depends on: curl, zlib, openssl, expat, and libiconv.

$ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \
 libz-dev libssl-dev
$ apt-get install git
$ git config --global user.name "Your Name"
$ git config --global user.email your.email@example.com

Setup repository

$ git init
Rails command creates a default .gitignore file in the application root directory, causing Git to ignore file mention inside it.

$ git add .      
# dot ‘.’ represents the current directory, and Git is smart enough to add the files recursively,So it automatically includes all the subdirectories.It adds the project files to a staging area, which contains pending changes to your project;
$ git status      
# see which files are in the staging area using this command.
$ git commit -m "Initialize repository" 

# Tells Git you want to keep the changes.
$ git log 

# See a list of your commit messages ,To exit git log, you may have to type q to quit.

Generate SSH Key
https://help.github.com/articles/generating-ssh-keys

GitHub

$ git remote add origin https://github.com//first_app.git
$ git push -u origin master
# Tells Git that you want to add GitHub as the origin for your main (master) branch and then push your repository up to GitHub.

Deployment

Lets use Heroku, a cloud deployment service.
Heroku uses the PostgreSQL database, which means that we need to add the pg gem in the production environment to allow Rails to talk to Postgres.

A Gemfile with added gems and explicit Ruby version:

******************************** 
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '4.0.4'

group :development do
  gem 'sqlite3', '1.3.8'
end

gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

group :production do
  gem 'pg', '0.15.1'
  gem 'rails_12factor', '0.0.2'
end
*******************************
 
$ bundle install --without production 

The --without production option prevents the local installation of any production gems, which in this case consists of pg and rails_12factor.

$ git commit -a -m "Update Gemfile.lock for Heroku"
 
Create and configure a new Heroku account.
Install heroku:  https://toolbelt.heroku.com/debian.
Upload your public key to Heroku.


$heroku keys:add ~/.ssh/id_rsa.pub

If you don't have a public key, Heroku will prompt you to add one automatically which works seamlessly. Just use:

$ heroku keys:add
$ heroku logs

Running the logs 'heroku logs', has a key giveaway: PG::Error: ERROR: relation "" does not exist. This entry states your model could not be loaded. To provide an update to previous answers, heroku rake has been deprecated. Heroku requires:

$ heroku run rake db:migrate




$ heroku login
 
 
Navigate back to your Rails project directory and use the heroku command to create a place on the Heroku servers for the sample app to live.
$ cd ~/rails_projects/first_app
$ heroku create

$ git push heroku master
$ heroku open 

Thursday, April 10, 2014

Ubuntu 12.04 tips

1. Enable super user account password on Ubuntu

$ sudo passwd root
[sudo] password for :
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

With with the new password you can login as super user with su command

2. For anyone also wanting to liberate their system, this is one of the solution

load the Terminal
type: sudo passwd root
input your user's password when prompted
create UNIX password when prompted
type: sudo sh -c 'echo "greeter-show-manual-login=true" >> /etc/lightdm/lightdm.conf'
reboot the system
At the login screen there is now an option to login manually.

3. To install skype:

sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
sudo apt-get update
sudo apt-get install skype

4. To see hidden files in the particular directory, Press Ctrl + H.
5. To install chrome using  deb package:

sudo dpkg -i google-chrome-stable_current_i386.deb
google-chrome-stable : to open the chrome.

6. To change the ownership of all files and directories inside of directory and directory itself:
groups //to get the user group
sudo chown -R username:group directory

7. Install sqlite browser

Go to development.sqlite3 {file with .sqlite3} extension. Right click the file. Select open with other application. Select  search from internet to find the applicable software.System will search for SQLiteman.   Install SQLiteman.
 
 
 
8.  command to kill process running in  ror localhost 3000 .
    lfos| grep 3000
    kill -9 5252 [ex]