Tuesday, April 09, 2013

Error running 'requirements_brew_libs_install libksba' or libgpg-error Ruby 2.0.0 on MAC, brew and RVM


Problem: 
If you have problem installing ruby 2.0.0 on your mac using rvm and brew. And the problem could be timeout error .

rvm install ruby-2.0.0-p0

Installing requirements for osx, might require sudo password.
Already up-to-date.
Installing required packages: libksba....
^CError running 'requirements_brew_libs_install libksba',
please read /Users/XXX/.rvm/log/ruby-2.0.0-p0/package_install_libksba.log

log file :

(curl: (56) Recv failure: Operation timed out)


Solution: 

vi  /usr/local/Library/Formula/libgpg-error.rb
Replace: url 'ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.9.tar.gz'
with  url 'http://www.mirrorservice.org/sites/ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-1.11.tar.gz'

same case with libksba

This should works if it complain sha1 stuff replace expected one on ruby code.

Thursday, March 28, 2013

Brew Update issue

$ brew update
error: The following untracked working tree files would be overwritten by merge:
    Library/Formula/libmusicbrainz.rb
Please move or remove them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master
 
 
Solution: 

rm /usr/local/Library/Formula/libmusicbrainz.rb
brew update

Thursday, January 24, 2013

Rails pg gem '0.14.1' on Mac fails and solution

pg.c: In function ‘Init_pg_ext’:
pg.c:384: error: ‘PQPING_OK’ undeclared (first use in this function)
pg.c:384: error: (Each undeclared identifier is reported only once
pg.c:384: error: for each function it appears in.)
pg.c:386: error: ‘PQPING_REJECT’ undeclared (first use in this function)
pg.c:388: error: ‘PQPING_NO_RESPONSE’ undeclared (first use in this function)
pg.c:390: error: ‘PQPING_NO_ATTEMPT’ undeclared (first use in this function)
make: *** [pg.o] Error 1

Solution:
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Library/PostgreSQL/9.2/bin/pg_config

EDIT :
If you dont know where your pg_config is. Assume you are on Linux/Mac system, using the command 'find' should help

find / -name pg_config
 
 


How to copy postgresql data from heroku production

Steps to get the copy of heroku deployed application database to localhost .

1 step: Create a backup on heroku production
       
           heroku pgbackups:capture --expire

2 step:  Get the latest back up to local by curl method

           curl -o backup.dump `heroku pgbackups:url`
3 step: Restore to localhost database using the followng comand
  
   pg_restore --verbose --clean --no-acl --no-owner -h localhost -d your_database_name  backup.dump


Friday, November 16, 2012

In Ruby, private methods are visible in derived classes


    class Base
    private
      def hello
      end
    end
then methods in the derived class can call it:

    class Derived < Base
      def say
        hello # this is allowed in Ruby
      end
    end 
 
Simply to say this :
in C++ and OOP languages, “private” means “private to this class”, 
while in Ruby it means “private to that instance”. Again here class is itself an object :-)

Thats means private method will have only one receiver that is self.

Thursday, October 18, 2012

Features of Ruby on Rails 4.0

Features of Rails 4.0:
    •    strong_parameters
    •    Rails.queue
    •    Turbolinks
    •    Russian Doll Caching (cache_digests)
    •    ActionController::Live (streaming)
    •    PATCH verb
    •    Routing concerns
    •    Extraction of activeresource
    •    ActiveRecord::Relation changes and improvements
    •    Removal of plugin support (not gems; only those that are installed in vendor/plugins)
    •    Removal of Rails 2 finder syntax
    •    Deprecation of most dynamic finders
    •    Deprecation of eager-evaluated scopes

Slide deck: speakerdeck.com/u/alindeman/p/rails-4-dot-0-whirlwind-tour

Video:  http://vimeo.com/51181496

Sunday, July 15, 2012

tooltipclass.js for drop down options when mouse over

code : https://github.com/reddyonrails/tooltipclass.js 
 
Description:
 This code is to tooltip drop down option when mouse over. TooltipClass uses json data source .
If this datasource is empty will fetch from ajax url passed from source list url.

You can set a template for each tooltip for drop down box.

sample source params to select particular select box.

Usage:
var dataSourceList = {
    'portfolio': {
        'targetElement': '#analysisjob_portfolio_id',
        'url': '/portfolios',
        'sourceName': 'portfolio',
        'primaryKey': 'portfolio.PortfolioId',
        'jasonData': {},
        'template': "" +
            "<%= item.Name%>" + "
" +
            "<%= item.Description%>" + "
" +
            ""
     }
}
targetElement : select box id
url: ajax url to fetch data
sourceName: json root
primaryKey: key with which we search for json data for each option
template: you can define tooltip structure

loadSource and call tooltipify function like this :
       var source = dataSourceList.portfolio
       var test = TooltipClass.initialize(source);
        test.toolTipfy();

Requirements:
http://twitter.github.com/bootstrap/javascript.html (tooltip,popover)
jquery
underscore.js

Tested in firefox