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

Wednesday, May 25, 2011

Kaminari plugin with column_sorting and jquery_ajax

https://github.com/reddyonrails/Kaminari_column_sorting_jquery_ajax
The above example code for column sorting through ajax calls when doing pagination.

Better to use sorting image arrows for column heading for visual appealing
 
Please visit for original kaminari pagination plugin here.
https://github.com/amatsuda/kaminari