Rock Mongo look similar to Popular phpmyadmin and built itself in php.

Feature of RockMongo :

a) Open Source

b) User Login and Multiple Host support with multiple database.

c) Facility for Database creation, deletion

d) Database Transfer  , import, export database

e) Document modify, delete, select

f) Query analyzer and Query Explanation tool.

Installation of RockMongo on Ubuntu

1) First Install Php and apache2 with below command i have mentioned:

sudo apt-get install apache2 php5 php-pear

2) Apache will run on port no: 80 by default. If you have any server running on port 80, change you can change port of apache by editing /etc/apache2/ports.conf.

3) You’ll need to install the PHP Mongo connector: Install it with below mentioned command :

In older version of ubuntu :

you need to type following command:

sudo pecl install php_mongo 

In later version(12.04), you will need to run following command:

sudo pecl install mongo   

4)    Add “extension=mongo.so” to the “Dynamic Extensions” section of /etc/php5/apache2/php.ini and restart Apache with sudo service apache2 restart

5) Download latest version of RockMongo from its official website “http://code.google.com/p/rock-php/downloads/list” and unzip it in /var/www.

6) Open browser and put “http://localhost/rockmongo/index.php” address in address bar and you will be login page and Username and password is “admin”

Enjoy its:

Have any question  just mail me : narutosanjiv@gmail.com

What are bindings?

Binding is one of important concept of ruby programming.
This concept is widely used in proc/lambda implementation.

I am explaining this concept with help of example of code:

 

In Procedural and compiled language like c , scope is important concept.

For example , taking the example of c code

 

function add(a, b)

   int c = a + b;       

   printf(“%d”, c); 

}

int main(){
int var1 = 1, var2 = 2;
add(var1, var2);
}

 Since program is simple passing variable is does not much overhead;
consider program in which you have to pass 20-25 variable from one function to another function like
def(int va1, int var2, int var3 , …………)
{

}
Above example mean you can not access variable outside your function scope , if you want access variable outside your function scope , then you have declared them as global variable but it is not recommended to declare variable as global .

Binding In Ruby:
It’s what’s used in Ruby to bind a variable to a block and have the block access it even after the variable went out of scope in the original code block, or the variable is re-defined in a new block. Here is some code to make it clear:

Explaning through code :

 

def scope_variable(scope_resolution)
a= 20
eval “a”, scope_resolution

end

a = 10

scope_variable(binding)

“This will print value = 10 “

binding is ruby variable return current scope .
In this , binding refer to main scope. So , while printing , a is evaluated as 10 rather than 20.

This concept is used is lambda/ proc implemetation.

 

For example :

a = 10
b = 20
sum = lambda{ put a + b}

def add(call_f)
a = 30
b = 50
call_f.call
end

add(sum)

Using the concept of binding lambda save  a and b as per scope and eval as a = 10, b = 20 when block.call is called from function. 

 

 

 

 

 

What are bindings?

Binding is one of important concept of ruby programming.
This concept is widely used in proc/lambda implementation.

I am explaining this concept with help of example of code:

 

In Procedural and compiled language like c , scope is important concept.

For example , taking the example of c code

 

function add(a, b)

   int c = a + b;       

   printf(“%d”, c); 

}

int main(){
int var1 = 1, var2 = 2;
add(var1, var2);
}

 Since program is simple passing variable is does not much overhead;
consider program in which you have to pass 20-25 variable from one function to another function like
def(int va1, int var2, int var3 , …………)
{

}
Above example mean you can not access variable outside your function scope , if you want access variable outside your function scope , then you have declared them as global variable but it is not recommended to declare variable as global .

Binding In Ruby:
It’s what’s used in Ruby to bind a variable to a block and have the block access it even after the variable went out of scope in the original code block, or the variable is re-defined in a new block. Here is some code to make it clear:

Explaning through code :

 

def scope_variable(scope_resolution)
a= 20
eval “a”, scope_resolution

end

a = 10

scope_variable(binding)

“This will print value = 10 “

binding is ruby variable return current scope .
In this , binding refer to main scope. So , while printing , a is evaluated as 10 rather than 20.

This concept is used is lambda/ proc implemetation.

 

For example :

a = 10
b = 20
sum = lambda{ put a + b}

def add(call_f)
a = 30
b = 50
call_f.call
end

add(sum)

Using the concept of binding lambda save  a and b as per scope and eval as a = 10, b = 20 when block.call is called from function. 

 

 

 

 

 

sasasass

What is jsonp?

JSONP is complement to JSON base data format. It allows one to access different domain which is by default prevent by web browser due to security concern under same origin policy .

Under Same origin policy, if web pages served from one domain such as (example.com) can not access another domain(such as example2.com) except under// <![CDATA[
 tag inside  html element. This type of pattern is called JSONP.
// ]]>

JSONP does not mean response should be in json format, it mean any javascript in response can be easily executed.

AJAX request are made through javascript(or jquery) inside the//

Given below example of jquery-ajax request:

<html>

<head>

</head

<body>

// <![CDATA[
javascript" >
// ]]>

$(document).ready(function(){

$.ajax({
url: “ http://example.server1.com?callback=?”,
type: “POST”,
data: {“email”: username},
dataType: “JSONP”,
contentType: ‘application/json’,
success: function (data){
   book_details = JSON.parse(data)
},
error: function () {
$(‘#loading’).hide()
alert(‘Invalid Username/Password’)
}
});
</script>
</body>
</html>
code inside// <![CDATA[
tag just send request to another domain to retreive data from other domain.
// ]]>
 As you are seeing , format of url is like that appending callback query string at end of url. It is any regular parameter but passed with url when we are making JSONP request.
Callback query parameter can be anything (you can give like “http:://example.server1.com?callback=any_name”)
Response of server returning json data will
  “any_name([book:{id:1 , author: asas}])”
in success  function, you still get data [book:{id:1, author: asss}].
But Server should validates its access request before accessing that url .
In Rails 3:
     You have apply before filter
    Consider i have books_controller , there is cross domain request for returning json data from server.
 Either header not set or you not set dataType: JSONP , you will get following error
   ”Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers.”
The first request send by ajax is OPTIONS(instead of POST, GET what is you expected).
If you does not specify  server how to handle OPTIONS method, you will get error “specified routes not found”.
If  you have to mention that name of methods in config/routes.rb file :

match ‘some_url’ => ‘controller#action’, :via => ["options", "get", "post"]

then options request get handled in server side.
 SETTING HEADER IN RAILS 3 CONTROLLER :
   class ApplicationController <  ActionController::Base
            before_filter: set_access_control_headers
            def  set_access_control_headers
                    headers['Access-Control-Allow-Origin'] = ‘*’
                    headers['Access-Control-Request-Method'] = ‘*’
                    headers['Access-Control-Allow-Headers'] = ‘*’
                    headers['Access-Control-Allow-Credentials'] = “true”
            end
   end
Then you have to send response in correct format:
If you does not specify correct format, then you will get error in sucess event of ajax as ” Parsed error “.
RESPONDING TO JSONP REQUEST IN RAILS 3
          @book = Book.all
           books= @book.to_json
           respond_to do |format|
           format.json{render :json => books, :callback => params[:callback]}
           end
   it will construct respond in javascript as “params[:callback](books)”
If you does not understand any part of above explanation , please free mail me to “narutosanjiv@gmail.com”

As we all know rubyonrails is opensource project . so its not uncommon to have new feature added quickly. One of feature in Rails 3.1 is that you do not have to define up/down method for migration if you are going for reversible migrations. Reversible migration are those migration which can be easily reversible(revert like add_column, rename_column, create_table,etc) but if you are working on irreversible migration it will throw exception activerecord:irreversible:migration , so be careful of using change method , it is handy but using careless while using its can lead to database schema unwanted error 

 

class AddFirstName < ActiveRecord::Migration
  def change
    add_column :users, :first_name, :string
  end
end
since add_column is reversible migration

Normally We are using apt-get tool to just install any popular package, however we are least bothered

about  what version its install , since usually it install latest stable version of package from debian repository or from source mentioned  in “/etc/apt/sources.list”

Since in ubuntu 11.04 , postgresql 8.4 is installed when apt-get install postgresql is fired on console.

So, update your source list by issuing commands

1) sudo add-apt-repository ppa:pitti/postgresql

After you need to update your list of repository so that when you next issue apt-get it consider your new added source

2)sudo apt-get update

if you want to remove old postgresql remove by “sudo apt-get remove postgresql”

and manually remove config file of postgresql

Install postgresql 9.1.2(in my case)

3)sudo apt-get install postgresql

it will install successfully postgresql

After installing postgresql, you will need to run following command

4)sudo passwd postgres

Give password for postgres user(default user of postgresql)

5) su postgres

Change user in terminal

6) psql

you will be drop into postgres command prompt default database template1

if you want specify database name then

7)psql -d your_database_name

it will run nicely but for connecting through network

You have to change pg_conf.hba otherwise it will complain of “psql: Peer authentication failed for user ‘postgres’” so change pg_conf.hba file

find pg_hba.conf

8) locate pg_hba.conf

in my case location of pg_hba.conf was “/etc/postgresql/9.1/main/” but it can differ.

just open that file change authentication method “peer” to “trust”

if you any problem in installing postgresql , mail me at narutosanjiv@gmail.com

Follow

Get every new post delivered to your Inbox.