Saturday, 7 December 2013

Javascript and Jquery


http://www.learningjquery.com/2006/09/introducing-document-ready

   


JQUERY:
http://jqueryui.com/demos/
http://try.jquery.com/levels/1/challenges/3
http://coding.smashingmagazine.com/2012/05/31/50-jquery-function-demos-for-aspiring-web-developers/

========================
Simple Ajax call
-----------------
Note: Unable to call $(this) inside ajax so use local variable to access

  $('.make_fav').click(function(){
    var v_id=$(this).attr('id');
    var th = this  // create local var for THIS
    $.ajax({
        dataType: 'json',  // not jsonp
        url: "/favo",
        type: "get",
        data: { id : v_id }, // passing argument to the action
        success: function(response) {
          console.log(response.active)      // based on response change the class
            if (response.active==false){
              $(th).addClass('fav_ajax')
              $(th).removeClass('unfav_ajax')
            }else{
              $(th).addClass('unfav_ajax')
              $(th).removeClass('fav_ajax')
            }
        }
    });

  })
===========================
=>What is prototype property in javascript?
To add new attribute to an object
object.prototype.name=value
ex: user.prototype.age = 28  #when there is no age.

=============

General Info


general info:
-------------
http://www.xe.com/ucc/         ===========>currency converter
http://www.kurnoolcity.com/       ==========>kurnool city passport
http://www.ap.nic.in/passport/APP-Coll.htm
http://lanyrd.com/2011/gogaruco/shmhw/  ==>videos for testing
site id's:
----------
->alaramanaiah/aug1985  =====>basecamp


:pserver:ramana@122.183.217.135:2401/Sayagame      ====> SAYAGAME CHECKOUT

RAILS_ENV=stage rake db:migrate



http://stage-stutalk.heroku.com/user

paypal sandbox =============>https://developer.paypal.com/cgi-bin/devscr?cmd=_logout


http://git-scm.com/        ==========>git site( repository)
alaramanaiah@dckap.com,58aanamar



http://www.ipadpeek.com/                ============>ipad simulator
http://iphonetester.com/


http://www.tutorialized.com/view/tutorial/Develop-iPhone-apps-using-Ruby-on-Rails/36116

iphone applicaions using ruby on rails


general:
---------
Virus – Vital Information Resources Under Seize.

NASA – National Aeronautics Space Administration

ISRO – Indian Space Research Organisation

Computer – Commonly Operating Machine Particularly Used for Technology Entertainment and Research

Google - Global Organization of Oriented Group Language of Earth
http://122.183.217.145/sayagame/faq.html     =====>sayagame
amazon login Username: webdev@stutalk.com Password: StuAMAZ11

BLOGS FOR rubyonrails:
=====================
1)stackoverflow
2)railscasts/asciicasts
3)rubygems
4)edgeguides
5)api.rubyonrails.org
6)rorexperts
7)github
8)rails google groups
9)railsforum
10)rubyforge
11)rails.nuvvo.com
12)allinterview.com
13)rubyinside.com
14)rubyflow.com
15)gems.github.com
16)rails.rubyonrails.org
17)ruby.railstutorial.org

Server


Nginx server ip's & errors statistics:
=========================
=> tail -f /mnt/errors/access.log | ngxtop top remote_addr => Shows IP'S list of users
=> ngxtop -i 'status >= 502' print request status http_referer -l /mnt/errors/access.log =>Shows for which pages we get 502 error
=>ngxtop -l /mnt/errors/access.log => Shows all types of errors from log




=>configure mongrel_cluseter?
Set up a mongrel cluster
Configure 2 or three ports for the mongrel cluster
Create a map file for my random load balancer
Set up a way to restart the cluster if the server reboots
Configure Apache to forward requests to the mongrel cluster
Configure capistrano to deploy the application.
================================
=>How can you generate sitemaps for your Rails site?
You can use dynamic_sitemaps gem to generate sitemaps
How can you show search user friendly urls instead of using only numeric ids?
The simplest way to do this is to use the gem FriendlyID.
It gives you the ability to specify a friendly URL for pages so that instead of the standard page URLs like:
http://mysite.com/page/1
You can build pages such as:
http://mysite.com/page/my-awesome-page-about-articles-and-content
How can you create page titles and metadata for your pages?
You can use the Headliner plugin for adding page titles.
You can use the MetaMagic plugin to add meta tags.
How can you create breadcrumbs on your pages?
Gretel is a great plugin to introduce breadcrumbs in your Rails application.
Another very simple implementation is breadcrumb_on_rails.
Architecture Related Questions
This questions can be from different angles like: quality, security, scalability, manageability, interoperability, reusability and all the other ilities you name! Here are a few example questions:
Is Rails scalable?
Yes Rails gives you complete freedom to use all traditional means of scaling an application. Things like memcached, caching full pages, caching fragments are all supported.
You can use any standard CDN to serve your media and static content as well.
Database scaling using sharding is supported.
Finally heroku makes your life easier by giving you the flexibility to scale up/down based on your need. Mostly websites have a peak time during which you need more servers and then there is a sleep time. Heroku makes that on-demand scaling process simpler. Companies such as HireFireApp.com makes the autoscale process easier.
============================================
=>How can you safeguard a rails application from SQL injection attack?
User.first("login = '#{params[:name]}' AND password = '#{params[:password]}'")
 SELECT * FROM users WHERE login = '' OR '1'='1' AND password = '' OR '2'>'1' LIMIT 1

  User.where("login = ? AND password = ?", entered_user_name, entered_password).first
 User.where(:login => entered_user_name, :password => entered_password).first

=============================================




create branch in heroku:
{from git
commit all changes to current branch => authenticaion

move changes to from git to heroku:
gem install heroku
heroku login
heroku create qjitsu-staging
git push heroku authentication:master
git remote add heroku git@heroku.com:qjitsu-staging.git
heroku keys
heroku keys:remove ramanaa85@mail.com


remove branch in local:
$ git branch -D branch_name

remove branch which is in remote:
$git push origin :branch_name
$git remote prune origin

============


ruby by satishtalim:
http://rubylearning.com/satishtalim/ruby_overriding_methods.html
paperlicp:
http://gkunwar1.wordpress.com/2012/06/25/how-to-upload-file-using-paperclip-in-rails/


HAML:
http://haml.info/docs/yardoc/file.REFERENCE.html


**Ubuntu on windows7 with VMWare:
=>  http://www.howtogeek.com/howto/11287/how-to-run-ubuntu-in-windows-7-with-vmware-player/
=>  http://linux.softpedia.com/get/System/Operating-Systems/Linux-Distributions/Ubuntu-Precise-Pangolin-76997.shtml


capistrano:
https://github.com/capistrano/capistrano/wiki/2.x-Getting-Started

rspec testing:
http://spitfiresky.com/blog/how-you-should-be-doing-testing-in-rails.html
http://railsapps.github.io/tutorial-rails-devise-rspec-cucumber.html

javascriptclient side validations:
http://webtempest.com/easy-client-side-form-validation-for-rails-3-1/

javascript client side validations:
http://www.javascript-coder.com/html-form/javascript-form-validation.phtml

**mobile application development:
http://www.tobiascohen.com/articles/2012/07/01/creating-a-mobile-version-of-your-rails-site/
http://stackoverflow.com/questions/5126085/ruby-on-rails-mobile-application/5130756#5130756

basics => http://www.rubyinside.com/21-ruby-tricks-902.html

authentication =>http://rubysource.com/rails-userpassword-authentication-from-scratch-part-ii/

aptana: http://www.pixelite.co.nz/article/installing-aptana-ubuntu-1204




==================================

=>google api key:
https://code.google.com/apis/console/#project:300004415644:access
http://railscasts.com/episodes/241-simple-omniauth?view=asciicast (omniauth-twitter)

twitter api key
https://dev.twitter.com/apps/4355889/show

facebook:
https://developers.facebook.com/apps/515338231858750/summary?save=1
================
=>Why rails slow?

Rails applications can run slowly for few fundamental reasons. The first is simple: Rails makes assumptions for you to speed up development. Usually, these assumptions are correct and helpful. They are not always beneficial for performance, however, and they can result in an inefficient use of resources — particularly database resources.
For example, ActiveRecord selects all fields on a query by default, using a SQL statement equivalent to SELECT *. In situations with a large number of columns — particularly if some are large VARCHAR or BLOB fields — this behavior can be a significant problem in terms of memory usage and performance.
Another significant challenge is the N+1 problem, which this article examines in detail. Essentially, this results in many small queries being performed, rather than one large query.ActiveRecord has no way to know that, for example, a child record is being requested for each of a set of parent records, so it will produce one child record query for each parent record. Because of per-query overhead, this behavior can cause significant performance issues.
==================

=>google api key:
https://code.google.com/apis/console/#project:300004415644:access
http://railscasts.com/episodes/241-simple-omniauth?view=asciicast (omniauth-twitter)

twitter api key
https://dev.twitter.com/apps/4355889/show

facebook:
https://developers.facebook.com/apps/515338231858750/summary?save=1
=======================

pg_dump -C -h localhost -U postgres myapp_production | psql -h 111.22.33.44 -U postgres myapp_production

mysql dis-adv's
=>A subquery with a depth of 3 levels cannot be optimized by MySQL anymore and is executed on every row.
=> time fields do not record milliseconds
=>multiple engines and one server layer

=>postgres =>full text search good,only one server layer


New Relic for ROR performance

Ruby core concepts


=>rho mobile
http://www.slideshare.net/Anubavam/rails-to-rhomobile

=>Capistrano deployment
http://robmclarty.com/blog/how-to-deploy-a-rails-4-app-with-git-and-capistrano

=>ruby docs
http://www.ruby-doc.org/core-2.0.0/Struct.html

=>jquery questions
http://www.codeproject.com/Articles/618484/Latest-jQuery-interview-questions-and-answers

=>ruby method_missing
Ruby's define_method, method_missing, and instance_eval

=>html elements
https://developer.mozilla.org/en-US/docs/Web/HTML/Element

=>Heroku
http://railsapps.github.io/rails-heroku-tutorial.html

https://devcenter.heroku.com/articles/getting-started-with-rails4

=>Mongodb
http://docs.mongodb.org/ecosystem/drivers/ruby/

=>Turbolinks
http://geekmonkey.org/articles/28-introducing-turbolinks-for-rails-4-0

=>ruby 1.9 vs 2.0 vs 1.8
http://slideshow.rubyforge.org/ruby19.html#1

http://globaldev.co.uk/2013/03/ruby-2-0-0-in-detail/

=>facebook with koala
https://github.com/arsduo/koala




Sendmail:
=========
/sbin/service
/etc/init.d/sendmail
locate sendmail

==========================
HOSTING THE SITE:
=================
sudo gem install mongrel –include-dependencies
sudo gem install mongrel_cluster
mongrel_rails cluster::configure -p 8001 -e production -a 127.0.0.1 -N 3
mongrel_rails cluster::start
mongrel_rails cluster::status
mongrel_rails cluster::stop
mongrel_rails cluster::restart
Nginx/APACHE-load balancing and fault tolerance
Apache and Nginx can serve static files faster
Apache/Nginx will take care of distributing requests between the instances in the cluster(mongrel).
sudo mongrel_rails cluster::configure -e production -p 3010 -N 2 -c /home/corti/Documents/ror/myapp -a 127.0.0.1 --user mongrel --group mongrel
mongrel_rails cluster::configure -e production -p 8000 -N 2 -c /home/demo/public_html/railsapp -a 127.0.0.1
-N=>2 processes
-a=>127.0.0.1  (@)
-p=>ports( 3010 and 3011)
-c=> /home/corti/Documents/ror/myapp  path of the appplication
cluster= collection of ports
(http://stackoverflow.com/questions/4113299/ruby-on-rails-server-options)
webrick(ruby),mongrel(c and ruby),thin,Phusion Passenger(c++),
Phusion Passenger can start any no. of processes for you when your site becomes busy, not like mongrel only a perticular ports
Capistrano:here "deployment" refers to doing all this preparation work to run the application(is not an application server.)==>replacement for FTP
http://articles.slicehost.com/2007/9/28/ubuntu-feisty-apache-vhosts-rails-and-mongrels

==================
s/w projects developement types:
===============================
t&m =
retain = vertis(everyday 16hrs)
fixed bid = sayagame,cherry branch gallery(fixed for 80hrs)


rails deployment servers:-
========================
slicehost,kattare,capistrono,dreamhost,go-daddy,heroku,amazon s3

http://ariejan.net/2011/09/14/lighting-fast-zero-downtime-deployments-with-git-capistrano-nginx-and-unicorn   =>deployments with git, capistrano, nginx and Unicorn
https://github.com/capistrano/capistrano/wiki/2.x-From-The-Beginning =====>capistrano deployment


http://www.rorexperts.com/rvm-installation-on-ubuntu-10-04-version-t2211.html
http://stjhimy.com/posts/10-five-quick-steps-to-set-up-rvm-with-rails-2-and-rails3
http://www.rubyinside.com/rvm-ruby-version-manager-2347.html

desiga: 0011+9566655680
http://railsapps.github.com/installing-rails-3-1.html

http://telugudictionary.telugupedia.com/

http://ubuntuguide.net/install-firefox-7-stable-in-ubuntu-11-1010-0410-10 ==> to update FIREFOX browser



application controller: stop back button:
before_filter :set_cache_buster

def set_cache_buster
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end

mongrel_rails cluster::start -C /home3/s/smcampbell/public_html/nanohygienics_pr/config/mongrel/production.yml

http://www2.elc.polyu.edu.hk/CILL/speaking.htm        ==========> spoken english


http://sidorovis.blogspot.com/2011/02/ruby-gems-errnoetimedout-issue-solution.html => gem is not installing

http://www.railsecommerce.com/           ============>rails e-commerce applications

http://en.wordpress.com/tag/ruby-on-rails-ror/           -==> tuts of ror while mutiple dbs connections


http://www.slideshare.net/wycats/jquery-presentation-to-rails-developers-110063   ====> for jquery

http://www.slideshare.net/mokolabs/haml-and-sass-in-15-minutes    ========> haml and sass:video tutorails

http://rails.nuvvo.com/lesson/6380-action-controller-streaming-and-file-downloads ===> rails tutorials

http://wowkhmer.com/2011/09/19/unobtrusive-ajax-with-rails-31/          ===========>3.1 tuts,ajax
gnome-open      =>to open website

http://www.blog.bridgeutopiaweb.com/post/how-to-install-rvm-and-rails-3-on-snow-leopard/ ==>RVM

http://magicmodels.rubyforge.org/magic_multi_connections/             => multiple db connections

http://rails-erd.rubyforge.org/install.html    ==> rails E-R diagrams
rake erd orientation=horizontal title='Global Brand Assurance ERD' filename="BA_ERD_rough" indirect=true notation=bachman attributes=foreign_keys,primary_keys,timestamps,inheritance,content

http://tutorvideo.org/ =>video tutorials

https://help.ubuntu.com/community/PostgreSQL                   =====> postgresql

git repo-config --get-regexp user.    ->          ====> git command to find system username
user.name ROR Dev2
user.email deepaks@dckap.com

http://ruby.railstutorial.org/chapters/updating-showing-and-deleting-users#top       ==>RUBY ON RAILS TUTORAILS



http://chat.stackoverflow.com/rooms/24/ruby-rails         =========>stack overflow chat

http://www.alfajango.com/blog/rails-3-remote-links-and-forms/  =======>rails 3.1 jquery and ajax

wine 'C:\Program Files\Internet Explorer\iexplore'      =>cmd to open ie
http://twitter.rubyforge.org/
https://dev.twitter.com/docs/tweet-button
http://www.paolocorti.net/2007/11/08/ruby-on-rails-applications-with-mongrel-clusters-and-apache-on-ubuntu/     =====>deployment
git --version     =>to find git version installed on system
http://kibyegon.wordpress.com/2010/05/13/how-to-install-git-on-ubuntu-lucid-10-04/

http://coding.smashingmagazine.com/2009/02/25/ruby-on-rails-tips/     ====>tips for ror developers
http://www.webresourcesdepot.com/23-amazing-and-open-source-ruby-on-rails-applications/ ====>
23 different ror apps(cms,crm..)

http://mashable.com/2007/09/30/ruby-on-rails-toolbox/      ====> 23 different ror apps(cms,crm..)


http://dsal.uchicago.edu/dictionaries/gwynn/            =====>telugu -to- english site

how to go for mongrel/webrick             ==============> how to decide the server

=>admin-creation :http://stackoverflow.com/questions/2708417/creating-an-admin-user-in-devise-on-rails-beta-3

http://guides.rubyonrails.org/form_helpers.html           =>ajax in guides
http://edgeguides.rubyonrails.org/ajax_on_rails.html

http://www.ultrasaurus.com/sarahblog/2009/06/simple-web-services-with-rails/        ====>webservice
http://blog.complitech.net/web-services-basics-ruby-on-rails/
https://peepcode.com/        ======>screencasts
http://www.ibm.com/developerworks/opensource/library/os-ws-rubyrails/index.html
http://railscasts.com/episodes?utf8=%E2%9C%93&search=web+service

=>developing a game with Ruby using the Gosu and Chipmunk gems
Don't cry because it's over, smile because it happened


http://changelogshow.com/             ===========> audio tutorials
http://srikanthjeeva.blogspot.com/2010/04/thinking-sphinx.html      =====>thinking-sphinx
http://railsapps.github.com/rails-heroku-tutorial.html              ===>heroku
http://peepcode.com/products/phusion-passenger       ========>phusion-passenger
http://devcenter.heroku.com/articles/rails3

crm tools for rubyonrails:
=========================
1)Fat Free            http://www.fatfreecrm.com/
2)XLsuite             http://xlsuite.org/
3)salesforce          http://www.salesforce.com/platform/cloud-infrastructure/integration.jsp
4)cohort
5)mongo




SERVER:
========
cat /etc/httpd.conf | more
cat /etc/httpd-2.2/httpd.conf | grep 10505
ps ax | grep ru
ps ax
tail -100f production.log
/home3/s/smcampbell/conf/apache2.conf
ror tuts "http://rubymonk.com/"



cms tools for rubyonrails:-
==========================
1)Radiant cms
2)Refinery cms
3)adva-cms
4)BrowserCMS
5)locomotive


===============================

Scalability:
===========
http://nerdfortress.com/2008/05/13/ruby-on-rails-pros-cons-lets-get-real/
= put a Nginx load balancing reverse proxy in front and then choose your framework, this allows you to add in a pretty well unlimited number of instances. If you care about hardware and electricity costs then go for a more efficient stack. The key part is intelligent cache's.


AGILE AND SCRUM:
===============
http://www.questions-interviews.com/software-development-testing-models/scrum.aspx#what_is_the_difference_between_agile_and_scrum_development


SEO (search engine optimization):
================================
Headliner for titles
Metamagic for meta tags
Gretel for breadcrumbs
FriendlyId for friendly URLs
Dynamic Sitemaps for sitemaps
- See more at: http://www.railsant.com/rails-seo-pack-5-plugins-optimize-site/#sthash.JAyRTS7P.dpuf

RSPEC


=>context vs describe?
According to the rspec source code, “context” is just a alias method of “describe”, meaning that there is no functional difference between these two methods. However, there is a contextual difference that’ll help to make your tests more understandable by using both of them.

The purpose of “describe” is to wrap a set of tests against one functionality while “context” is to wrap a set of tests against one functionality under the same state. Here’s an example

===================================
=>shared examples?
Making tests is great and you get more confident day after day. But in the end you will start to see code duplication coming up everywhere. Use shared examples to DRY your test suite up.

===================================
=>Expect vs Should syntax ?

On new projects always use the expect syntax

===================================
=>Use subject?

If you have several tests related to the same subject use subject{} to DRY them up.
BAD
it { expect(assigns('message')).to match /it was born in Belville/ }
it { expect(assigns('message').creator).to match /Topolino/ }
GOOD
subject { assigns('message') }
it { should match /it was born in Billville/ }
===================================
=>Automatic tests with guard?

Running all the test suite every time you change your app can be cumbersome. It takes a lot of time and it can break your flow. With Guard you can automate your test suite running only the tests related to the updated spec, model, controller or file you are working at.

GOOD
bundle exec guard
====================================
=>Stubbing HTTP requests?

Sometimes you need to access external services. In these cases you can't rely on the real service but you should stub it with solutions like webmock.

GOOD
context "with unauthorized access" do
  let(:uri) { 'http://api.lelylan.com/types' }
  before    { stub_request(:get, uri).to_return(status: 401, body: fixture('401.json')) }
  it "gets a not authorized notification" do
    page.driver.get uri
    expect(page).to have_content 'Access denied'
  end
end
===========================================
=>Useful formatter?

Use a formatter that can give you useful information about the test suite. I personally find fuubar really nice. To make it work add the gem and set fuubar as default formatter in your Guardfile.

GOOD
# Gemfile
group :development, :test do
  gem 'fuubar'
===========================================
=>mock vs stub?
Both mock and stub are aliases of the more generic double. Like context and describe, they can be used interchangeably to make the intent of the specs more clear. This is described in a lot more detail in The RSpec Book.
================


cucumber vs rspec?
http://stackoverflow.com/questions/1700970/tdd-bdd-rails-cucumber-rspec-duplication
http://stackoverflow.com/questions/11762245/whats-the-difference-between-rspec-and-cucumber

==============

HTML


NEW TAGS IN HTML5:
==================
<article>New Defines an article
<aside>New Defines content aside from the page content
<audio>New Defines sound content
<bdi>New Isolates a part of text that might be formatted in a different direction from other text outside it
<canvas>New Used to draw graphics, on the fly, via scripting (usually JavaScript)
<command>New Defines a command button that a user can invoke
<datalist>New Specifies a list of pre-defined options for input controls
<details>New Defines additional details that the user can view or hide
<embed>New Defines a container for an external application or interactive content (a plug-in)
<figcaption>New Defines a caption for a <figure> element
<figure>New Specifies self-contained content
<footer>New Defines a footer for a document or section
<header>New Defines a header for a document or section
<hgroup>New Groups heading (<h1> to <h6>) elements
<keygen>New Defines a key-pair generator field (for forms)
<mark>New Defines marked/highlighted text
<meter>New Defines a scalar measurement within a known range (a gauge)
<nav>New Defines navigation links
<output>New Defines the result of a calculation
<progress>New Represents the progress of a task
<rp>New Defines what to show in browsers that do not support ruby annotations
<rt>New Defines an explanation/pronunciation of characters (for East Asian typography)
<ruby>New Defines a ruby annotation (for East Asian typography)
<section>New Defines a section in a document
<source>New Defines multiple media resources for media elements (<video> and <audio>)
<summary>New Defines a visible heading for a <details> element
<time>New Defines a date/time
<track>New Defines text tracks for media elements (<video> and <audio>)
<video>New Defines a video or movie
<wbr>New Defines a possible line-break


Global Attributes:
==================

contenteditableNew Specifies whether the content of an element is editable or not
contextmenuNew Specifies a context menu for an element. The context menu appears when a user right-clicks on the element
draggableNew Specifies whether an element is draggable or not
dropzoneNew Specifies whether the dragged data is copied, moved, or linked, when dropped
hiddenNew Specifies that an element is not yet, or is no longer, relevant
spellcheckNew Specifies whether the element is to have its spelling and grammar checked or not




Not in HTML5:
======================
<acronym>
<applet>
<basefont>
<big>
<center>
<dir> Not supported in HTML5
<font> Not supported in HTML5
<frame> Not supported in HTML5
<noframes> Not supported in HTML5
<frameset> Not supported in HTML5
<strike>
<tt>

Errors


==>E)NameError in CategoriesController#index
uninitialized constant ApplicationController
A) application.rb to application_controller.rb


==>ActiveRecord::RecordNotFound in ProductsController#show
Couldn't find Product with ID=nw
A)url problem



200..399 - Valid response, no exception (other than 301, 302)

301, 302 - ActiveResource::Redirection

400 - ActiveResource::BadRequest

401 - ActiveResource::UnauthorizedAccess

403 - ActiveResource::ForbiddenAccess

404 - ActiveResource::ResourceNotFound

405 - ActiveResource::MethodNotAllowed

409 - ActiveResource::ResourceConflict

410 - ActiveResource::ResourceGone

422 - ActiveResource::ResourceInvalid (rescued by save as validation errors)

401..499 - ActiveResource::ClientError

500..599 - ActiveResource::ServerError

Other -
=======
=>ActiveResource::ConnectionError

=>You have a nil object when you didn't expect it!

Database


=>Diff b/w myisam and innodb

Myisam:(befor 5.5.5 default engine for mysql)
      Table level locking
      No ordering in storage of data
      Not *ACID compliant,no foreign key support and non-transactional
      reading records fast

Innodb:(default as of 5.5.5)
      Row level locking
      Row data stored in pages in PK order
      *ACID compliant and hence fully transactional with ROLLBACK and COMMIT and support for Foreign Keys
      reading records slow
ALTER TABLE <table-name> ENGINE=INNODB;    
==================================
=>Diff b/w primary key vs unique key?
A primary key must be unique.

A unique key does not have to be the primary key - see candidate key.

That is, there may be more than one combination of columns on a table that can uniquely identify a row - only one of these can be selected as the primary key. The others, though unique are candidate keys.

 there can be only one primary key for a given table, while there can be many unique keys.

 primary key cannot be NULL

 ====================================
 =>diff b/w mysql and postgresql?
 dates format different

mysql:
 #comment
 "
 case insensitive
 Only follows some of the ANSI SQL standards
 Faster
 No Foreign key support
 No Sub-selects
 Transactions  with innodb engine only


 postgresql:
 -- comment(ANSI standard)
 '
 case sensitive
 Slower
 Closer to ANSI SQL standard
 Have Foreign key support
 Have Sub-selects
 Have Transactions support
 ==========================
 =>rdbms vs nosql?
=RDBMS is completely structured way of storing data.NoSQL databases also have a structure to store data, but these structures are less strict as relational schema, so it became a better choice to some applications.
= the amount of data stored mainly depends on the Physical memory of the system. While in the NoSQL you don't have any such limits as you can scale the system horizontally.
=It's important to say that NoSQL databases are a complement in database field, and not a replacement for RDBMS.
=Graph Databases is also a very popolar NoSQL database. . Examples of the popular graphical database are Neo4j,
= OrientDB, InfiniteGraph, AllegroGraph etc.
=Facebook uses open sources the Cassandra
=NoSQL stands for "Not only SQL"
=E.g. graph databases like Neo4j, document databases like CouchDB and object databases like db4o.
=================================


   
postgresql?
https://help.ubuntu.com/8.04/serverguide/postgresql.html
http://www.thegeekstuff.com/2009/04/15-practical-postgresql-database-adminstration-commands/
 $sudo su postgres
 $psql
 $\l =>lists all databases
 $\c =>switch database
 $select current_database();

 $ CREATE USER alaramana WITH password 'password';
 $ CREATE DATABASE mydb WITH OWNER alaramana
============
===========
Install mysql?
sudo apt-get install libmysqlclient-dev, mysql-server, mysql-client
============

install sqlite3?
sudo apt-get install sqlite3 libsqlite3-dev
sudo gem install sqlite3-ruby

============

postgresql backup
=================
 $ pg_dump mydb > db.sql #To dump a database called mydb into a SQL-script file:
 $ psql -d newdb -f db.sql  #To reload such a script into a (freshly created) database named newdb:
============================
join vs include in sql?
=>The difference between joins and include is that using the include statement generates a much larger SQL query loading into memory all the attributes from the other table(s).
For example, if you have a table full of comments and you use a :joins => users to pull in all the user information for sorting purposes, etc it will work fine and take less time than :include, but say you want to display the comment along with the users name, email, etc. To get the information using :joins, it will have to make separate SQL queries for each user it fetches, whereas if you used :include this information is ready for use.

:joins returns read-only objects, :includes does not

:joins uses inner join, :includes uses outer join.

the main reason of :includes is eager loading, to avoid the N+1 problem of loading in attributes of each object using a separate query.
=============

POSTGRESQL:
===========
https://help.ubuntu.com/community/PostgreSQL
https://help.ubuntu.com/8.04/serverguide/C/postgresql.html

==================
mysql engine
SELECT table_schema,engine FROM information_schema.tables WHERE table_name='resources';


$mysql> SELECT * FROM mysql.user;      ==>to find list of users for mysql database
http://www.pantz.org/software/mysql/mysqlcommands.html    ======>mysql commands



postgresql:
===========
http://olmonrails.wordpress.com/2008/08/12/switching-rails-to-postgresql/
sudo -u postgres psql
\l
=>To find list of db's
\connect <database_name>         ==>to switchover to another database

sudo su
su postgre
psql


========
Rename mysql database name:
mysqldump -u username -p -v olddatabase > olddbdump.sql
mysqladmin -u username -p create newdatabase
mysql -u username -p newdatabase < olddbdump.sql