Sunday 26 May 2013

Quit Early, Quit Often

http://www.youtube.com/watch?v=D73mm29XXAw&t=0s

Today 25th of May 2013 was a sad day in life due to some personal reason but as I was going through my mail Inbox, I came across a video where Prof Deepak Malhotra whom i came to know only after watching the video.

I just loved the things which he told.

oh no, I have turned out to be a fan of him.

Friday 10 May 2013

Oh there are some things which you have promised to do.

Rails convention and tunning the application



http://opensoul.org/blog/archives/2012/05/23/why-our-code-smells/

http://adamsanderson.github.io/railsconf_2013/?full#26

http://blog.plataformatec.com.br/2011/02/understanding-the-latest-rails-benchmarks/

https://github.com/railsbp/rails_best_practices



PostgreSql


http://adamsanderson.github.io/railsconf_2013/?full#26

Sunday 5 May 2013

If you have any doubts over why we are doing something, you should ask someone immediately, or write them down to investigate later


Q:  Full text search

PostgreSQL
Elasticsearch
Sphinx - fully developed
Solr   - fully developed


How does rails index works ?


Facts:

map outputs an array with the ability to do some computational on it.

Facts:

user = User.where(:name => 'tapan')  --> It builds sql query
user.first --> Execute the query in other words it now talks with databases.

NameError
NoMethodError

Curiosity:  Just know commented on this video, waiting for approval

http://www.youtube.com/watch?v=mBXGBbEbXZY

Q. Why do we use symbol ?

 
bihar = {state: 'bihar', capital: 'patna'}

then, india.keys.map(&:object_id) => [163848, 3119208] (some arbitrary ids)

karnataka = {state: 'karnataka', capital: 'bangalore'}

india.keys.map(&:object_id) => [163848, 3119208] (some arbitrary ids)

Here it returns the same object id for keys(state, capital).

So it references the same symbol and thus saves memory.

Q. Why  does Symbol.all_symbols.include? :hello  

       always return true

   => It happens as because it will go and first check in the array whether this particular symbols exists ? and it happens to be present there then returns true : else it will be pushed to the array and then return true

Concatenation

1. puts "tapan" + "sharma"
2. puts "tapan".concat("sharma")
3. puts "tapan" "sharma"

Chaining if's

   
  puts "hello boy" if 1 == 1 if 2 == 2

Ruby zip method


order = %w{1 2 3 4}
animals = %w{ant bat cat dog elephant}
p order.zip(animals)
=> [["1", "ant"], ["2", "bat"], ["3", "cat"], ["4", "dog"]]
p Hash[order.zip(animals)]
=> {"1"=>"ant", "2"=>"bat", "3"=>"cat", "4"=>"dog"}

Array creation

a = [*1..8]

Json


 require 'json'

h = {a: 'apple', b: 'boy', c: 'cat'}
j h 
 => {"a":"apple","b":"boy","c":"cat"}

jj h  
=> {
  "a": "apple",
  "b": "boy",
  "c": "cat"
}

__method__ :

  check for method name.

source_location :

  this locates the method.

Difference between scopes and class method

http://blog.plataformatec.com.br/2013/02/active-record-scopes-vs-class-methods/

Method Look up in Ruby.

Very well explained and written.

http://blog.jcoglan.com/2013/05/08/how-ruby-method-dispatch-works/comment-page-1/#comment-11917"


StringInquirer is a subclass of String


Command to create dump and restore


  pg_dump dbname > outfile

 psql dbname < infile

 Take dump of some tables in postgresql

    pg_dump --table=tutor_invoices --table=students veritas_development > out.sql