Monday, February 25, 2013

Accessing Git Repository on Github


Problem:
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Solution:

Password Caching (Explains how to use https to access repository and cache password so you don't get annoying password prompt whenever you have to access the github repo)

1. curl -s -O \
  http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain
chmod u+x git-credential-osxkeychainsudo mv git-credential-osxkeychain `dirname \`which git\``
git config --global credential.helper osxkeychain

Using Bundler Outside Rails

1. bundle init
2. Open Gemfile and add your gems : gem 'highline'
3. bundle

Bundler without Rails

Friday, February 22, 2013

Using Phusion Passenger as a Rails Server on Mac OS X 10.7.5

Software used : RVM Passenger 3.0 on Mac OS X 10.7.5

1. rvm use 1.9.3
2. gem install passenger
3. rvm get head
4. rvm reload
5. rvm repair all
6. passenger-install-apache2-module

Thursday, February 21, 2013

Could not find gem 'activerecord-sqlite3-adapter (>= 0) ruby' in the gems available on this machine.

Instead of
gem install activerecord-sqlite3-adapter
run
gem install sqlite3

Archimedes and the Internet

If Archimedes was born in this era, he would say:

Give me a single email account, and a website, and I will move the Internet.

Saturday, February 16, 2013

Playing with URL Helpers in Rails 3.2 Console


 :001 > Rails.application.routes
 => # 
 :002 > Rails.application.routes.url_helpers
 => # 
 :003 > Rails.application.routes.url_helpers.permissions_get_access_token_url
ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
 :004 > Rails.application.routes.url_helpers.permissions_get_access_token_path
 => "/permissions/get_access_token"
 :005 > Rails.application.routes.url_helpers.permissions_get_access_token_path(:host => 'http://localhost')
 => "/permissions/get_access_token"
 :006 > Rails.application.routes.url_helpers.permissions_get_access_token_url(:host => 'http://localhost')
 => "http://http://localhost/permissions/get_access_token"
 :007 > Rails.application.routes.url_helpers.permissions_get_access_token_url(:host => 'localhost')
 => "http://localhost/permissions/get_access_token"
 :008 > Rails.application.routes.url_helpers.permissions_get_access_token_url(:host => 'localhost:3000')
 => "http://localhost:3000/permissions/get_access_token"

 or

  :001 > include ActionDispatch::Routing
  => Object
  :002 > include Rails.application.routes.url_helpers
  => Object
  :003 > permissions_path
  => "/permissions"
  :004 > permissions_url
 ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
  from /Users/bparanj/.r

Reference:
Recognizing URL Helpers

Friday, February 15, 2013

protocol version mismatch (client 7, server 6) tmux

ps aux | grep tmux

Look at the second column for the process id. Then run : kill process-id-for-tmux

Sunday, February 10, 2013

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

1. Install GCC Installer https://github.com/kennethreitz/osx-gcc-installer
2.

rvm remove 1.9.3
brew install openssl
rvm install 1.9.3 --with-openssl-dir=`brew --prefix openssl`


# Install openssl
echo "Install openssl..."
brew install openssl
brew link openssl
# download cert.pem file for openssl
cd /usr/local/etc/openssl/certs/
sudo curl -O http://curl.haxx.se/ca/cacert.pem
sudo mv cacert.pem cert.pem
cd -
echo "
# cert.pem file for openssl 
export SSL_CERT_FILE=/usr/local/etc/openssl/certs/cert.pem" >> ~/.bash_profile
source ~/.bash_profile

Shell script to turn your laptop to a development machine.

Saturday, February 09, 2013

PayPal Application id for Sand Box

Use APP-80W284485P519543T as the app_id

This is the same for all sandbox users and any PayPal API (Adaptive Payments, Express Checkout etc).

Sunday, February 03, 2013

Convert HAML to ERB


1. rails g install haml2erb
2. Gemfile :
gem 'mixology'
3. bundle
4. Rails console : Haml2Erb.convert('.foo')

This plugin is not perfect. I had to refer HAML documentation to convert some of the lines.

no such file to load -- less Twitter Bootstrap, Rails 3.2.11

1. In Gemfile, for group :assets block, add:
        gem "less-rails"
2. Add to Gemfile (not in any block), add:
         gem 'therubyracer', :require => 'v8'
3. bundle

It will now work.