Ruby Conf 2013 – Pune

I had been to the Ruby Conf 2013 in Pune on 22nd and 23rd of this month.
Was quite excited to meet the Ruby Gurus like Jim Weirich – the author of “Rake” which is a defacto build tool in the Ruby world.  However, I was kind of taken aback by the fact that he was explaining and demonstrating the fundamentals of TDD that too in a Keynote speech.
Aaron Patterson’s Keynote was very very interesting.   He had shown his new “gadget” called “Google Glass”.  If you want to have a quick look at it, check out here.
Nick Sutterer’s talk stressed upon “NOT to be afraid of creating more classes”.  How can you break up your Controller/Model/Views into smaller maintainable classes/views using gems like Cells, Roar, Objectify etc.
There was a lot of motivation from the speakers to the audience requesting to contribute to the Open Source world.  Richard Schneeman has developed a site called CodeTriage which allows us to signup for various open source softwares, following which you would be sent a bug/issue every day.  You can contribute by simply reproducing an issue, fix an issue and even provide pull request to the developers.  This can provide a good start for anyone who would like to get their hands on the Open Source.  I have immediately signed up with Code Triage and have already started working on my first Rails bug.

Lightning Talks
In this section, the participants were given an opportunity to volunteer themselves to present a talk for about 5 minutes on any subject.
Myself and my friend Venkat had an opportunity presented a talk on “Developing Rich Internet Applications with Netzke framework (ExtJS and Rails)”.
Generally, such conferences would cover some fundamental/basic topics and some advanced topics running in parallell in two tracks.  However, in this conference, the focus was more towards the crowd who have just started in Ruby and had very little as takeaway for people looking forward for advanced topics.

Ubuntu 10.10 Upgrade – Logs out instead of Shutdown

I am like most of the Ubuntu favorites…awaiting for half-yearly upgrades from Canonical and making sure all my systems are up-to-date.

However my happiness was short lived after upgrading to Maverick(Ubuntu 10.10). Whenever I tried to shutdown or restart using the button in the bottom right corner, all that happens is a log out and back to login screen!!! However, when I call shutdown from terminal or from login screen, it behaves as expected!

Tried all sorts of suggestions after googling for over 3 months now…and YES! I managed to find a solution for my problem TODAY…feeling so relieved… When I executed “ck-list-sessions” in terminal, it showed 2 active sessions, one is mine and the other one is “hsqldb-server”.

I wondered why is HQLDB Server creating a session??? And even if so, why should that prevent the shutdown from happening…that too only when I click the shutdown button.

No idea. So what did I do….obviously, in my case, I did not require “hsqldb server”, so I simply uninstalled the same…and viola! my problem vanished! Hope this will help someone who also is going thru what I did in the last 3 months or so 🙂

Ruby Regexp Unescape

May not be a big deal to write it yourself…but I wrote this and was quite useful, where I had to do un-escaping of a Regex Pattern for some reasons…

class Regexp
def unescape
source = self.source.split('')
escape_on = false
unescaped_string = source.inject([]) {|r, char|
if char == "\\" and escape_on == false
escape_on = !escape_on
r << char
escape_on = false

Enable Disable Touchpad in Ubuntu with a Hot key

I have got this new Dell Vostro n3500 Laptop, which is really a solid machine. I am very happy to have made this choice.

As a hardcore UBUNTU User, I always liked to have any feature available in Windows to be made available in Ubuntu as well :)…

Recently, I realized that the “Fn+F6” shortcut to disable the Touchpad does not work… I am sure many of you would have encountered the annoying behavior of touchpad moving your cursor to some place while you are typing something…

The most ideal solution I would have liked is that, when I connect an external mouse, the touchpad should automatically be disabled. Apparently, I did not find any solution for this in the current version of Ubuntu 10.04(Lucid Lynx). Google did not help me either.

So, the next thing is, is there any way I can tell Ubuntu to disable touchpad when I start typing. Yes, there is such an option in the “Mouse Preferences”. But that is not working consistently atleast for me.

So, now this is what I did. I wrote a small Ruby script(I am a big big fan of Ruby) that can toggle the Touchpad ON and OFF.

Now, the next thing is to make it hooked to a keyboard shortcut like the one in Windows…Fn+F6. Apparently, I also found that I cannot assign the combination of “Fn” Key and “F6” to the Keyboard shortcut in Ubuntu. So for now, I have simply assigned “F6” key for this toggle switch tool.

The script is not a big deal, but in any case, its here…

touch_pad_setting = `synclient -l | grep TouchpadOff`
new_touch_pad_setting = touch_pad_setting =~ /1/ ? "0" : "1"
`synclient TouchpadOff=#{new_touch_pad_setting}`

Enforce JRuby to use gems inside the JRuby complete and ignore the local gem repository

Most of us are aware that Gems can be bundled as part of JRuby Complete, and Jruby will automatically load these gems from the jruby-complete.jar happily.

But do you know that, if you had a local gem repository set, jruby will ALWAYS attempt load the gems ONLY from your local gem repository? And ignore the gems bundled inside the jruby-complete.jar?

Well, we are aware of that, but it was quite annoying when we find that some code that worked happily in our development environment does not work in production, bcos the codes were referring to some gems that were available only in our development environment.

To ensure JRuby completes ignores our local gem repository, we used to add the following line in our deployment scripts before launching JRuby.

unset GEM_HOME

We are trying to understand the principle behind using the local gem repository even though certain gems are bundled inside the Jruby Complete.

Some thoughts on how Jruby should choose the gem repository
1. Whenever jruby is launched from the jar file with embedded ruby home, then always assume to use the embedded gem home and ignore the local gem repository?


2. If atleast one gem is bundled in jruby-complete, then can jruby assume the developer wants to use the particular gem in his application and hence ignore the local gem repo and set the gem repo as the embedded gems location inside jar?

We are unable to come to a conclusion on what is the sane approach to handle the situation.

For now, we have patched jruby to go thru first approach. This way, I am completely sure that when jruby is launched from jar, my local gem repository is not coming in the way. And I dont have to remember to “unset GEM_HOME” in all my deployment scripts to tell Jruby to look for gems embedded in the jar file.

Hope this may be of some help for people who have had faced this issue.

JOpenSSL gem inside JRuby Complete

We had faced quite a lot of issues trying to embed JOpenSSL inside jruby-complete.jar.

We used to get an error “Uninitialized constant OpenSSL::Digest::OPENSSL_VERSION_NUMBER” with the following stack trace :

NameError: uninitialized constant OpenSSL::Digest::OPENSSL_VERSION_NUMBER
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/gems/1.8/gems/jruby-openssl-0.6/lib/openssl/cipher.rb:28:in `const_missing’
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/gems/1.8/gems/jruby-openssl-0.6/lib/openssl/digest.rb:23
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/gems/1.8/gems/jruby-openssl-0.6/lib/openssl/digest.rb:31:in `require’
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/gems/1.8/gems/jruby-openssl-0.6/lib/openssl.rb:24
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/gems/1.8/gems/jruby-openssl-0.6/lib/openssl.rb:31:in `require’
from file:/home/msuser1/jruby-complete-1.3.1.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’

You can find Charles’ explanation here

What we did is the following :

1. Add the Jruby-openssl gem inside the jruby-complete.jar bundle like adding any other gems(rspec, rake etc.)
2. Extract the JRuby Complete Jar in a fresh folder
3. In addition to this, extract the contents of jopenssl.jar directly under the root folder. (jopenssl.jar is located inside the lib folder of the jruby-openssl gem).
4. Re-create the jruby-complete.jar from this exploded folder.

Thats about it, you are all set to use openssl inside jruby without any issue.

Please note, at the time of writing this post, I was using JRuby 1.3.1 and Jopenssl 0.6.

Another iPhone App on the pipeline – Tarabalam

After developing an iPhone app called Panchangam Lite and seeing its success rate in terms of increasing number of downloads day after day and receiving positive feedback for the app, we were motivated quite a lot and it made us realize that there are lots of people around the world looking for such cool and useful tools in their iPhone…And we thought lets develop another app for such people in the similar lines…hence an app named “Perfect Day (Tarabalam)” is born.  The app should be available in AppStore very soon 🙂

Ok, then here goes some notes about “What is Tarabalam ?” and why and how should it be used?

Importance of Muhurtha (Quoted from the well known astrologer BV Raman)

The value of Time is inestimable. All objects in nature are produced in Time, developed in Time and destroyed in Time. The truth of these statements requires no further proof. It stands unchallenged.

Each moment has got its own potency and as Carl Jung says “whatever is born or done this moment of time has the qualities of this moment of time”. Hence the moment of birth or the moment at which we elect to do an important act is not certainly an insignificant epoch. Cosmic radiations pouring at the moment on the earth from outer space and coming from various stars and planets act on our brain cells which take up these cosmic radiations which are transformed into vital electricity. It must be noted that in all undertakings invisible energies are set in motion by our words, deeds, thoughts and of course by our actions. You may call these invisible forces as electric, ethereal or electro-magnetic or cosmic radiations. As man himself is an electrical body discharging different kinds of electrical energies, his success and failure are simply matters of attraction and repulsion between himself and the objects with which he has to deal in his day-to-day activities.

Muhurtha could therefore be defined as that precious moment when the vibrations radiated by man are altered to a specific wavelength capable of entering resonance with the radiations of the same vibratory rate coming from other planets and stars.

What is Tarabalam?

Various strengths are checked for muhurtham. Tarabalam, Chandrabalam, Gurubalam, Suryabalam, Lagnam shuddhi, etc… As outlined in following mantra. When we worship lakshmipati sri narayana, he will make everything right. He is tithi, vaara, nakshatra, yoga, karana. Hence, worshipping him will make everything right, remove all dosha.

तदेव लग्नं सुदिनं तदेव ताराबलं चंद्रबलं तदेव। विद्या बलं दैवबलं तदेव लक्ष्मीपतेः तेंघ्रिऽयुगं स्मरामि॥

tadeva lagnaṁ sudinaṁ tadeva tārābalaṁ caṁdrabalaṁ tadeva | vidyā balaṁ daivabalaṁ tadeva lakṣmīpateḥ teṁghri’yugaṁ smarāmi

Tarabalam is a strength provided by stars to your Janma / Birth star. Nakshatra/Star of moon at the time of your birth is known as Birth star. Moon’s daily star / Nakshatra position needs to be favourable for casting any muhurtha. Moon takes roughly 27 days to circle around earth and passes through 27 nakshatras. Daily motion of moon from your janma nakshatra decides this strength.

What does this mobile app do?

In order to increase the chances of success in any endeavor, this mobile app helps the user to pick days / times to perform the endeavor when Tarabalam is very strong. It calculates Tarabalam for 400 cities around the world for the year 2010. The timings are daylight adjusted where-ever applicable. You can also keep a list of your family / friends with their birth star and easily select Tarabalam for the person with just a click of the button.

Tarabalam is available for year 2010.