Tatva-Artha

meaning of "it"

Archive for the ‘Technology’ Category

Installing RMagick gem on mac osx (Mountain Lion)

without comments

Several things have changed since the last time I wrote about gotchas when installing rmagick on mac osx.

Now a days, you need Homebrew instead of Port.

Install ImageMagick using homebrew first

$ brew install imagemagick

Before, you install rmagick gem though, find out the homebrew folder where imagemagick libraries are installed.

$ Magick-config --prefix

Change directory into this directory.

$ cd `Magick-config --prefix`

Now, symlink the versioned library to what the gem is looking for.

$ ln -s libMagick++-6.Q16.dylib libMagick++.dylib
$ ln -s libMagickCore-6.Q16.dylib libMagickCore.dylib
$ ln -s libMagickWand-6.Q16.dylib libMagickWand.dylib

Your specific versioned library may differ a little bit.

Now, you should be able to infall gem just fine.

$ gem install rmagick

Written by Sharad

October 6th, 2013 at 11:53 pm

Posted in All,Technology

Tagged with , ,

Unix init script for searchd (sphinx server) and monit config

without comments

If you are using thinking_sphinx for your text search needs on a rails project, you will need to have searchd service monitored in production. Monit service allows us to monitor a unix service. However, there is no good/recommended init script that exists. Here’s one that could work for your rails3 project.

Read the rest of this entry »

Written by Sharad

September 20th, 2012 at 5:05 pm

Posted in All,Technology

Tagged with , , ,

How to ask for professional reference

without comments

It used to be that giving professional reference to your potential employer was just about sharing a few names along with their phone numbers. Not anymore. Winning the technical interview is just half the battle, and especially at senior level positions, the response from your professional reference(s) matter more than ever. Preparing and grooming your references before you actually need them and maintaining elevated communication with each referee can pay huge dividends.

Most potential employers require around 3 professional references. When you start your job search, you are better served getting initial permission from folks that you think could be your professional reference. This is a good time to inform them about why you are looking for new opportunity. Also, confirm phone number, email where they can be reached for reference. You should have about 5 people at various levels (boss, direct report, colleague) available before you actually need them.

While most of us do this right, we forget a few things.

It makes a huge difference if you could share important information about the job with your referee and the person checking reference just before the call happens. Here are some of things you should do before each of your potential employer decides to check on your reference.

Give following information to your referee (person giving professional reference):

  • Company detail: Share name of company, website and a brief description of what they do. This saves your referee time to research the company and prepare their answers. It also conveys that you value their time and remain ready to make it as easy as possible.
  • Position being interviewed for: Share the title of the position (Sr. Business Analyst, Architect) and job description. This helps them understand the nature of your work in that position so they can highlight the alignment with the job in an enhanced manner.
  • Name, phone number, email of person calling. This is important since most people don’t pickup phone if they don’t recognize the number. Also, sharing approximate time of expected call helps a great deal in making sure that they connect the first time!

The same goes for the other side of the equation:

Give the person performing reference check following information:

  • Referee’s contact information: Name, phone number, email, preferred time to contact. This is obvious. During initial cultivation of reference, check and confirm which phone, weekday/time works best for them.
  • Brief description of nature of professional relationship (boss, direct report, colleague): Thinks like “I worked closely on X project with Y colleague” or “He/she was the lead and I reported to him in Sr. developer capacity”.
  • What are some of the things that the person can provide information on: Things like “he can talk about my people skills more than my development ability” or “He can vouch about my progress since our time at X company”. No, this is not cheesy at all. It helps your potential employer understand what are some of the highlights of each reference. Sure, they will not follow the script exactly as you laid out but it will be pretty close.

All in all, your goal with reference should be to get truthful and consistent story (about you) to come out. Preparing your references takes a little effort/time but it is well worth the effort.

Finally, don’t forget to send thank you email to all referee that you’ve used in your search and inform them about your decision to choose a particular company.

Written by Sharad

April 30th, 2012 at 8:24 pm

Posted in Technology

Upgrading to ruby 1.9: rbx-require-relative requires Ruby version ~> 1.8.7

without comments

If you are upgrading from ruby 1.8 or Ruby Enterprise 1.8.7 to ruby 1.9.2, you may encounter this error.

Installing rbx-require-relative (0.0.5) Unfortunately, a fatal error has occurred.
Please report this error to the Bundler issue tracker at https://github.com/carlhuda/
bundler/issues so that we can fix it. Thanks!/Users/sjain/.rvm/rubies/ruby-1.9.2-p290/
lib/ruby/site_ruby/1.9.1/rubygems/ installer.rb:364:in `ensure_required_ruby_version_met':
rbx-require-relative requires Ruby version ~> 1.8.7. (Gem::InstallError)

This most likely happens because you are declaring a dependency on ruby-debug gem in your Gemfile.

group :development do
  gem 'ruby-debug'
end

With ruby 1.9, you need to update this with new gem name ruby-debug19.

group :development do
  gem 'ruby-debug19'
end

This will eliminate the dependency on rbx-require-relative and fix the issue.

Written by Sharad

August 21st, 2011 at 1:55 pm

Posted in All,Technology

Tagged with , , ,

Setting environment variables in Max OSX

without comments

Any a developer switching from linux to mac, the way to set environment variables is similar yet different enough that is annoying at times. I have so far failed to find a good documentation on where and how to set those in mac osx. Today I found one here.

My takeaway:

Mac OS X applies .bash_profile and .profile only for Terminal.app environment and Apple’s technical documentation suggests using ~/.MacOSX/environment.plist for other applications. So, by default PATH value will differ for RubyMine and the console.

For managing the global environments, it also recommends a system preference pane app. This worked for me.

Written by Sharad

May 16th, 2011 at 10:12 am

Posted in All,Technology

Tagged with , , ,

Javascript Garden

without comments

If you consider yourself a beginner or intermediate Javascript developer and feel the need to advance, here’s something that may be right up you ally: Javascript Garden.

Written by Sharad

March 19th, 2011 at 12:12 am

Posted in All,Technology

Tagged with ,

Mocha unexpected invocation errors

without comments

If you find that your tests pass when run alone but fail with “unexpected invocation” inside “rake test”, you are most likely seeing behavior that is caused by mocha load order.

This is a documented gotcha with mocha. And also discussed here.

It happens when mocha gem is listed as library dependency inside rails app. The library gets loaded too soon. The fix is to load mocha after rails has booted up.

For rails < 3.0.0, this means removing -- config.gem 'mocha' -- entry from config/environment.rb and adding -- require 'mocha' -- at the bottom of test/test_helper.rb.

For rails >= 3.0.0, this means adding — :require => false — inside Gemfile entry as follows.

# Gemfile
group :test do
  gem 'mocha', :require => false
end

And then adding following line at the bottom of test/test_helper.rb:

# test_helper.rb
require 'mocha'

Written by Sharad

March 11th, 2011 at 10:38 pm

Posted in All,Technology

Tagged with , ,

Installing RMagick gem on Mac OSX

without comments

Commands for installing image-magick package and rmagick gem on max osx:

sudo port install tiff -macosx imagemagick +q8 +gs +wmf
sudo gem install rmagick

Reference: http://rmagick.rubyforge.org/install-osx.html

Written by Sharad

March 8th, 2011 at 10:41 pm

Posted in All,Technology

Tagged with , ,

ActiveRecord::MissingAttributeError: missing attribute — a bug or a feature?

with 4 comments

Sooner or later, the need arises to assign default values to model attributes. In rails this is usually done in model’s after_initialize() with a new_record? guard.

Something like:

class User
  def after_initialize
    if new_record?
      self.country = "US"
    end
  end
end

This initializes the object with proper default so the UI form gets properly populated and the database gets proper default if user hasn’t overridden it.

Sometimes, you realize that you have (pre-existing?) objects in database that also need the same default if the current value is nil. In such case, you may modify your initializer like this:

class User
  def after_initialize
    self.country ||= "US"
  end
end

This works for both scenarios: User.new and User.find.

However, it introduces a behavior that may not be apparant immediately.

$ script/console
ree> User.find(u.id)
  User Load (0.9ms)   SELECT * FROM `users` WHERE (`users`.`id` = 1) 
ree> User.exists?(:id => u.id)
  RateSearch Load (0.6ms)   SELECT `users`.id FROM `users` WHERE (`users`.`id` = 1) LIMIT 1
ActiveRecord::MissingAttributeError: missing attribute: country
/[prj]/app/models/User.rb:3:in `after_initialize'

A closer look reveals that ActiveRecord tries to be smart and only fetch ‘id’ column when performing Model.exists? call.

Many people have tripped this and logged it as a bug. The report has been silently ignored, and I believe, for good/performance reasons.

So, what do we get around it? Here’s one way.

class User
  def after_initialize
    self.country ||= "US"
  rescue ActiveRecord::MissingAttributeError
    # this should only happen on Model.exists?() call. It can be safely ignored.
  end
end

As they say, it is not a bug, it is a feature.

Written by Sharad

March 3rd, 2011 at 8:07 pm

Posted in All,Technology

Tagged with , ,

Online Regular Expression Tool

without comments

Rubular, is a tool that you may find handy when developing ruby regular expression for scraping unstructured data needs.

http://rubular.com/

Good one!

Written by Sharad

March 2nd, 2011 at 6:14 pm