Tatva-Artha

meaning of "it"

Archive for October, 2009

Ruby Interview Questions

without comments

I’ve been attending a few Ruby interviews recently. Here are a few questions that I liked being asked. The answers are all mine and may not be all correct.

# Question: Invert the following array
{:a => 1, :b => 2}
# Expected Result: 
{1=>:a, 2=>:b}
 
# Answer:
Hash[{:a => 1, :b => 2}.collect {|k,v| [v,k] }]
# OR
{:a => 1, :b => 2}.inject({}) { |r,e| r.merge({e[1] => e[0]}) }
# Question: What will following code return
{:a => 1, :b => 2}.to_a
# Answer:
[[:a, 1], [:b, 2]]
# Question: How to you quickly determine if a given hash is identity hash or not?
# (Identity Hash is where key == value. For example, {:a => :a, :b => :b})
hash.keys == hash.values
# (Note: hash.keys and hash.values will return the elements in matching order as long as hash is not modified between those 2 calls)
# Question: What is the difference between following to codes?
x = 'a'
x += 'b'
# and
x = 'a'
x << 'b'
# Answer: Nothing. They both return the same result
x = 'ab'
# Question: What will following code return
''.to_sym
# Answer: ArgumentError: interning empty string
# (in other words, an empty string cannot be symbolized/internalized)
# Question: What will the following code return
begin
  ''.to_sym
rescue => e
  5
ensure
  6
end
# Answer:
5
# Note: logic inside ensure does get executed but it still returns the final output of rescue block! This is different from Java, where anything returned from inside finally will override the original return value.
# Question: Given following classes, specify the parent-child inheritance relationship
Class
Object
Module
String
# Answer:

# Question: What will following code return?
x = 1
Array === x
# Answer:
false
# === is a equality operator used for case/when statement.
# Question: What will following code return?
x = []
Array === x
# Answer:
true

Written by Sharad

October 24th, 2009 at 5:18 am

Posted in All

COBRA and Insurance Shopping Tips

without comments

I blogged about some basic information when shopping of individual insurance and recently there was an article in Business Week about COBRA. I found a few more information that are worth keeping in mind when shopping for insurance.

Facts about COBRA:

  • Decide within 60 days of qualifying event whether to take cobra or not. Qualifying event is changing job (voluntary or involuntary).
  • More info about Cobra: dol.gov/ebsa/cobra.html
  • cobra is valid for 18 month. Obama govt. is subsidizing premium by paying 65% of the premium (for the first 9 months of the full 18month coverage)
  • This 65% subsidy is not available for somebody who has another group plan option available (like spouse’s employer insurance plan)
  • COBRA coverage is usually the same coverage that the employee had when on job. It has the same premium + 2% administrative fee. However, employee becomes responsible for full premium (unlike employer paying 2/3rd premium when employed).

When shopping for health insurance, look out for following things:

  • StateHealthFacts.org: information about consumer protection, plan features required by each state
  • Ask insurers for “Explanation of Benefits (EOBs), which are more detailed than summary. Insurers hesitate and sometimes provide EOBs only after you are signed up. Ask to see EOBs before signing up.
  • Avoid plans with annual benefit caps. Lifetime benefit maximum of 1.5 to 2 million are more common now.
  • If employer based group plans are not available, look for association based group plans. e.g. New York Freelancers Union. Each have qualifying rules.
  • There is a difference between insurance plans and “limited-benefit” plans. LB plans (usually touted on TV and offer doctor visit, prescription discounts) don’t cover surgery and hospital stays.

Written by Sharad

October 19th, 2009 at 12:13 am

Posted in All

Looking for Ruby/Rails Work

without comments

Job losses accelerate to 263,000 in September and yes, that number includes me.

After exciting, hard working, fun filled 2 and 1/2 years at Pathfinder Associates, we had to part ways. On the bright side, I worked with some of the finest programmers, agile practitioners and visionaries in Chicagoland area. I got to practice the goodness of agile, pair-programming, scrum, Test Driven Development, became a fan and devotee of Ruby/Rails. I got into serious habit of blogging. Thanks pathfinder!

Yes and it is time to move on. And I am actively looking for Ruby/Rails opportunities. If you are looking for senior level ruby developer or Java architects, please do not hesitate to contact me.

Wish you all a Happy Gandhi Anniversary.

Written by Sharad

October 2nd, 2009 at 4:37 pm

Posted in All