Saturday, January 29, 2011

How to Add Linkedin Profile Link / Button on blogger site

How to Add Linkedin Profile Link / Button on blogger site:

  • Get the code for Linkedin Profile Link / Button, copy the code.
  • Login at blogger.com.
  • Click on Design link of the blog you want to add the code.
  • It will open the page "Add and Arrange Page Elements" under Design -> Page Elements tab.
  • Click "Add a Gadget" link, scroll down to gadget "HTML/JavaScript" Gadget, paste the code and save the Gadget.

You will get the link /button visible on the site similar to the one you can see on my blog left panel.

How to Customize Profile Page Url on Facebook

I have a facebook account and my profile page is displaying url which is hard to remember. So I wanted to customize my profile page url which is easy to remember.

To customize the facebook profile page url, visit the page http://www.facebook.com/username/. There you will get the option to set the username that will be displayed in url. Check the availability of the username and set one of the name. I added it as "krritesh" and here is my http://www.facebook.com/krritesh.

Thursday, January 20, 2011

Getting error "Retrieving unmerged branches Error:" when trying to push Rails application code from RubyMine

Yesterday, when I was trying to push the Rails3 application code from RubyMine, I got a strange error.
Errors was:
Retrieving unmerged branches Error:
Process failed to start (git branch --no-color): com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/usr/local/git/bin/git" (in directory "C:\projects\rails3_app"): CreateProcess error=2, The system cannot find the file specified

Let me explain the scenario about this error in a bit more detail. I had cloned a Rails application and committed in git as a branch of that application. Then I took checkout on other system and modified the code. When I was trying to push my changes through RubyMine I got the above errors and I was not able to push the code.

After long time of google and findings, I found the solution myself.
Reason of the error was that when we open any Rails application through RubyMine, it creates a ".idea" folder and that folder was commited when creating the branch. And when I took checkout of the code, the ".idea" folder of another computer's RubyMine setting was cloned on another system which was creating error.

Solution was quite a simple one. I just closed the newly created Rails3 project on RubyMine and deleted the ".idea" folder of the application. Then again I opened the project and this time I was able to push my code changes. Main point to note here is that you need to close the project from RubyMine before deleting the folder or else RubyMine will create the old folder again if the project is not closed.


How to debug jQuery is getting properly loaded or not

 What is jQuery and why it is used?
 
jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. 
For details you can refer to http://jquery.com/

There are many Rails application in which I have used jQuery. Many times when jQuery is added to the application we aren't able to run it properly. Basic problem, how to debug jQuery, how to test whether jQuery is getting called or not?
To answer such questions, you can write the below codes in layout where you are including jQuery.

    <script type="text/javascript">
   $(document).ready(function() {
      alert("test");
   })
    </script>

Following codes will give you alert "test" when application is loaded. This way you can be sure where your problem lies.

RAILS_ENV=production devise:setup giving error


RAILS_ENV=production devise:setup giving error  "Missing host to link to! Please provide :host parameter or set default_url_options[:host]" on Rails 3

We have created one application (rails_app3) on Rails 3 and used Devise gem.
When run rake devise:setup in development its working fine, but when we run the command “RAILS_ENV=production devise:setup” its giving following error:

Missing host to link to! Please provide :host parameter or set default_url_options[:host]
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:473:in `url_for'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/routing/url_for.rb:131:in `url_for'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/url_helper.rb:99:in `url_for'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:195:in `user_confirmation_url'
/usr/lib/ruby/gems/1.8/gems/devise-1.1.4/lib/devise/controllers/url_helpers.rb:32:in `send'
/usr/lib/ruby/gems/1.8/gems/devise-1.1.4/lib/devise/controllers/url_helpers.rb:32:in `confirmation_url'
/usr/lib/ruby/gems/1.8/gems/devise-1.1.4/app/views/devise/mailer/confirmation_instructions.html.erb:5:in `__usr_lib_ruby_gems_____gems_devise_______app_views_devise_mailer_confirmation_instructions_html_erb__607271297__615816948_0'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/template.rb:135:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/template.rb:135:in `render'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/notifications.rb:54:in `instrument'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/template.rb:127:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/render/rendering.rb:59:in `_render_template'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52:in `instrument'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/notifications.rb:52:in `instrument'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/render/rendering.rb:56:in `_render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/render/rendering.rb:26:in `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/abstract_controller/rendering.rb:114:in `_render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/abstract_controller/rendering.rb:108:in `render_to_body'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/abstract_controller/rendering.rb:101:in `render_to_string'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/abstract_controller/rendering.rb:92:in `render'
/usr/lib/ruby/gems/1.8/gems/actionmailer-3.0.3/lib/action_mailer/deprecated_api.rb:111:in `render'
/usr/lib/ruby/gems/1.8/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:710:in `collect_responses_and_parts_order'
/usr/lib/ruby/gems/1.8/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:725:in `each'
/usr/lib/ruby/gems/1.8/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:725:in `each_template'
/usr/lib/ruby/gems/1.8/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:720:in `each'
/usr/lib/ruby/gems/1.8/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:720:in `each_template'
/usr/lib/ruby/gems/1.8/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:706:in `collect_responses_and_parts_order'
/usr/lib/ruby/gems/1.8/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:648:in `mail'
/usr/lib/ruby/gems/1.8/gems/devise-1.1.4/app/mailers/devise/mailer.rb:33:in `setup_mail'
/usr/lib/ruby/gems/1.8/gems/devise-1.1.4/app/mailers/devise/mailer.rb:6:in `confirmation_instructions'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/abstract_controller/base.rb:151:in `send_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/abstract_controller/base.rb:151:in `process_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/abstract_controller/base.rb:120:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/abstract_controller/rendering.rb:40:in `process'
/usr/lib/ruby/gems/1.8/gems/actionmailer-3.0.3/lib/action_mailer/old_api.rb:75:in `process'
/usr/lib/ruby/gems/1.8/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:446:in `process'
/usr/lib/ruby/gems/1.8/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:441:in `initialize'
/usr/lib/ruby/gems/1.8/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:425:in `new'
/usr/lib/ruby/gems/1.8/gems/actionmailer-3.0.3/lib/action_mailer/base.rb:425:in `method_missing'
/usr/lib/ruby/gems/1.8/gems/devise-1.1.4/lib/devise/models/confirmable.rb:54:in `send_confirmation_instructions'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:422:in `_run_create_callbacks'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/callbacks.rb:281:in `create'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/persistence.rb:246:in `create_or_update'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/callbacks.rb:277:in `create_or_update'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:413:in `_run_save_callbacks'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/callbacks.rb:277:in `create_or_update'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/persistence.rb:39:in `save'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/validations.rb:43:in `save'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/attribute_methods/dirty.rb:21:in `save'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/transactions.rb:237:in `save'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/transactions.rb:289:in `with_transaction_returning_status'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/transactions.rb:204:in `transaction'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/transactions.rb:287:in `with_transaction_returning_status'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/transactions.rb:237:in `save'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/transactions.rb:248:in `rollback_active_record_state!'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/transactions.rb:236:in `save'
/usr/lib/ruby/gems/1.8/gems/devise-1.1.4/lib/devise/models/token_authenticatable.rb:29:in `reset_authentication_token!'
/usr/lib/ruby/gems/1.8/gems/devise-1.1.4/lib/devise/models/token_authenticatable.rb:39:in `ensure_authentication_token!'
/var/www/rails_applications/rails_app3/releases/20110120102714/lib/tasks/setup.rake:9
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/validations.rb:33:in `create!'
/var/www/rails_applications/rails_app3/releases/20110120102714/lib/tasks/setup.rake:5
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19



My database.yml production block is:

production:
  adapter: mysql
  database: rails_app3_production
  username: produser
  password: produserpwd
  host:
  encoding: utf8


Any ideas why I am getting this error?

Monday, January 10, 2011

Open a web page URL in popup

Just now spent a lot of time searching for one solution. My requirement was to open a web page say www.google.com in a popup. That popup can be either thickbox, facebox, redbox or other similar popup box.

After some time of struggle, came across one solution which will definitely help in saving lots of other people effort. I did it with facebox and must admit, I didn't found it anywhere as simple enough to be directly implemented. It requires iframe along with facebox.


  1. Download and install facebox from  http://chriswanstrath.com/facebox/.
  2. For installing the facebox, lot of articles can be found, if you come across any issue, let me know.
  3. Place the below code where you want to render the site:
<div>
  <div id="interactive_ad" style="display:none">
    <iframe height="500" width="800" src="www.google.com"></iframe>
  </div>
  <a href="#interactive_ad_1" rel="[facebox]">interactivea_ad</a>
</div>

And thats it. Now when you will click on "interactivea_ad" link, it will open a facebox popup and will display the site in popup.