Friday 2 August 2013

Git Reset Head using Refflog

Refflog is used to reset your HEAD after you had HARD RESET HEAD.

$ install reflog
$ git reflog
$ git reset --hard 4993de0 #(give the HEAD number on which you want to go back)

Useful Links:

Setting up Git to use Diffmerge

Diffmerge is used to manage your merge conflicts cleanly. first you need to download and install Diffmerge. For further configuration
http://adventuresincoding.com/2010/04/how-to-setup-git-to-use-diffmerge/

Restore a postgres database dump

If you want to restore your postgres database from a dump. first cd into the directory where your dump file exist.
Then run the following command in your console.

$ psql -U mypostgresusername -d mydestinationdbname -f mydbdumpfilename.sql


Creating a Postgres admin user

First run this Query on Postgres:

WITH mx AS ( SELECT MAX(id) AS id FROM sch.mytable)
SELECT setval('sch.mytable_id_seq', mx.id) AS curseq
FROM mx; 

Then run this in your console:

$ rake spree_auth:admin:create ?

 

Omni Auth Managing Multiple Providers

Facebook API localhost redirect.

if you are using Omni Auth Facebook and want to redirect to your local host. and you are getting error code 191. It means that your provided redirect URI on facebooks Apps is not correct.
example: http://localhost:3000/   (OR) http://lvh.me:3000/

Authenticate User Using OmniAuth facebook

Here is a step by step Guide Using Omni Auth Facebook. you may encounter some bugs while following the tutorial. Therefore Do not miss to readout the comments of 'Vadym Tyemirov' at the end of the Article. 

Google Omni Auth with devise tutorial

Here is a step by step user guide for using Google Omni Auth with devise.

http://blogs.burnsidedigital.com/2013/03/rails-3-devise-omniauth-and-google/

But one thing I want to add is that, there in section 4, author says that "First, create a new controller called omniauth_callbacks_controller.rb and make it look something like this:" However the code is not given. For that I followed the following link.
https://github.com/plataformatec/devise/blob/master/app/controllers/devise/omniauth_callbacks_controller.rb

Google OmniAuth. Error: redirect_uri_mismatch

If you are using Google OmniAuth with devise and you get this error.

Error: redirect_uri_mismatch

The redirect URI in the request: http://localhost:3000/users/auth/google_oauth2/callback did not match a registered redirect URI.

Copy the highlighted text and Go into the Google developer API where you have registered your App edit sittings and paste it there in the Google redirect URI.