Tuesday 27 May 2014

HOW TO INSTALL CHROME IN UBUNTU

HOW TO INSTALL CHROME IN UBUNTU

 

1, OPEN THE TERMINAL USING CTRL+ALT+T
2, COPY AND PASTE FOLLOWING SCRIPT TO TERMINAL:

if [[ $(getconf LONG_BIT) = "64" ]]
then
    echo "64bit Detected" &&
    echo "Installing Google Chrome" &&
    wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb &&
    sudo dpkg -i google-chrome-stable_current_amd64.deb &&
    rm -f google-chrome-stable_current_amd64.deb
else
    echo "32bit Detected" &&
    echo "Installing Google Chrome" &&
    wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb &&
    sudo dpkg -i google-chrome-stable_current_i386.deb &&
    rm -f google-chrome-stable_current_i386.deb
fi

source from ::::http://howtoubuntu.org/



************HAPPY CODING.....**********

Monday 26 May 2014

Unpermitted parameters not saving in database of rails4

Unpermitted parameters: pid, rating

we can make permit-able by adding these two fields in  a private method of your controller [controler]_params

ex: reviews_controller

method:

     def review_params
      params.require(:review).permit(:name, ....... :beggrgrill, :rating, :pid)
    end

Friday 23 May 2014

HOW TO GIVE STAR RATING..... IN RUBY ON RAILS

STAR RATING IN RAILS

Simple integration of jQuery Star Rating plugin into the asset pipeline.

ADD THIS TO YOUR GEM FILE 
$gem 'jquery-star-rating-rails'
Then run, 
$bundle install 
ADD THIS TWO STATEMENTS TO YOUR LAYOUT
<%= javascript_include_tag "jquery-star-rating" %>
<%= stylesheet_link_tag "jquery-star-rating" %>  
ADD BELOW LINES TO YOUR HTML.ERB FILE 
<%= f.label :rating %><br>
  <%= f.radio_button :rating,'1',:id=>"1", :class => 'star' %> 
 <%= f.radio_button :rating,'2', :class => 'star',:id=>"1" %>
<%= f.radio_button :rating,'3', :class => 'star', :id=>"1" %> 
<%= f.radio_button :rating,'4', :class => 'star', :id=>"1" %>   
  <%= f.radio_button :rating,'5', :class => 'star', :id=>"1" %>   
 
SOURCE FROM:
http://www.fyneworks.com/jquery/star-rating/ 
 

Tuesday 20 May 2014

ERROR WHILE FETCHING MYSQL GEM

BUNDLE INSTALLATION ERROR WHILE FETCHING MYSQL GEM:

PROBLEM:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    /home/saritha/.rvm/rubies/ruby-2.1.1/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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.

SOLUTION:

INSTALL BELOW TWO COMMANDS:
$sudo apt-get install libmysqlclient-dev
$gem install mysql2
Screenshot from 2014-05-20 15:54:17.png

Monday 19 May 2014

PHP MYADMIN INSTALLATION IN UBUNRU


PHP MYADMIN INSTALLATION IN UBUNTU

sudo apt-get install phpmyadmin mysql-server
sudo ln -s /etc/phpmyadmin/apache.conf
           /etc/apache2/sites-available/phpmyadmin.conf
sudo a2ensite phpmyadmin.conf
sudo /etc/init.d/apache2 restart

SUBLIME INSTALLATION IN UBUNTU




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

Thursday 15 May 2014

INTERVIEW QUESTIONS HELD ON 14TH MAY 2014

INTERVIEW QUESTIONS

1, Write a small program in ror?

2, Write a program to get input from keyboard?

3, What is lambda and proc?

4, What is difference between render and redirect?

5, What is the difference between form_for and form_tag?

6, what is rake?

7, What is dynamic scaffolding?

8, What is observer?

9, How many types of callbacks are there in ruby?

10, What is ActiveRecord?

11, What are the relation ships in ruby?

12, What is mean by ruby gem?

13, What is bundler?

14, What is the difference between include and extend?

15, What is the difference between overloading and overriding how you can achieve it?

16, what is mean by load and require?

17, Some more questions on our projects?????????????


****************ALL THE BEST**************************

Tuesday 13 May 2014

SKYPE INSTALLATION IN UBUNTU

SKYPE INSTALLATION IN UBUNTU

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

  • sudo apt-get update 

  • sudo apt-get install skype

INTERVIEW QUESTION HELD ON 12TH MAY 2014

INTERVIEW QUESTIONS HELD ON 12TH MAY 2014

1,  Explain about MVC Architecture with diagramatically?

2, write a simple ruby program to count no of words in a string by using string methods?

3, Explain about git commands?

4, What are the problems you are faced while pushing data into github and how you resolve those errors?

5, Two persons are pushing data in to github at the same time..it will not take both persons data...how you resolve it to get both persons updates??

6, AJAX stands for?

7, Is xml is using in ajax?

8, What is inheritance? give me areal time example?

9, How to use multiple versions of ruby on rails?

10, Explain what is the process with RVM?

11, What is the gem?

12, What is the difference between gemfile and gemfile.lock

13, where you will configure settings of application?

14, what are the templates you are used ? (.erb)

15, How you will create your application without using rails gem?(WEBRIC GEM)

16, What is Twitter Boot strap?

17, What is grid in twitter boot strap?

18, Can you create a model with out inherit it from Active Record?exmple?

19, What is routes? Explain?

.....etc




@@@@@ ALL THE BEST @@@@





Thursday 8 May 2014

GIT BRANCHING AND SIMPLE MERGING COMMANDS


Branching

$git branch: git branch list your available branches.

The branch that you are currently working on will have a star next to it.
$ git branch
*master
This means that we have a 'master' branch and we are currently on it.
$git branch (branchname): Create a new branch.
$ git branch testing
$ git branch
* master
  testing
$ git checkout (branch name) : To switch to a branch.
$ git checkout testing
switched to branch 'testing' .
Simple Example:
$ ls
README hello.rb
$ echo 'test content' > test.txt
$ echo 'more content' > more.txt
$ git add *.txt
$ git commit -m 'added two files'
[master 8bd6d8b] added two files
2 files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 more.txt
create mode 100644 test.txt
$ ls
README hello.rb more.txt test.txt
$ git checkout testing
Switched to branch 'testing'
$ ls
README hello.rb
So now we can see that when we switch to the 'testing' branch, our new files were removed. We could switch back to the 'master' branch and see them re-appear.
$ ls
README hello.rb
$ git checkout master
Switched to branch 'master'
$ ls
README hello.rb more.txt test.txt

$git checkout -b (branchname): Create and immediately switch to a branch.

$git branch -d (branchname): Delete a branch
EX: $git branch -d testing
$git branch
master *
Note: Here testing branch has been removed.
$ git push origin <name_of_your_new_branch>:Push the branch on github.



Merging


Simple Example:
$ git branch
* master
$ ls
README hello.rb more.txt test.txt
$ git checkout -b removals
Switched to a new branch 'removals'
$ git rm more.txt
rm 'more.txt'
$ git rm test.txt
rm 'test.txt'
$ ls
README hello.rb
$ git commit -am 'removed useless files'
[removals 8f7c949] removed useless files
2 files changed, 0 insertions(+), 2 deletions(-)
delete mode 100644 more.txt
delete mode 100644 test.txt
$ git checkout master
Switched to branch 'master'
$ ls
README hello.rb more.txt test.txt
Once you have work isolated in a branch, you will eventually want to incorporate it into your main branch. You can merge any branch into your current branch with the git merge command. Let's take as a simple example the 'removals' branch from above. If we create a branch and remove files in it and commit our removals to that branch, it is isolated from our main ('master', in this case) branch. To include those deletions in your 'master' branch, you can just merge in the 'removals' branch.
$ git branch
* master
removals
$ ls
README hello.rb more.txt test.txt
$ git merge removals
Updating 8bd6d8b..8f7c949
Fast-forward
more.txt | 1 -
test.txt | 1 -
2 files changed, 0 insertions(+), 2 deletions(-)
delete mode 100644 more.txt
delete mode 100644 test.txt
$ ls
README hello.rb


***************ALL THE BEST*********************

HOW TO PUSH A SIMPLE APPLICATION IN TO GITHUB

  HOW TO PUSH A SIMPLE APPLICATION INTO GITHUB

Step 1: First create a new rails application in your local system.
EX: I was created one application in projrcts folder i.e, ~/projects/deviseauth
Step 2: Open the terminal and go to your application location.
ctrl+alt+t -------> To open the terminal
@ubuntu:~$cd projects
@ubuntu:~/projects$ cd deviseauth
Step 3: Initialize empty git repository.
@ubuntu:~/projects/deviseauth$ git init
you will see fallowing text on terminal.
Initialized empty Git repositoryin ~/projects/deviseauth/.git/
Step 4: To add all subsequent resources(on which you have made changes) under that folder to GIT's version control for commit.
@ubuntu:~/projects/deviseauth$ git add.
Step 5: To commit all the changes
syntax: $ git commit -m "simple message"
@ubuntu:~/projects/deviseauth$ git commit -m "new rails app"
Step 6:Go to your github account and create a new repositary give a name here my repositary name is “deviseauth”.
Step 7:
Syntax: $ git remote add [any name] [ path of remote repo]
git remote add is to add a "short name", such as origin, and it can be any name as well, which is like an alias to a URL. And origin is the usual path of where the remote repo points to.
@ubuntu:~/projects/deviseauth$ git remote add origin https://github.com/sarithachakilala/deviseauth.git
Step 8:To push your application to github
@ubuntu:~/projects/deviseauth$ git push -u origin master
It will ask your github account username and password.
[Note: The push operation is performed when the total work of your remote contains locally otherwise it gives fallowing error message. Error:failed to push some refs to 'https://github.com/sarithachakilala/deviseau hint: Updates were rejected because the remote contains work that you do nt have locally.]
At that time you need to perform step 9.
Step 9:Pull your remote work to your local application.
@ubuntu:~/projects/deviseauth$ git pull origin master
Step 10: Then try to perform push operation using step 8. It will works fine.


*********************HAPPY RAILS CODING****************

Wednesday 7 May 2014

SETUP GITHUB IN UBUNTU


Setup Github in Ubuntu

  It is a new hosted Git repository service that's being called a "social network" for programmers. It is basically a distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Step1 : You have to create your account at github and now you want to work with it from your terminal.
Step2 : (Setting up ssh keys)
Before you start installing Github, you should set up ssh keys:
 $cd ~/.ssh
If it says "bash: cd: ./.ssh:No such file or directory",it means its not generated and you should continue with step 3. But if it changes to ~/.ssh directory, continue from step 4. 
Step3 : open your terminal and type PRE.ctl { font-family: "Lohit Hindi",monospace; }P { margin-bottom: 0.21cm; }A:link  
   $ssh-keygen -t rsa -C "your_email@youremail.com"
You will get following lines: 'Generating public/private rsa key pair. Enter file in which to save the key(/Home/ubuntu/.ssh/id_rsa):' just press enter now it will ask you to enter passphrase note that passphrase you enter must be >4, otherwise you will have to repeat whole process again.
Ex:I enter here my name...saritha
Step4 : open the file id_rsa.pub from ~/.ssh/id_rsa.pub and copy whole content of that file.(or)
you can open that file from terminal by using command as
$gedit id_rsa.pub
copy whole data...(or)
copy it to the clipboard by usinning fallowing commands:$sudo apt-get install xclip
$xclip -sel clip < ~/.ssh/id_rsa.pub
Step5 : After copy of entire content. Open github site and login. go to “Account Settings” > Click “SSH Public Keys” > Click “Add another public key” paste it  into "key field" and title enter any title name. then press Add key.
Ex: Here I entered title name as SSH FOR UBUNTU.
Step6:
And now try to connect to github to see if everything is working:
$ssh-add ~/.ssh/id_rsa (here need to press enter)
$ssh git@github.com

It will ask per passwrd need to  type your password ( for the first time).
Step7:   (To configure git)
Now you have successfully setup ssh key and ready to install github in terminal.
to download a local copy of your code branch. You'll need to replace "username" with your GitHub user name and project name with the name of project on github.
Setup git with your name and email address
$git config --global user.name "Name Last Name"
$git config --global user.email "your_email@youremail.com"
$git config --global github.user your_username







*************HAPPY READING :-)******************





Tuesday 6 May 2014

Great Advantage with remote: true


usage of remote: true in rails

When we are running our rails application URL will be changed based on the page request.

EX:
/users             ------->  index
/users/[id]/edit------->  edit
/users/new      -------> new

Instead of changing address in the url we can make a simple ajax call by using
:remote=> true

Working with :remote=>true:


1. Include :remote=>true in all links of index page.

Here i am showing remote: true with New User link of index page

Ex: <%= link_to 'New User', new_user_path, :remote => true %>

#it will make a ajax call

Equivalent html Code :

<a data-remote=true href="/users/new">New User</a>

2.  Create a div tag with id in index page, in order to place your ajax response.

Ex: <div id="content"></div>

3. As an Ajax request, looking for JavaScript. In order to serve that request, the new  action of our controller would look like this:

Ex: 
# app/controllers/users_controller.rb
def new
    @user = User.new
    respond_to do |format|
     format.js
    end
 end


in rails4----    respond_to :js

4. Notice the format.js in the respond_to block; that allows the controller to respond to your Ajax request. You then have a corresponding app/views/users/new.js.erb view file that generates the actual JavaScript code that will be sent and executed on the client side.
Ex:
# app/views/users/new.js.erb
$('#content').html("<%= escape_javascript render 'ajaxform' %>")

5. The app/views/users/_ajaxform.html.erb partial contains the code for new form(i.e, _form.html.erb)
(or)
We can use directly form insted of ajaxform i.e,
$('#content').html("<%= escape_javascript render 'form' %>")








***********“Practice makes the master."*************