Monday 30 December 2013

Tech Talk...JavaScript execution from within JVM

This tutorial describes how to execute JavaScript from within java using the Rhino provided JavaScript execution Engine.

About Rhino:

What is Rhino JavaScript Engine
Maven Repository for Rhino Jar

How to invoke a JavaScript from within java using Rhino:


public class JavaScriptInvoker {
    String myfn = ""
            + "function sayHello(inputStr, outputStr){"
            + " outputStr =  \"Hello\"+inputStr;"
            + "}";
    Function function;
    Context ctx;
    ScriptableObject scriptable;

   public void initJs(){
        ctx = Context.enter();
        ctx.setOptimizationLevel(9);
        scriptable = ctx.initStandardObjects();
        function = ctx.compileFunction(scriptable, myfn, "sayHello", 0, null);
   }

   public void invokeJs(){
      String outputStr;
      Object[] args = {"Neha", outputStr};
      function.call(ctx, scriptable, function, args);
      System.out.println(outputStr);
   }

    public static void main(String[] args) throws Exception{
       JavaScriptInvoker jsInvoker = new JavaScriptInvoker();
       jsInvoker.initJs();
       jsInvoker.invokeJs();
    }
}


Understanding different parts of the program:

1. Initializing the JavaScript engine.
The Rhino JavaScript engine needs to be initialized before it can be used to invoke a java script. This initialization involves initializing the internal objects used by the JavaScript Engine (being done using the line  scriptable = ctx.initStandardObjects(); ) .This single line would be sufficient for you in most of the cases( unless you need to do some sophisticated initializations on your own.).
Also, an optimization level can be set on the context of the engine, which ensures how performant the invocation of JavaScript from within java will be (see the line:ctx.setOptimizationLevel(9);) Optimization levels are integers, 9 being the highest.
Finally, the javascript which has to be invoked, needs to be initialized. This is being done in the line:
 function = ctx.compileFunction(_scriptable, myfn, "sayHello", 0, null);

2. Invoking the JavaScript from within java at runtime.
Once the javascript engine is initialized, it can be invoked at runtime multiple times to invoke the function compiled above, that is happening in the code :
 function.call(ctx, scriptable, function, args);
The first two arguments to the call method are context object and scriptable object of the JavaScriptEngine to let it know of the initialization parameters.
The next parameter is the compiled function that needs to be called.
The final parameter is an Object array consisting of parameters being passed to the function being invoked.

3. Parameter passing / Object sharing between JavaScript and Java.
As seen in the code above, I am passing two parameters to the method sayHello : one input string and one output string. Both these are Java String Object types. They are successfully binded and passed to the function sayHello, which appends "Hello" to the input string and then assigns the result to output string and returns the output string back. On obtaining the output string, the java runtime can successfully use it for further operation.

4. Java method invocation from within javascript engine
From within the javascript function, any of the Java methods can be invoked, even objects can be passed from the java code to the javascript as initialization parameters or arguments and then they can be used by the javascript in any way possible.

Thursday 5 December 2013

What am I writing after all


So, What am I writing after all....

So...many of the readers might be wondering what am I writing here...some technical topics, some management stuff, some general stuff - difficult to categorize. Well, most might as well be wondering, am I really writing because it has been a really long gap after which this post is coming up. Well, there have been things that I was held back with and even now there are things, but it gives me pleasure to see that I am still writing..or rather blurting whatever is coming to my mind. And that is what I do with every post. That is why there is a mix of stuff out there.

 To be honest, when I started blogging, I had no definite plans as to what I would write on. So, as and when things have been popping up, I have been jolting them down (That sounds nice..isn't it ? :) , of-course there is one more underlying 'strong' reason for the mix of topics you see here, that being, I am more of a jack of all trades...and of-course master of none :D ) So, I am assembling here different kind of posts with the hope that everyone finds something here that interests them (I know not every topic will be of interest to everyone ) and I know that the readers are intelligent enough to dig down and get what interests them :) . Thus, i can go for stunt of writing diverse things under the roof of a single blog when i am blessed with such an intelligent set of readers. So, I am listening to the instincts for now that says - just go for it :)

Jokes apart, now a few posts down the line I have started reflecting on the aspects of blogging which I had not even thought of initially when I started on. For instance, it would be a pleasure to look back and see what all I had got to share, as the posts grow old (and you and me too :) ). Also, it gives such a nice space to not only share your thoughts, little observations from life (like hope), but to vent out your feelings wrapped in a nice coat of sugary words (like the post Who is a development manager ). You get to connect with like minded people and when the topics are diverse, then you get to connect to many like minded people who share your thoughts on the different topics...
So, thanks for bearing with the different posts so far,and do hang on, i will be writing soon again :) . Lots of stuff is piling up, need to slowly jolt them down and present forth, which I would do soon.
If you like my writing, you can award me an excellence medal :P i really like the one below :) :)

Sunday 8 September 2013

Best of Ayn Rand quotes

"The question isn't who is going to let me; it's who is going to stop me."
“Learn to value yourself, which means: fight for your happiness.”

“A creative man is motivated by the desire to achieve, not by the desire to beat others.”

 “If you don't know, the thing to do is not to get scared, but to learn.”  
  - Atlas Shrugged

 “I started my life with a single absolute: that the world was mine to shape in the image of my highest values and never to be given up to a lesser standard, no matter how long or hard the struggle.”

“You can avoid reality, but you cannot avoid the consequences of avoiding reality.”

“Never think of pain or danger or enemies a moment longer than is necessary to fight them.” 

- Atlas Shrugged

“A government is the most dangerous threat to man's rights: it holds a legal monopoly on the use of physical force against legally disarmed victims.” 

“I worship individuals for their highest possibilities as individuals and I loathe humanity for its failure to live up to these possibilities.”

“She did not know the nature of her loneliness. The only words that named it were: This is not the world I expected.”

“What greater wealth is there than to own your life and to spend it on growing? Every living thing must grow. It can't stand still. It must grow or perish.”

-  Atlas Shrugged

“Live and act within the limit of your knowledge and keep expanding it to the limit of your life.” 
-  Atlas Shrugged

“There's no way to rule innocent men. The only power any government has is the power to crack down on criminals. Well, when there aren't enough criminals, one makes them. One declares so many things to be a crime that it becomes impossible for men to live without breaking laws.” 
-  Atlas Shrugged

“Men who reject the responsibility of thought and reason can only exist as parasites on the thinking of others.” 
- The Virtue of selfishness

“Self-sacrifice? But it is precisely the self that cannot and must not be sacrificed.”
- The Fountainhead

“Ask yourself whether the dream of heaven and greatness should be left waiting for us in our graves-or whether it should be ours here and now and on this earth.”
-  Atlas Shrugged

“It is not advisable to venture unsolicited opinions. You should spare yourself the embarrassing discovery of their exact value to your listener.” 
-  Atlas Shrugged

“Power-lust is a weed that grows only in the vacant lots of an abandoned mind. ”
-  Atlas Shrugged

“A rational man never distorts or corrupts his own standards and judgment in order to appeal to the irrationality, stupidity, or dishonesty of others.”  
- Atlas Shrugged

“In a free society, one does not have to deal with those who are irrational. One is free to avoid them.”  
- The Virtue of selfishness

“But there are people who'll try to hurt you through the good they see in you--knowing that it's the good, needing it and punishing you for it. Don't let it break you when you discover that.” 
-  Atlas Shrugged









 

Monday 2 September 2013

hope..

The other day when I was taking my mom from hospital back to home, in this auto-rickshaw, mid noon, I had a really rough time with the auto driver. I had been already going though a rough patch in life - having been recently met with an accident and most of the family members ailing.I was dealing with the downs of life, waiting patiently for the bad time to pass on, but, when the auto rickshaw driver started blabbing complaints and demanding more money because we were living in a street and not on the main road, the limits to my patience burst and I ended up in this heated argument with him which left me feeling bitter about the infrastructure around us, the law-and-order and the kind of people that we have to deal with.
Days later, when me and hubby were headed for a place somewhere in Vijayanagar, Bangalore for
image source : LINK
some work, we ended up in this small street that was heading straight to the cattle barn, with no side streets and reversing the car looked like a nightmare because half of the population from the houses - children and old alike - was on the street itself (thanks to the Google map and some people who would confidently guide you even if they themselves have no idea what you are looking for). We were not sure what to do next. Gathering courage, we started reversing the vehicle at a very very small pace, doing our best not to hurt anyone in the process. Slowly, the residents started helping us out, they started managing their children and gathering other stuffs like the drying spices and water buckets that they had laid out on the road while going through their daily chore. They also started guiding us to help make the reversing process smoother. There was this one really great guy who looked like a cab driver residing there, who took extra efforts to help us out of the nightmarish ordeal in that street. The incidence, although draining and tiring, filled my heart with hope and happiness - on finding so much friendliness and supportive attitude in the people out there. So, the good things do still exist :)
When I started writing this post, I just felt like putting the two incidences together, maybe to remind myself that there are both sides to life, that there are things that are good here and there are things that are bad. I hope we slowly improve upon things that are bad, and the experience of our next generation would be better than what it has been so far for us...


Image source : LINK


Wednesday 28 August 2013

Biscuit Corn Sev Poori

We had this quick and super easy biscuit corn sev poori recipe made this weekend for snacks when we were super hungry :). Just some ready-made and some already available ingredients made to work together , giving a sweet-sour-tangy taste to satisfy the taste buds :)

Ingredients:

  1. 10 salty biscuit - I used the parley monaco biscuits, you can use any you like, even the regular cream crackers
  2. fine sev or any potato mixture  like the haldiram aaloo bhujiya or the lahar aloo bhujiya - 1/2 cup
  3. finely chopped corianders - 1/4 cup
  4. finely chopped onion - 1/2 cup
  5. finely chopped tomato - 1/2 cup
  6. one large potato - boiled and finely mashed
  7. one cup boiled corn or sweet corn kennels
  8. 1 tsp roasted cumin powder
  9. 1 tsp roasted coriander powder
  10. 1 tsp black salt powder
  11. 2-3 tsp green chutney
  12. 2-3 tsp sweet chutney - can be tamarind or tomato or mango - whatever you prefer
  13. 2-3 tsp diluted tamarind paste
  14. salt to taste
  15. green chilli -1 - finely chopped

Method:

Spread the biscuits on a plate. Mix the mashed potatoes, corn, coriander leaves, coriander powder,  cumin powder, onion, tomato, black salt, salt and green chilli together and add equal portions of this mixture on top of each biscuit. Top each one of these with equal portions of green chutney, sweet chutney and diluted tamarind paste. Spread sev equally over each one of these and serve immediately.
Below is a snap of how mine looked after preparing, could have been a better snap. I will post more when again make this dish a second time. But believe me, it turned out to be so mouth watering tasty, I am sure I will make another one soon.

 Diluted tamarind paste:You can make it by mixing 1/4 tsp readymade tamarind paste with 2-3 tbsp water and properly dissolve the tamarind paste in water, or you can also make it by dissolving one ripe tamarind ball in 2-3 tbsp water, ofcourse after de-seeding it.
Green chutney: You can use a standard green coriander chutney, or a coriander+garlic chutney or a mint coriander chutney for the same. Here are some great links on how you can make it:
(I will post my own blog on how to prepare each one of these, as soon as possible, please bear with me till then)
Sweet chutney: You can use a sweet tamarind chutney or a sweet mango chutney. I will soon write to you how I prepare them, till then, you can use these links for reference :

Thursday 22 August 2013

This is going to hurt just a little bit...

My mom got a bad tooth ache last night and once again it reminded me the infamous lines from Odgen Nash "Because some tortures are physical and some are mental, But the one that is both is dental", true to the core. All those who have had to go through either this dental torture at some point of time in their life, or those who didn't have to because they pay regular visit to their dentists and willingly take-up the pain in small installments to avoid the big hit, would nevertheless agree with me, Odgen Nash so very well summarizes all their feelings into his amazing words in this poem - dedicating this post to his poem "This is going to hurt just a little bit...." and to all the victims of dental torture.

"One thing I like less than most things is
sitting in a dentist chair with my mouth wide open.
And that I will never have to do it again
is a hope that I am against hope hopen.

Because some tortures are physical and some are mental,
But the one that is both is dental.

It is hard to be self-possessed
With your jaw digging into your chest.
So hard to retain your calm
When your fingernails are making serious alterations in your life line
or love line or some other important line in your palm;

So hard to give your usual effect of cheery benignity
When you know your position is one of the two or three in life most lacking in dignity.

And your mouth is like a section of road that is being worked on.
And it is all cluttered up with stone crushers and concrete mixers
and drills and steam rollers
and there isn’t a nerve in your head that you aren’t being irked on.

Oh, some people are unfortunate enough to be strung up by thumbs.
And others have things done to their gums,
And your teeth are supposed to be being polished,
But you have reason to believe they are being demolished.

And the circumstance that adds most to your terror
Is that it’s all done with a mirror,
Because the dentist may be a bear, or as the Romans used to say,
only they were referring to a feminine bear when they said it, an ursa,

But all the same how can you be sure when he takes his crowbar in one hand and mirror in the other
he won’t get mixed up, the way you do when you try to tie a bow tie with the aid of a mirror,
and forget that left is right and vice versa?

And then at last he says That will be all;
but it isn’t because he then coats your mouth from cellar to roof
With something that I suspect is generally used to put a shine on a horse’s hoof.

And you totter to your feet and think.
Well it’s all over now and afterall it was only this once.
And he says come back in three monce.

And this, O Fate, is I think the most vicious circle that thou ever sentest,
That Man has to go continually to the dentist to keep his teeth in good condition
when the chief reason he wants his teeth in good condition
is so that he won’t have to go to the dentist."
 
 

Monday 19 August 2013

Ma's Aaloo Parathas

Difficulty Level : Medium

Time Required : 1 Hour +


Well, I need not stretch on the authenticity and the taste of this delicacy. It's directly from Mom, she made it yesterday morning for breakfast. It was one of those rare occasions when she kept taking out the hot parathas right from the pan and we ate, without keeping a track, could eat no more. So, here goes the recipe for mom's aaloo paratha (The recipe below would serve 4) :

Ingredients:

For the filling:

  • Potatoes , medium - 4  , boiled and peeled
  • Onion - 1 medium
  • Garlic - 6-7 cloves
  • Ginger - 1" piece
  • Salt to taste
  • Turmeric powder - 1/2 tsp
  • Coriander powder - 1/2 tsp
  • Cumin powder - 1/2 tsp
  • Garam masala powder - 1/4 tsp
  • Green chillis - 2 to 3
  • Red chilli powder - 1/8 tsp (almost 2 pinches)
  • 1 tbsp vegetable oil for frying the filling material.
  • 1 tsp ghee or refine oil or butter for each of the parathas.
  • 1 tbsp finely chopped coriander leaves

For the Dough: 

  • 2 cups whole wheat flour  
  • Enough water to kneed a soft dough

Method:

For preparing the filling, cut onion into small pieces. Mince the ginger and garlic . In a heavy bottom frying pan or wok, heat 1 tbsp vegetable oil. When hot, add the onion, ginger and garlic to it. Saute till the onion turns translucent. Then add the spices and green chilli (cut into fine pieces) to it. Cook for another 2-3 minutes, or, until the spices give a cooked aroma. Mash the boiled and peeled potatoes and add to the pan. Mix well with rest of the spices etc. Sprinkle salt as per taste and then mix everything well. Smooth out the filling mixture so that there are no lumps left into it. (If there are lumps left, when you will fill it in your parathas, they may split while rolling). Now, add the finely chopped coriander leaves to the filling mixture and mix well. Set it aside to cool while you work on the dough. For the dough, take the wheat flour and gradually add water to it, making a soft dough. Divide this dough into 12 equal portions. Take each portion between your palms and then roll it into a smooth ball (like you do to make any other chapati or flat Indian bread). Now, make a dip inside one  ball with your finger, add a teaspoon of the filling mixture inside it and then seal its mouth (like you do for any stuffed paratha). Dust with dry flour and roll out paratha using an Indian rolling pin. Now , heat a pan and put the paratha into it. Apply 1/2 tsp oil/ghee to both sides of the paratha and let it cook on the pan till its cooked (it would turn dusky in color with golden brown patches on it :) )
Make the rest of the parathas the same way. Serve them hot. 

Serving the potato stuffed parathas:

Potato stuffed parathas can be served with a verity of side dishes like curd, raita, kheer (rice pudding), sewai (vermicelli pudding), or chutneys like tomato chutney, green chutney, coriander chutney, pudina chutney,sweet mango or tamarind chutney, anchar (pickles), or any gravy reach vegetables like masala gobhi (cauliflower curry) or chole (chikpeas curry). Slowly I will add the recipes for these as well ,to the blog :)

Invariantions while roasting the parathas:

You can roast the potato stuffed parathas in more than one ways. You can either choose the way I described above, or, you can roast it dry , take it out of tawa/pan and then apply butter or ghee on top of it. Its a delight to see the butter melting on your hot paratha. This option of applying the ghee or butter on the parathas post preparing them makes them softer while with the previous procedure of applying oil to them while they are on the pan, you can make them crunchier if you want.

Finally, a snap of my mother's yummy aaloo parathas:

Friday 16 August 2013

Oh!! These Dreams....

Do you remember that dream sequence from "Kung fu Panda 2" where the Panda dreams of his parents deserting him? He runs after them and they say something like 'we have replaced you with this radish which is better than you and does a better kung fu' and post that the radish actually starts doing the kung fu and takes the panda completely off - guard. And finally, it wins over and then gets transformed into a symbol that is haunting the panda. Parent replacing their child with a radish and then the radish performing kung fu and then suddenly converting into a symbol. Sounds bizarre!! Right?

Do you as well remember Inception - levels of dreams and so much technicalities involved!!Where , it rains in one level of dream and it floods in the other. Able to correlate to these? I am, absolutely. As, I am one of those individuals that get lots of dreams - all kinds of dreams - and even dreams within dreams. I don't remember a night when I had such a sound sleep that I didn't get a single dream. Well, they don't let me have a sound sleep, but I still love them. They are bizarre, sometimes sweet, sometimes scary, sometimes adventurous and sometimes very depressing - but one thing is sure, they bring me nearer to my subconscious self , which is overpowered by my conscious mind all through the day, involved into the day to day activities of mere or no significance.And, they provide me these boundless and countless opportunities of achieving the impossibles.
Some interesting factors that I have observed about my dreams:
Achieve the impossible : I dream of friends and relatives whom I desire to meet but haven't been able to, since long, and they stop after I get to meet them. I have para glided, conquered mountains and sailed through the 7 seas in my dreams. And I have died a thousand deaths - falling from the mountain peaks and being chased by enemies, fighting all kind of odds and what not. The most wonderful thing is how some dreams span across days in episodes , and how at times they are so symbolic and rhythmic. Sometimes they even helped me make a decision, which I possibly couldn't have with my conscious mind which keeps pondering over all the aspects of the situation.
Stitch - in the outside environment: Once I was having this dream and in the dream it started raining, I tried to escape the rain, but didn't help, I took a shelter, still no protection from the rain. Then finally I woke up, and then I saw it was actually raining outside and the rain water was coming inside from the open window - the reason I couldn't escape the rain in my dream :)
All emotions, including sarcasm: You won't really believe how once my mind could spin a dream which was so sarcastic. I had this manager who was so used to "explaining" and "expanding" every talk. You reach out to him with one simple question that could have been answered in 1 sentence and yet he would weave a whole big one-hour lecture on the subject, there won't be any escape.Sometimes, he would even lecture just like that. So, one fine day, I dream of him, at my native place. He was giving bath to my late doggie and at the same time lecturing about how to give bath to a dog in the best possible way!!!! I was amazed by the sarcasm of my own subconscious, having this dream.
Communication between the subconscious and conscious mind:  Sometimes, it feels like the mind knows that its a dream going on. If its a sweet and charming dream - the mind says - keep sleeping, have more of it. While, when its a fearful, tragic or painful dream, the mind jolts us out of it, when we are no longer able to take it.
There are countless amazing facts about dreams. Newborns who hardly know what to do and how to do when they are awake, are able to dream. Animals, who so much lack the intellect that human race boasts of, even they are as capable of dreaming as us. Some of you must have had dreams of future forecasts as well - like the exact number on your mark-sheet in  that maths paper etc.  But "why do we dream" is still a mystery. If you come to know something interesting about these dreams, do share across.

Here's a resourceful article on dreams: http://www.psychologytoday.com/blog/the-literary-mind/200911/why-do-we-dream.
More reference materials:
http://psychology.about.com/od/statesofconsciousness/p/dream-theories.htm
http://news.nationalgeographic.co.in/news/2011/11/111129-sleep-dreaming-rem-brain-emotions-science-health/

If interested to find more, just Google for "why do we dream" and you would get numerous links around the same.


Wednesday 14 August 2013

Paneer Malai Kofta

Difficulty Level : Medium 

Time Required : 1 Hour +


This recipe is not really tough, just takes a bit more time to prepare - anywhere between 30-45 minutes. But once done, you won't at all regret the time spent, and in fact, you would like to spend time on it as much as possible :)
Here goes the recipe, I prepared it yesterday and my whole family liked it a lot. This recipe would serve 4-5 people.
Ingredients:
  • Potatoes - medium - 3 , boiled and peeled
  • Paneer or cottage cheese - 200 gm
  • Raisins - 1 tbsp
  • Cashewnuts - 3 tbsp
  • Fresh cream - 1/2 cup (if not available , replace by 1/2 cup thickened milk)
  • Coriander powder - 1 and 1/2 tsp
  • Garam masala powder - 1/2 tsp (I substituted it with kitchen kind masala)
  • salt - as per taste
  • Corn flour - 3 tbsp
  • Refined oil - 1 cup - for deep frying the koftas
  • Vegetable oil or mustard oil - 3 tbsp for preparing the curry
  • Onion - 1 large
  • Tomatoes - 2 large
  • Green chilli - 1
  • Khara garam masala - 2 cardamom, 2 cloves and 1medium  piece of cinnamon
Method:
For the Koftas:
Mash the potatoes. Grate the paneer and add to the mashed potatoes. Add corn flour, salt to taste , 1/2 tsp coriander powder, 1/4 tsp garam masala powder, all the raisins and 1 tbsp cashew nuts to it. Mix everything together. Take small amounts of this mixture into your hand and roll into a round ball. 
Try making all the balls of the same size, for this, you can pre-divide the mixture into equal portions. You can make small, medium or large balls depending on your choice. Put a heavy bottom pan on the stove and pour the refined oil into it. Let the oil heat up to frying temperature. One by one drop the balls in the the oil and let them fry till golden brown. Turn them once or twice so that they are equally fried from all sides. Take them out. Below are some snaps of the balls (koftas) that I prepared:
One side of the plate are the koftas which are fried (golden brown ones) and the other side are the one to be fried.


All koftas fried :)
For the curry or gravy:
Peel and cut the onion into 2 halves. Cut the tomatoes in 2 halves as well. Add them to a pan with water and let them boil on medium heat for 7-10 minutes. Once done, put off the flame, take them out and let them cool. Add 2 tbsp cashew nuts to water and leave them soaked for 10 minutes. After 10 minutes, grind them to a fine cashew paste and set aside. Once the onion and tomato pieces are cold enough to grind in a mixie, add them to the mixer along with the chilli and grind to a smooth paste. Put a wok on the flame and add the mustard oil to it. When hot, add the onion and tomato paste and then fry it till the raw smell of tomatoes is gone (takes nearly 10 minutes) . Then add to it 1 tsp coriander powder, 1/4 tsp garam masala powder, salt to taste and fry for 2-3 more minutes. Now add the cashew paste and fry for one more minute. Add the khara garam masalas to it. Now add the whipped cream and mix everything so that the gravy has a smooth texture. Add 4-5 cups water and let it boil to a smooth consistency. After 2-3 minutes, turn off the flame and drop the kofta balls into the gravy. Your paneer malai kofta is ready, let it sit for 10-15 minutes before serving, the kofta will absorb the gravy and thus, the gravy will become thick in consistency.
After that you can serve it with naan, or tandoori roti or freshly made rice or any rice preparation like pulav or jeera rice.
Decoration :
You can decorate your yummy paneer malai kofta with some grated panner, some red chilli powder, corainder leaves and top it with fresh cream. Below is a snap of how mine looked like:
Paneer malai Kofta, just after putting off the flame.

Paneer Malai Kofta, after it absorbed the gravy and was decorated with grated paneer.


Monday 12 August 2013

Development Manager - Demystified

In my pursuit to demystify a development manager role,(journey started from the post here) I went across a lot of articles and also a lot of job descriptions for the same. The job descriptions were highly inconsistent. Some wanted the candidate to have knowledge of some specific programming languages and be very much hands on into coding or code review etc, some others looked for someone who could understand people psychology and manage people well, yet another wanted PMO and other such certifications and the list goes on. And, as you know, even my experience so far with my development managers has been widespread.However, there were some common points that came out from all the places. I intend to summarize what I understood from it all.
Definition of a development manager: If you are a development manager, you can be most precisely described as a "man in the middle" who at times can be under "Attack" from all the sides and should have the "capability" to "counter the attack" in a "constructive and productive" manner. Well, sounds confusing?Same here. Let me break it down.
Man in the middle: What this means is that you are a link or bridge between your team and the rest of the world outside your team which would include the other teams, business or sales people, upper management or leadership of the organization, and everyone else that the team needs to interact with. In this role, you need to balance the expectations from both the ends , maintain good relationship on both the sides and help your team deliver the products / features, providing them the necessary cover from external distractions.
Your primary responsibilities as a development manager include the following:
1. Take the team along on the success road: You, as a development manager, not just need your
team to implement the features or products that you own, you are also responsible to see through the personal development of each and every team member. For this, you need to understand each individual in the team at a 'human' level, understand the strengths and weaknesses of each one of them. Then, you should be able to set short and long term goals for each one of them. These goals should align with the overall vision of the product and the organization and at the same time , every individual in the team should grow towards his/her own career aspirations as and when they achieve these goals.
2. Get the product out of the doors: Development manager is primarily responsible for resource planning, and align it with the product features and deliverable, within the given constraints of timeline and budget.During this process, you should plan to harness the strengths of each individual in your team to the best possible extent to get the maximum efficiency.
3. Be end - to - end accountable: From the initial planning to delivering the product out to the customer , each step is a development manager's own responsibility and accountability. Ofcourse, he/she needs to delegate work to the team in best possible way to achieve the same, and should definitely do work delegation.
4. Manage relationships: You need to manage relationship with the external folks like sales and customers. At the same time, you need to manage relationship within your team itself. Find out who has been in the company and for how long, get to know them better, keep track of small things like birthdays and anniversaries and other such details about the team and acknowledge these important times. Stand by your team in the crisis situation and extend moral support whenever required.
5. Follow processes: Every organization has its own unique set of processes and sometimes it can be overwhelming to follow new processes. Sometimes, when you are in start-up kind of environment, there may not be too many processes in place. Because of these reasons, a brilliant development manager always has some simple processes to follow, no matter what kind of organization he/she works for. Following your own set of processes to plan, keep track of things etc. in the best possible way that suits you, gets you going within no time.
6. Technical hands-on:You should have a good understanding of the product architecture, and if you
have hands on the technologies that are used in your project, its an added advantage. But, you should stop here, draw a boundary and not get into too much of technicalities. You should also be aware of new technologies, and you should be able to figure out your team's needs to learn new tools and technologies or to more efficiently use existing technology. You should encourage them to take trainings that enhances their technical skills. But you should leave the core technical decisions and details to the technical leads and senior designers and developers in your team.There's a reason they are there in your team - so that they can carry the technical expertise while you can focus on other responsibilities of yours in the organization. Of-course, you should participate in the design discussions and other technical discussions,if you can do justice to rest of your responsibilities and still have time for these.
7. Development:  Its a well-known saying in the IT industry that the best programmers make lousy managers. You need to have a basic understanding of best practices to write good code and you should ensure that your team is following the same, but you should never get into the details yourself here.
8. Administrative and staffing responsibilities: As a development manager, you would need to take care of a lot of administrative and staffing responsibilities. You would need to calculate the budget for your project, you would have to keep track of the project progress with respect to the budget and the timelines, you would need to take care of each individual's development and last but not the least, you should be able to account and accommodate for both hiring and firing or employee moving on in your team.
So, overall, there are a lot of responsibilities tied to this role, unlike an individual contributor role where the responsibility is mostly one - technical most of the time. The key to being a good development manager, in my opinion, is to be able to strike a balance , where-in you are able to divide your time between all of the above responsibilities and carry out each one of them. It's definitely not possible to please everyone at every point of time. So, being a development manager, you have to be able to make tough calls, and take definitive stands when required, but, there are some definite don't(s) defined for you:
1. Don't let arrogance or ego take up : " O! I have a bunch of people at my command, I am powerful!". "O! I have the ability to handle others and get whatever I want done from them". "O! N people report to me"."O!What I think is always right", "O! I was good at design before becoming a manager, so I can do that as well!" - Never let this kind of false ego or arrogance build inside you. You are a mere bridge between the team and external world, and people report to you for a streamlined organization structure - nothing more than that. You always have much more to learn at each point of time, you can never be always right, give space to others creativity.
2. Don't forget to distribute credit : You are nothing without your team! Always remember to
distribute credit for good technical achievements to your team - call out individuals who strode that extra mile, or thought out of the box, or coded efficiently or made a wise technical decision or what not - that eventually contributed to the overall success of your project. Remember that human race is always hungry for praises and its the simplest tool to increase their zeal to achieve more and get better.
3. Don't treat your team as a mere tool : "I can get any kind of work done, because I have a team whom I can make work on anything and everything and definitely deliver it" . Again wrong. You have a set of people with certain skill sets and yet another set of skill sets that they want to develop.Treat them human because that's what they are. Never ignore their own aspirations and progress, treat them equal and give them sufficient space to innovate, and create. Accept the fact that they may come up with something which can be better than what you thought of, and the end result can be much better for the team as a whole.
4. Don't neglect any of your responsibilities : "O! I have good relation within my team, I need not spend too much energy trying to bond with that sales guy, if the team makes a brilliant product, sales will be bound to sell it". OR "O! I have to make relation with external folks , I can look inside the team later on". You would be in trouble in both the cases. Don't neglect any of your responsibilities. You might have to prioritize one over the other, but at the end of a month or so, you should look back and reflect, and only be satisfied if you have done justice to all of them over the period of that one month.
5. Don't judge too fast : Your primary responsibility is to deal with people in and out - means people within your team and people outside your team. You should give yourself time and understand each one of them, figure out their strengths and potential improvement areas. Don't judge people too fast. This way, you might yourself end up having wrong expectations or misjudging the efficiency or potential of a team member - which would impact the effectiveness of your resource plan etc.
6. Don't play the blame game: When it comes to crisis, stand by your team. Don't blame a failure on your individual team members. Talk to the team members concerned, point out the error to them in a one-on-one kind of discussion so that they can improve upon it, but when facing the external world - never try to make an individual the guinea ping of your project failure. Be a team player.
7. Avoid Micromanagement : You have got to trust your team. Nothing can be achieved without trust. You need to delegate work to senior team members, set timelines and see through tools that they are on track, you need to delegate the micromanagement of very junior folks to these senior members, who can be their mentors as well. But you need not be dancing on the head of your team for getting things done, majority of the times, that leads to the team being rather unproductive. If you want your team to be more productive, the right way of achieving that is to generate motivation and interest in the team with respect to the work that they are doing. Keep them motivated by helping them grow, providing them the big picture of organization, maintaining transparency and giving them the business insight. Provide them the sense of achievement and contribution.

With that, I come to a summary of the learning that I could gather from my studies on the subject. Please suggest more additions, lets try to compile an idle development manager requirement :)

Saturday 10 August 2013

How to make pizza base at home

The below pizza base recipe would be adequate to make 4 medium size thin crust pizza or 4 regular size thick pan pizzas.
Ingredients required:

  1. 4 cups refined flour 
  2. 2 tsp dry yeast
  3. 1 cup warm water or 1/2 cup warm water and 1/2 cup milk
  4. 1/4 cup olive oil or vegetable oil
  5. 1 tsp baking powder
  6. 1 and 1/2 tsp sugar
  7. 1 tsp salt
Method:
take 1/2 cup water and 1/2 cup milk. Mix together and then warm it up either on stove or in oven, it should be luke warm (when you put your finger into it, it should be tolerable). I heat mine in the microwave oven at 350 W for 1 minute. Add the yeast to this water and milk mixture and stir to dissolve the yeast completely. Add salt and sugar to this mixture and dissolve them as well. Set aside for 10 mins (this would help the yeast start fermenting). Now take the flour in a container where you can kneed it. Make a well in the center and then add the olive oil to it. mix well by rubbing the flour and the oil mixture between your palm. Now start kneeding it by gradually adding the yeast mix to it, if required, add more water and kneed to a soft dough. Trasfer this dough to a clean container, dusted with refined flour, cover with a wet cloth and set aside. Let it sit like that for 40 min - 1 hour in a warm place. This would ferment the yeast and the flour would rise to double the original size.
After an hour, make 4 equal size balls of the dough. Roll out each ball in a round shape pizza base. You can do it either with the help of a rolling pin or you can simply beat the ball with your hand, slowly expanding it in all directions. I prefer the rolling pin method because it gives a smooth and even base. When rolling out the pizza base, dust the ball once with plain flour or flour and then you can go ahead and roll it. Roll the base out to the thickness that you desire.
Now comes the baking part to cook the pizza base. For baking, preheat the over to 220 degree celcius. Now , we would bake the pizza bases one by one. Put the first pizza base into a round baking tray or on the microwave grill and then put it inside the microwave, let it bake for 5-7 minutes on 220 degree celcius if you require a softer base, if you want crunchy base, further bake for 2-3 more minutes till you see the base has become crispy. You would also see the base rising like a roti while it bakes. 
Once done, you take the pizza base out, spread pizza sauce, your selection of toppings and cheese on top of it and then put it back in the over for just 1-2 mins on regular microwave (350 W). Take it out and its ready to be eaten.
Alternatives:
For the base material: If you prefer a more healthy pizza base, you can use a 1:1 mixture of refined flour and normal wheat flour.Further more, you can altogether use wheat flour. Or, you can use a mixture of wheat flour with other healthy flours like soya flour, and crushed oat. 
For baking the pizza: You can bake the pizza base on a pan as well, if you don't have a microwave oven. Put it in a pan with cover / lid, cover and cook on low flame for 5-6 minutes (or as per the crunchiness required).


Wednesday 7 August 2013

Who is a development manager

Well, I am not a development manager..I am rather a software engineer who has worked with so many so called development managers, that at this point of time, I am seriously confused who a development manager really is. Any ideas? So, in this post, I intend to present to you the picture of different development managers that I got to work with so far. I am really serious about finding out who a development manager is supposed to be, now that I am in a position where as soon as the next promotion happens, I might end up being one myself.
micromanager
The "micro manager" : The first manager that I worked with on starting my career in the IT industry. Really great with those huge excel sheets, pie charts and graphs and what not, equally efficient when it came to dancing on the head of a developer to ensure that the deadlines were met, but equally lousy at gluing the team together, standing by the team in crisis situations and helping the junior folks develop in their career path. I think he had hardly seen any organization than just one, and he was very much molded into the culture of that one organization, happily settled ever after, not much bothering about what was expected out of him from the team.
the hero manager
The "experienced manager"  : This time, I switched my job and the new organization was  a start up, there was just one manager,and the team was also under construction.Looked like the  manager had 
rich experience from some of the top notch software companies and he was here on the mission to start a team and a project from the scratch. He was more senior, better balanced. I was greatly amazed by the balance of his project management and people management skills, there were people in the team who had earlier also worked with him, and they looked up to him like a mentor.He was the best manager so far that I had got a chance to work with.But again, one thing that he lagged was a regular 1:1 with the team members, particularly junior ones like the ones at my level.
The "novice" manager :  As the team in the second organization grew, this guy was promoted from a senior engineer directly to a development manager, although he tried to do full justice to the role as per his capabilities, but we saw a steep decline in the team size as quick as 2 months since he became manager. He was learning and grooming his skills while already on-board. But I really appreciate the way he embraced all feedback from the team and tried to become better day by day. By the time his tenure was over with the organization, even I had got a lot to learn from him.
The "I am always right" manager : Great business insight, unmatched skills when
I can do everything and I am always right manager


it came to creating and maintaining great relation with external stakeholders, even clients. Big time salesman when it came to selling what his team had created. But, and here comes a big but, jack of all trades - one man army who wanted to handle everything from business to product requirement to project plan to design and architecture. Its a pity he didn't get time to code, and then test it out, else, I am sure he would have done that as well. He viewed his team more as a tool to achieve what he wanted. Everyone was supposed to do what was narrated to them. Also, there were no goal settings with the team, no people management. Didn't respect the view of anyone else, used funny logic to always get his ways. The irony is that - this guy had the most innocent outlook covering the most cunning inside!!!
The manager who made me run away: Last but not the least, this was the manager with whom I got to talk when I was about to accept an offer extended from his organization and team. He was so lousy, his body language and personality was so negative, that I changed my almost final decision to join that organization, after meeting him.

At this point of time, I would like to state that the intention of this post is not to offend any of my previous managers in any way or portray the development managers negatively. What I want to say here is that, in a short span of 5 years in the IT industry, I have seen so many colors of development managers that it has left me baffled. There is something fundamentally not in place here.The questions that arise in my mind are - Is it that the ask from the position is too much? Is it that the number of responsibilities that a development manager is supposed to handle are too much for one single individual? Or is it that we have a lot of half baked development managers around - maybe because the expectations from the role vary across organizations and industries? Sadly, I don't have the answers at this point of time, but I am planning to continue my search for the same, and intend to be able to soon come up with a "Development Manager Demystified". :)

Tuesday 6 August 2013

The Insertion Sort

How Insertion Sort works

Insertion sort is a simple sorting algorithm where the final sorted array is built by traversing through the array, taking one element at a time and placing it at its right location as per the expected sorted array.

Efficiency of insertion sort

Best case (sorted array is provided as input) : O(n)
Worst case(reverse sorted array is provided as input): O(n^2)
Average case : partially sorted array : O(n+d)
where, n = number of elements in the array and d= number of inversions required to sort the array (inversions = shuffling/interchange of array elements)

The more sorted an array is, the lesser would be d (number of inversions) and hence faster would be insertion sort algorithm.
The nature of insertion sort makes it more efficient than many other quadratic sorting algorithms like bubble sort and selection when the list to be sorted is not too huge , also, the more the list to be sorted is near to being sorted (nearly sorted lists), the better this algorithm would perform.

Advantages of insertion sort

  • It is simple to implement
  • It is quiet efficient for small sets of data
  • It is more efficient than most other quadratic sorting algorithms
  • It is stable, which means, if there are more than one elements with the same keys, their relative order remains unchanged
  • It is in-place. only requires a single extra element, which would count as constant O(1).
  • It can sort a list on-the-go, which means, as and when it is taking inputs, it can keep sorting them.

Insertion sort algorithm implementation in java

public class InsertionSort {
    public static int[] insertionSort(int[] arrayToSort) {
        int key;
        for(int i=1; i < arrayToSort.length; i++){
            //within the outer for loop, assign the next element as 'key'.
           //key is the element which is to be placed at its right location within this iteration of loop
            key =  arrayToSort[i];
            //start traversing from the back of the array in the inner for loop
            int j = i-1;
            //traverse through the elements which are greater than key and shift them as and when we   
            //traverse , one space further, to make space for the key at the right location
            for(; j >= 0 && key < arrayToSort[j]; j--){
                //shift the elements greater than key further in the array
                arrayToSort[j+1] = arrayToSort[j];
            }
           //finally place key at its right location
            arrayToSort[j+1] = key;
        }
        
        //print out the sorted array
        System.out.println("Sorted array:");
        System.out.println();
        for(int i=0; i<arrayToSort.length; i++){
            System.out.print(" " + arrayToSort[i] + " ");
        }
        System.out.println();
       
        return arrayToSort;
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        List<Integer>listToSort = new ArrayList<Integer>();

        //Take input from the console
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(in);
        System.out.println("Input comma separated list of integers and hit enter when done");
        String inputStr = br.readLine();
        String[] splittedInputs = inputStr.split(",");
        for(String str : splittedInputs){
            listToSort.add(Integer.parseInt(str));
        }
        while(!(inputStr = br.readLine()).equals("DONE")){
            listToSort.add(Integer.parseInt(inputStr));
        }
        //call the insertion sort method
        insertionSort(listToSort.toArray());
    }

}

Reverse Insertion Sort

During Insertion sort, the array elements are normally sorted in ascending order (first element of array = smallest and last one = largest). In case of reverse insertion sort, they are sorted in the descending order. Below is a java function for reverse insertion sort implementation :

    private static void reverseInsertionSort(int[] arrayToSort) {
        int key;
        for(int i=1; i < arrayToSort.length; i++){
            key = arrayToSort[i];
            int j = i-1;
           //here's the difference from the actual insertion sort
           //we traverse the array backward in the inner for loop and shift the elements which are 
          //smaller than the given key, to find the right place for the key (we shift the elements 
         //larger than the key, in case of normal insertion sort).
            for(; j >= 0 && key > arrayToSort[j]; j--){
                arrayToSort[j+1] = arrayToSort[j];
            }
            arrayToSort[j+1] = key;
        }
 

         //print out the sorted array
         System.out.println("Selection Sorted array:");
        for(int i=0; i<arrayToSort.length; i++){
            System.out.print(" " + arrayToSort[i] + " ");
        }
    }


Monday 24 June 2013

Tangy spicy potato roll

This roll is again very easy to make, with minimum ingredients and is tangy and yummy. Acts as a good appetizer. Can also be used a full fledged lunch or dinner recipe. So, here goes the recipe -
Ingredients for roll:
  • Flour (Aanta) - 2 cup
  • Milk - 1/4 cup (or as required, to be used while kneeding the dough)
  • Water (for kneeding the dough)
Ingredient for filling:
  • Potatoes boiled and peeled - 4 to 5
  • Curd - 1/4 cup
  • Turmeric powder - 1/4 tsp
  • Coriander powder - 1 tsp
  • Cumin powder - 1 tsp
  • Salt to taste
  • Chaat masala powder - 1 tsp
  • Green chilli - 2 to 3
  • Green peas - 1/2 cup (optional)
  • Onion - 1 large
  • ginger - garlic paste - 1/2 tsp
Ingredients for garnish:
  • Mayonnaise - 5 tbsp
  • Coriander - finely chopped - 2 tbsp
  • Tomato sauce - 2 tbsp
  • Lettuce leaves - cleaned and washed
Method:
  •  Cut the potato into small cubes (need to be of even size). You can even mash the potato lightly so that they break into uneven crumbled pieces.
  • Add coriander, cumin, turmeric powder and chaat masala powder to the curd and mix well.
  • Add potatoes to the curd mix and mix well so that the potatoes get coated with the curd.
  • Now put the potato mix in the freeze to marinate
  • Cut the onion into thin long slices and keep aside
  • Now, while the potato marinates, we can prepare the rolls base (chapatis)
  • For this, make a soft dough out of the flour by adding the milk and then water as required.
  • Divide this dough into 5 equal large balls and roll each ball into a chapati (round one) with the help of the rolling pin
  • Now heat a pan. Here you can either bake the rolled out chapatis without applying any oil or you can brush it up with butter or oil on both sides . Cook each one to a crisp chapati if you are using ghee or oil, put in a hot pot or bread basket so that it remains hot.
  • Now heat a thick bottom pan and add 2-3 tbsp of refined oil to it.
  • Once the oil heats up, add the onion and ginger garlic paste to it and saute till the onion turns translucent.
  • Once the onion is translucent, add the peas to it and cook for a minute or so
  • Now, add the marinates potato mix to this mixture and stir properly so that everything mixes up well and fry till potato turn a bit golden in color
Potato filling while its frying

  • Now add salt to this mix as per taste and mix well.
  • Spread out each chapati one by one, spread a layer of mayonnaise and a layer of tomato sauce on it. Spread a lettuce leave on top of it to cover almost the whole roll.
  • In the middle, add a thin layer of the potato mix.
  • Spread some coriander over it
  • Roll out the roles from it.
  • Serve hot with green chutney or chilli sauce.
And the rolls are ready...

Monday 3 June 2013

Super Fast Egg Bhurji (Dry Egg Dish)

This Egg bhurji is another super fast recipe that I tried this week. It takes just 10-15mins for preparing it for 2-3 people. Its one of my time saving favorites now and guess what, hubby is not very keen of dry recipes (those without gravy) but he liked this one very much. It can be made as a replacement to a dry vegetable to have with chapatis or it can be used as a quick delicious side dish to almost any main course recipe. It can also be used as an appetizer during morning breakfast or evening snacks - in fact, anytime :)
So, without wasting further of your precious time, here goes the recipe:

Ingredients:

  • Eggs - 3
  • Onion - 1 medium
  • Tomato - 1 medium
  • Salt - to taste
  • Oil - 2 tbsp
  • Coriander powder - 1/2 tsp
  • Cumin powder - 1/4 tsp
  • Turmeric - 1/4 tsp 
  • Coriander leaves - cleaned and cut into small pieces - 1 tsp
  • Green chilli - 1

Method:

  • Cut onion, tomato into small pieces
  • Cut green chilli into fine pieces
  • In a thick bottom container, heat oil
  • When oil heats up, add the tomato and onion and saute till the onion turns translucent
  • At this point, add the spices,chilli and salt
  • Now, break the eggs and pour the content in the container
  • Mix the egg well with quick and swift movements of the spatula with rest of the ingredients. After a minute or so, the recipe would look like this:
                         

  • Stir for a minute or so, you need to take care that the eggs are neither sticky and watery nor do they dry up completely. When this consistency is reached (2-3 minutes after pouring the eggs in the container), turn off the flame
  • Add cut coriander leaves to this and your dry egg recipe is ready. Serve it hot with any main course, tea, or you can have it all on its own as well.