Tuesday, September 20, 2011

Install ruby and rails.

Installing native libraries:



  • sudo apt-get install curl git zlib1g zlib1g-dev openssl



  • sudo apt-get install libpq-dev


Installing ruby version manager:


bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc

 

Close the terminal and reopen again (reload config) then install:

rvm pkg install zlib
rvm pkg install openssl

 

rvm install 1.9.2
rvm use 1.9.2 --default

 

Thursday, September 15, 2011

Meta keywords in google search engine

I used to use meta keywords extensively in my page. There come the time that I realised that I was totally confused.

Here I found an official article from Google . Google does not use the keywords meta tag in web ranking

visit this http://googlewebmastercentral.blogspot.com/2009/09/google-does-not-use-keywords-meta-tag.html

Wednesday, September 14, 2011

How to copy public key to remote server with just one command

I found that I copy my public key to remote server again and again, then I realise that I need a quicker way to do this.

After googling I found this very useful command.


ssh-copy-id user@remoteserver


ssh-copy-id : is the command

user : is the user of the remote server

remoteserver : is the server of destination

Add remote in mercurial

I need in some point to be able to add remote in hg

To do that go to the root of mercurial open .hg/hgrc and add these entries:

[paths]
default = ssh://hg@bitbucket.org/ilab/resource_mapper

remote1 = ssh://hg@bitbucket.org/ilab/resource_mapper_1


remote2 = ssh://hg@bitbucket.org/ilab/resource_mapper_2




The "default" is the  remote address that will be used when none is specified.

Tuesday, September 13, 2011

Trips for ruby new comers

I found that the following point can trip for ruby new comers:

  • Class definition is an executable code.

  • Only nil and false will be evaluated to false in conditional  statement.

  • A statement always return a value.

  • If the last statement is a value, we don't need the return keywords in a function definition.

  • Use   do  end for multiple line of block and { } same line  for one line code block.

  • { } is optional for hash attribute when it is located in the last parameter.


Next we will show the details of each in the next chapter.

Please comment if you think there is more point that trip you.

Monday, September 12, 2011

SEO rubyonrails

In your model override the to_param method. For instance
class Post < ActiveRecord::Base
def to_param
“#{id}-#{title.parameterize}.html”
end
end

Assume we have a post :
 @post = Post.create! :title => "simple SEO with rubyonrails",
:content => "blah blah ... "

In our view we call
link_to  "Detail", post_url(@post) # "1-simple-SEO-with-rubyonrails"

We get seo url pretty easy.

In our controller we simply call the find or where method as normal since Rails will convert the params[:id] to integer automatically :
@post = Post.where(["id=?", params[:id]) # or @post = Post.find(params[:id])