Tuesday, May 12, 2009

Longest Common Increasing Subsequence


I recently came across the problem of computing the Longest Common Increasing Subsequence(LCIS) of 2 given sequences. What does LCIS mean? Given 2 sequences of integers, we need to find a longest sub-sequence which is common to both the sequences, and the numbers of such a sub-sequence are in strictly increasing order.

So for example, given the 2 sequences:


  • 4,3,5,6,7,1,2 and

  • 1,2,3,50,6,4,7



Possible common increasing sub-sequence of the 2 sequences above are:

(4), (3), (7), (6), (1), (2), (1,2), (3,6), (3,7), (6,7), (4,7) and (3,6,7).

The LCIS of the 2 sequences would be (3,6,7). It so happens that the 2 sequences above have a unique LCIS, though that may not always be the case.

Now, how do we go about computing the LCIS of 2 sequences in a reasonable amount of time? If we think a bit, we can come up with the recurrence:

LCIS_length(seq1, seq2, prev_elem) is equal to:
  1. MAX(LCIS_length(seq1 less it's first element, seq2 less it's first element, first element of seq1)+1,
    LCIS_length(seq1 less it's first element, seq2, prev_elem),
    LCIS_length(seq1, seq2 less it's first element, prev_elem)).
    If the first elements of seq1 and seq2 are the same AND the first element of seq1 is > prev_elem.

  2. MAX(LCIS_length(seq1 less it's first element, seq2, prev_elem),
    LCIS_length(seq1, seq2 less it's first element, prev_elem)).
    If the first elements of seq1 and seq2 are different.



Now, if we implement it just the way it is, it is going to be quite expensive to compute the LCIS_length for any sequence having a length of more than say 20 elements. So, we want to use an approach which would work for larger input. On further thinking, we think that a faster(polynomial time) approach is possible.

Let's lay out both the sequences along the first row and column of an nXm matrix, where n and m are the lengths of the 2 sequences given.














4356712
1
2
3
50
6
4
7




Let's define each cell to hold the length of the LCIS ending at the row(or column) that that cell is defining. For example, cell [6,1] will hold the length of the LCIS that ends with the number 4. The cell [5,2] will not hold any meaningful value since there can be no sub-sequence that ends with both 6 and 3. Similarly, the cell [7,5] will hold the length of an LCIS that ends with the number 7.

What we will do is we run 2 for loops, one for the row and one for the column, and each time we find a match between an element in the top row and the left column(i.e. The input elements), we will try and find some sub-sequence computed till now that can be extended by the number that that cell represents.

It should be clear by now that the number that the cell [x,y] represents is the number in the first column in the row 'x' OR the number in the first row in column 'y' ONLY IF both these numbers are the same. For example, the cell [2,3] can NOT represent any number, whereas the cell [3,2] represents the number 3.

A sub-sequence that can be extended by a number in cell [x,y] will always lie in the matrix of which the cell [x-1,y-1] is the right-bottom most cell. Let is refer to such a matrix as the candidate matrix for cell [x,y]. For example, we have highlighted all the cells which can have potential candidate sub-sequences that can be extended by the cell [5,4](which represents the number 6).















4356712
1
2
3
50
6
4
7





Let's start working out a solution row-by-row.

We need to remember that while processing the 1st row, there is NO sub-sequence that can be extended by any sub-sequence that ends with a number in the first row! This would be the situation after we finished processing the first row.
















4356712
10000010
2
3
50
6
4
7



When processing further rows, we check the candidate matrix of each cell being processed, and always extend the LCIS in the candidate matrix that ends with a number less than the representative number of the cell being processed.

When processing the 2nd row, we notice that a sub-sequence ending at 2 can extend a subsequence ending at 1 because that sub-sequence is the LCIS that ends with a number less than 2 and lies in the candidate matrix for the cell [2,7].














4356712
10000010
20000002
3
50
6
4
7




Similarly, after processing all the rows, our matrix looks like this.














4356712
10000010
20000002
30100000
500000000
60002000
41000000
70000300




To find the LCIS, we search for the largest number in the matrix, and that gives you the length of the LCIS and also the number at which such an LCIS ends. To trace the LCIS, we need to find the largest number that lies in the candidate matrix of the cell to which this largest number belongs. In the figure below, the cell and candidate matrix have been highlighted in green and yellow colours respectively.














4356712
10000010
20000002
30100000
500000000
60002000
41000000
70000300




Tracing thus, we land up with 3 cells(marked in green).














4356712
10000010
20000002
30100000
500000000
60002000
41000000
70000300




The LCIS is just the numbers represented by the cells marked in green, when taken in increasing order of their value. i.e. (3,6,7).

The complexity of the approach presented above is O(n4). Can we bring it down?

If you notice, you will see that for each index representing numbers in the top most row, there is a unique integer associated with it. For example, indexes 1,2,3,4 are associated with numbers 4,3,5,6. There is always one integer associated with every such index. If we think a bit, it should be clear that whenever a CIS ends at some such index, and another longer CIS also ends at that index, then it is sufficient to just keep the larger of the 2. This is because the way in which we are processing the input(row-wise) allows us to track just the LCIS ending at any index.

If we adopt such an approach and use an auxiliary array to hold the LCIS ending at every such index, we land up with an O(n3) solution since we now need to scan just a single array for every element instead of an entire matrix.

However, if we think a little bit more, we can see that we don't even need that scan, since we can always maintain(for every row scanned), a single variable holding the length of the LCIS that the number(N) in the first column of that row can extend. Whenever we encounter a cell which has the same representative number(N), we store a number one more than an LCIS that can be extended by this representative number of such a cell. This brings down the complexity further to O(n2).

Re-constructing the LCIS can be trivially accomplished in time O(n) if we use extra space to the order of O(n2) and this is left as an exercise for the reader.

Sunday, April 12, 2009

A cool definition of money....

Money is what it's function is....

Effective Delegation

I realise that one thing I need to learn, and learn fast is how to effectively delegate responsibilities to others. It is truly an art. How to pick someone for a task such that the probability of it's successful completion are upped significantly. Firstly, I think I need to be confident that I can trust someone with a certain task, and once that is done, how to choose that someone such that there is enough internal motivation for that person to run that task to completion.

Delegation solves a lot of problems if done well.

Some questions:
[1] What to delegate.
[2] When to delegate.
[3] Whom to delegate to.
[4] How much to delegate.
[5] How to create/detect internal motivation for effective delegation.

Wednesday, February 04, 2009

The Ticking

Often have I seen this line
That people are a slave to time
and when hey miss their train divine
they seldom cry but often whine
But they will when they think it fine
wait outside a royal dine.

And in the morn, when they do tick
get up they will very slick
for when they hit the ticking clock
like the feathers they will flock.

If at the time their path you block
won't they spare a living stock
and ruthlessly they will knock
for they fear the dreaded dock.

Nature hath it's living foes
and friends they o become galore
When they adorn their pretty robes
That do negate it's wily woes.

Tuesday, January 13, 2009

GIGO

Sometimes, the the title of a post doesn't quite describe what the post is all about. I think this post is a classic case of the above.

I'll try to keep it as simple as possible.

Suppose you are writing a program to compute the factorial of a number, you would also add a function to find if a string is a substring of another string, or check if a string is a palindrome? If you answer "yes" to any of the above questions, I would surely like to see you actively use the above in your program. For the rest of you un-interesting lot(Rule:0 of blogging; never lower the self-esteem of your readers), I would like to ask you if you would eat a packet of biscuits just because it was available for free. I'm guessing you wouldn't eat anything unless you were hungry, and if you consider biscuits as not belonging to the class of "healthy foods", you probably wouldn't eat those as well.

Friday, January 09, 2009

Maximum Atiguous Sum of a Sequence(Array)

Let me first explain what the question is.

Given an array(a sequence of non-negative integers), we need to find that subsequence of this sequence such that:
1. No element in the subsequence is adjacent to any other element in that subsequence in the original array(atiguous).
2. The sum of the elements of this subsequence is the maximum for any subsequence of the array which satisfies (1).

I was asked this question in an interview but was able to come up only with a very inefficient solution for it. That solution consisted of enumerting all possible subsequences which satisfied (1) and find the one that gave the maximum sum. Only after a week did I come up with a solution that is Linear in complexity, and examines each element of the array just once.

I present it below and leave it up to the reader to modify the solution so that it works for negative integers as well. Hint: In case all the numbers are negative, the solution will contain no elements and the value of the maximum atiguous sum will be zero(0).

But before I present the solution, let me discuss how I got to it.
For the longest time, i was under the impression that the only solution that could exists would be the one that consisted of enumerating all sets with atiguous elements. However, on thinking more on it, it seemed that the solution could be improved because if you see, you must choose 2 out of every 4 contiguous elements, whatever way you look at it. Also, you may choose 1 or 2 out of 3 contiguous elements. Similarly, you could choose 0 or 1 out of 2 continuous elements. This means that in the worst case we will have a solution consisting of abs(N/2) elements for a sequence of N elements, and in the best case we have a solution consisting of abs((N+1)/2) elements.

If you solve this problem using the enumeration method, but continuously adding elements to a smaller sub-sequence, you will notice that the best solution involves choosing either the sum 2 elements later or the sum 3 elements later; adding it to the current element, and saving the maximum of these 2 values as the maximum sum up to the current element with the current element as a constituent. At the end of this exercise, the final solution is the maximum of the 1st or 2nd element(considering that we are working backwards).



import java.util.*;

public class MaxAtigSum {

static private Vector
getIntegers()
{
Vector ret = new Vector();
Scanner sin = new Scanner(System.in);
while (sin.hasNextInt())
{
Integer val = sin.nextInt();
ret.add(val);
}

return ret;
}

public static void main(String[ ] args)
{
Vector ints = getIntegers();
Vector soln = new Vector();

// Pad the array with 3 integers more than the ints array.
System.out.println("Size of input: " + ints.size());
for (int i = 0; i < ints.size() + 3; ++i)
{
soln.add(0);
}

for (int i = soln.size() - 4; i >= 0; --i)
{
soln.set(i, ints.get(i) + Math.max(soln.get(i+2), soln.get(i+3)));
}

System.out.println("The maximum atiguous sum is: " + Math.max(soln.get(0), soln.get(1)));

}
}


Update (22/06/2010): This is probably the first and last time I hope to write Java code. Such a verbose and ungainly language have I never seen.

Sunday, November 30, 2008

Marketing; the 8th sin?

Did you ever notice how people when the see advertisements tend to either:
1. Believe everything that's shown or
2. Believe only part of what is shown.

Well, I think this has to do with the fact that advertisers tend to (un)intentionally blur the facts to promote their products. I say that because it is not always don't intentionally, but sometimes, it is because of difference of opinion between individuals. Besides the utility of a certain product/feature, is entirely subjective and depends on the individual under question.

I think we sometimes wrongly blame marketing people for their (mis)doings, but I do believe that they need to get their act together and try and stay as close to reality as possible.

The thing with ads is that you can't have an enticing ad that is just factual. It needs to have some sort of feeling or direction to it and that isn't achievable by just spitting out the facts. People sometimes need to be told what use a toothbrush would be to them. You can't just highlight the features of a toothbrush without moping around the teeth, gums and bacteria aspect.

I think advertising will really come of age when advertisers learn to maintain the right balance.

Tnirwahtg gogole's ad "feraute"

I was tihnnikg auobt goolge and all the ad ruenvee it geaenerts and
all the ixndees it mannitias and all our dtaa taht it ixndees and
mekas alabalive for popele to secrah and fnid. Waht if "what if" I had
this piece of data taht I didn't wnat any srcaeh eignne to be able to
unrntesdad and yet allow poelpe to be albe to read. No ads geeaetrnd
besad on the cnentot, but yet ppeole can raed it. Iesrriceptve of the
robots.txt file, the data souhld NOT be ietpntrered in a viald faoihsn
by mniehcas. Mybae tihs isn't a lnog trem sooutiln, but it sure wroks
for now! Now only if I can find a vliad use for it :-p

If you wnat the spcrit, send me an eiaml at "dhruv \bbird@" + "google"[0] + "mail.com"

Sunday, November 09, 2008

Mummy's "Jeeradu" masala

"Jeeradu" is a masala that we use to flavour our buttermilk and lemon juice. You can add it as-is to buttermilk and optionally sweeten it with sugar. You can also add this masala to a glass of lime juice along with sugar and optionally some salt to get a refreshingly fresh drink!



























Jeera(Cumin seed) powder:1 unit
Dry Ginger powder(Soonth):1 unit
Black(Rock) salt powder:3/4th unit
Table salt powder:1/2 unit



Mix up all the above ingredients well, and use about 1/2tsp per cup of the drink required!

Nani's Chai Masala

This is the recipe for the chai masala that makes my chai what it is! It has been passed on to my mother from her mother(my nani) and now to me....

Ingredients:































Cinnamon Powder:3/4th Tbsp.
Clove Powder:1/2 cup
Black Peppercorn Powder:1 cup -(minus) 1 Tbsp.
Cardamom Powder:3/5th Cup(60% of a cup)
Ginger Powder(Soonth):2 cups



1 cup is 240ml.
1 Tbsp is 15ml.

I grind the cardamom along with their skin. This adds taste and also saves a lot of effort!

Just mix up all the powders given above well and use it in you tea. Approximately 1/4th tsp. for 2 cups is what I use. You can always experiment and find out what works best for you!

Wednesday, November 05, 2008

Dadi's Rava Sheera

This is a sheera which I can never get enough of. Every time my Granny(Dadi) makes it, I am the first person to have it hot and fresh, and I have about 10 pieces in the average on the first harvest ;-)

I saw her making it once, and here is the recipe for this mouth-watering dish....

Ingredients:



















































Rava(Semolina):1 cup
Cow's Ghee(Clarified Butter):1/2 - 1/3 cup
Sultanas(Raisins):20 - 25 nos.
Boiling Water:3 cups
Powdered Kesar:1/2 tsp
Grain Sugar:1 1/4 cup
Nutmeg(jaifad) powder:1/8 tsp
Cardamom(elaichi) powder:1/2 tsp
Badam &Pista powder:1 Tbsp




Procedure:






  1. On a medium-low flame, heat the ghee, and when a little hot, add the rava.


  2. Boil 3 cups of water


  3. When the Ghee starts separating from the mixture, reduce the flame to low &add sultanas. Keep stirring till the sultanas swell up by soaking the Ghee.


  4. Add boiling water in 3 additions in intervals of 15-20 sec, stirring all the time.


  5. After a while, the mixture in the pan will stop sticking to the pan. Cook for 30 sec. more and add all the sugar.


  6. Increase the flame's intensity to medium, stirring all the while.


  7. When the sugar has dissolved and the water of crystallization has left the sugar, add the powdered saffron to ensure that it is distributed evenly across the product.


  8. When the mixture in the pan has completely left the pan and is very easy to stir, reduce the flame's intensity again to low.


  9. Add nutmeg powder and cardamom powder.


  10. Quickly put the mixture into the settling vessel(typically a thaali or a steel box) and sprinkle the shopped nuts all over. Do NOT press the top of the sheera.


  11. Let the sheera cool. You can cut it into pieces when warm and enjoy it the most right now!




Sujata's Elaichi Nankhatai

I had been searching for a good nankhatai product/recipe but hadn't been able to find one even after trying out many different recipes. I used to always compare it to nankhatai I had had at my nana's place, and none of them would live up to that standard. So, this time I decided to ask my mami, Sujata for the recipe. Here it is in it's unmodified form, and is makes really excellent elaichi nankhatai!

Ingredients:




































All-purpose flour(Maida):1 1/2 cups(170g)
Gram flour(besan):1/2 cup(45g)
Powdered sugar:1 cup + 2 Tbsp(175g)
Cow's Ghee(Clarified Butter):1 cup minus 2 Tbsp = about 210 ml
Powdered cardamom:1/2 tsp
Vanilla extract/essence:1 tsp




Procedure:






  1. Preheat the oven to 145°C - 150°C. If it is not baked at this temp, then the gram flour(chickpea) will remain uncooked. If you bake it at a greater temperature, then the chickpea will get burnt(overcooked)!


  2. Mix the maida, besan and elaichi(cardamom) powder well with a spoon for about 5 mins.


  3. Cream the Ghee and sugar just until they are mixed well.


  4. Add the flour mixture to the creamed mixture and mix using a wooden spoon or a spatula.


  5. Lightly knead into a smooth dough.


  6. Make small roundlets, place on the baking sheet and make a design on top with a fork. Or you could place a single charoli nut on each roundlet.


  7. Bake for 30 mins or less(till done). The cookies will feel silky smooth and the flour will peel off from the sided, but they are actually done.


  8. Cool and enjoy!




Dhruv's favourite Mava Cake!!!!

This is a cake that I truly relish and enjoy and I make using my own method. Since I love the cake and other people have also appreciated it, I feel like sharing the recipe....

Ingredients:


































































Maida(all purpose flour):80 g
Mava(grated):40 g
Grain sugar:115g
Cardamom powder:1/2 tsp
Powdered Saffron:1/4 tsp
Vanilla essence:1/4 tsp
Eggs:2 nos.
Baking powder:1/4 tsp
Hot Water:2 1/2 Tbsp
Powdered dry fruits(pista and badam):2 Tbsp
Melted butter(salted):50 g
Vegetable Oil:3 Tbsp



You will also need a pan that is 25 sq. inches in area and at least 2 inches tall. I use a 7.3" X 3.5" X 4" bread tin.

Procedure:






  1. To prepare the pan, grease the pan, line it with parchment paper and then grease it again.


  2. Preheat your oven to 180°C.


  3. Mix the grated mava, flour, cardamom powder and paking powder very well with a spoon. Stir well for 5 mins to mix.


  4. Take the sugar in a bowl and break the 2 eggs in it.


  5. Mix the melted butter and oil in a separate vessel.


  6. Warm the saffron strands and grind into a powder.


  7. Add the powdered saffron to the butter & oil mixture and mix well.


  8. Heat 2 cups of water to a boil and turn off the flame. Set the egg container over boiling water(do not touch the base of the container to the water) and beat well till stiff peaks form.


  9. Add the vanilla essence and beat a little more.


  10. Add the 3 Tbsp of Hot water to the beaten eggs.


  11. Add about 3 Tbsp of flour mixture to the well beaten eggs and mix by stirring at the base. Take care NOT to over-mix or you will deflate the batter.


  12. Add the melted butter & oil mixture. Mix a little.


  13. Add the remaining flour and the powdered nuts and mix in using the same procedure taking care not to over-mix and deflate the batter. Work in small but quick strokes.


  14. Pour the batter into the pan and bake for about 50 mins. or till the cake is done. Test with either a toothpick or by touching the surface of the cake. A toothpick inserted should come out clean, or the surface should feel done(spongy, but not soft).



Tuesday, November 04, 2008

Mom's Gujarati Kadhi

This is the recipe for Gujarati Kadhi; the way my mom makes it. I have started liking this dish off late. Kadhi is usually accompanied by Khidchi but we have it as-is or with Steamed Rice or Steamed Jeera Rice.




Ingredients:





































































Green Chillies:2, sliced lengthwise and de-seeded
Dahi:1 - 1 1/2 cups
Besan(Gram Flour):2 - 3 Tbsp
Ginger Paste:2 tsp
Kadi Patta:Leaves of 4-5 sticks
Water:(1/2 + 1/2 + 3) cups = 4 cups(960 ml)
Jeera(Cumin Seeds):2 tsp
Vegetable Oil(or Butter or Ghee):1 1/2 Tbsp
Hing(Compounded Asafoetida) powder:1/2 tsp
Salt:To taste(or 3/4 - 1 tsp)
Jaggery:2 - 2 1/2 Tbsp
Fresh Corriander leaves:A fistful(for seasoning)
Sugar:1 1/2 tsp






Procedure:


  1. Add Besan to dahi. Add ginger paste to it.


  2. Add 1/2 cup water to the above mixture and it in mix with a mandhiani(apparatus used to make buttermilk from curds). When mixed well, add remaining water and wash the mandhiani.


  3. Saute chillies, kadi patta, hing and jeera in the oil.


  4. Make sure gas is on medium.


  5. Add the flour & curds liquid to the above and add the remaining water to it to adjust the kadhi's consistency. The mixture will thicken on cooking because of the gram flour(besan). Keep stirring the mixture to prevent sticking at the base.


  6. When the kadhi starts to boil, reduce the flame to slow and keep cooking for about 20 mins more. It is done when kadhi doesn't spill over when the flame's intensity in increased. Cook it sufficiently well or else kadhi will remain uncooked and will taste bad.


  7. Now, add the jaggery to it and stir in till dissolved. Add jaggery ONLY after the besan is cooked well.


  8. Add sugar to taste.


  9. Serve and enjoy!



Monday, September 22, 2008

Better than Kayani Shrewsbury Biscuits

After trying out many recipes and buying Shrewsbury biscuits from many more bakeries and shops, I have finally found a recipe that not only matches the Kayani Shrewsbury biscuits, but I would venture out to say "results in biscuits that are tastier than the ones at Kayani!!!!"





Here we go:

Ingredients:
o 100g Powder sugar(you can grind grain sugar for 5-10 sec to get this)
o 150g Pure salted Butter(I use Amul)
o 200g Refined flour(also called Maida or All-Purpose Flour)

Procedure:
1. Pre-heat the oven to 150°C.
2. Start off with butter right from the refrigerator and cream it till it is not solid.
3. Cream the butter and sugar just until the sugar is mixed with the butter.
4. Add the flour in one go, and use a cut & fold motion of the spatula to incorporate the flour.
5. Refrigerate for 5-10 min if the dough is oozing with butter.
6. Lightly knead the dough to form a smooth dough.
7. Refrigerate again if required.
8. Make about 24 equal sized balls and place them on a baking tray.
9. Flatten out just a little bit with a fork to form a "peda" like ball.
10. Place in pre-heated oven for 30 mins.
11. Enjoy!!!!

Tuesday, September 16, 2008

(For me,) Culture is:

unsaid, unspoken
questioned and found to be true
using makkhan and ghee
fresh garam masala
learning from mother
not a photograph
unexpressable, undescribable
knowing how to feed your baby
years of experimentation and knowledge
bundled into a neat package
more trustworthy than science at times
discovering the known
respecting your elders
a series of mutations
a never-ending process
something that transcends education but is akin to it
indestructible
being misunderstood by people today
underrated
taken too literally
knowing what nani used to make for mummy
using a mortar and pestle
more than The Flintstones
older than The Flintstones
not just a chapter in history, but my extended past
mine to give to the future
For me, culture is what it is....

Wednesday, September 03, 2008

About Yeast.

I was baking a loaf of bread, and for some reason, it didn't turn out as voluminous as it should have, so I decided to investigate what the problem was. The 2 loaves I had baked earlier too were not quite up to the mark so my suspicion fell on the yeast that I was using. I use fresh baker's/cake yeast, and it goes bad really fast. It has a refrigerated shelf life of about 3 weeks, but I had stored it in the deep freezer so that it was stored frozen. Baker's yeast can be stored frozen up to 6 months. The yeast I had was about 5 weeks old and had changed in both colour as well as texture.
Baker's or Fresh Yeast that you get in India is basically cake yeast which is available in cuboids starting from 500g. It costs Rs. 30 for 500g, and Rs. 56 for 1 kg. The brand I buy is called "Tower". Now this yeast when fresh has a creamish-yellow colour, and has a crumbly texture. i.e. It should crumble easily when you try to crumble it. If the colour changes to a somewhat darker shade and the texture becomes more paste-like(and hence does not crumble), it means your yeast has been working and is probably "tired". I do NOT know how to check yeast for tiredness because this "tired" yeast when mixed with sugar and water WILL bubble, but when you make bread, won't give a good second rise. And that is exactly what happened with me. I had stored a small amount of yeast in the refrigerator in what I thought was an air-tight container, but it was letting water vapour in so that was what had tired out the yeast. So when you start making bread, make sure your fresh yeast is creamish-yellow in colour and crumbly in texture. Also if it is tried out, it will smell very beerish(will smell of alcohol). Fresh yeast should have a yeasty smell and not a beery smell.
Storage: As far as storage is concerned, this is what I do. I buy about 250g of yeast(enough to make about 20-25 loaves of 400g bread; 300g flour and rest water) and store it in the deep freezer in an air-tight plastic wrap. Every few weeks, I remove about 1/5th the yeast and transfer it into an air-tight plastic box to store in the refrigerator. This is because frozen yeast does not crumble. Also before breaking off the yeast, I leave it in the refrigerator to thaw for at least 6 hours after removing it from the deep freezer.

Sunday, August 24, 2008

How to make chocolate from cocoa powder at home.

I always buy cooking chocolate from shops, and I have noticed that all of them have "hydrogenated vegetable oil" or their equivalents mentioned in the ingredient list. Now, I'm not a big fan of using products that contain fully/partially hydrogenated vegetable oils, so I've long been on the look out for chocolates that do not contain these ingredients. However, on searching, I haven't been able to find any with just a few basic ingredients. The ones that don't contain hydrogenated oils are too expensive because of the high cost of cocoa butter. Also, being in India, where the climate is generally about 33°C - 36°C, manufacturers use Hydrogenated Vegetable Oils to keep the chocolate from melting at room temperature(which is why "foreign" chocolates are generally deformed when we buy them in India).

I have been experimenting, and have found that the following procedure produces good quality bitter chocolate, which I enjoy eating.

Ingredients:

  • 1 unit Melted Unsalted Butter

  • 1 unit powdered/pulverised sugar(not Icing sugar), or to taste

  • 3 units good quality cocoa powder(I use Cadbury or Hershey's), or to taste



Procedure:

  1. Melt the Butter, and add all the sugar to it.

  2. Simmer the butter with the sugar for some time so that sugar is completely melted in the butter and some of the water has vaporised. Keep stirring with a thin wire whisk.

  3. Remove from the heat.

  4. Add the cocoa powder a little at a time(preferably in 4~5 batches), stirring all the time with a thin wire whisk, to ensure that no lumps form.

  5. Add as much cocoa powder as is required(to taste) or to adjust the consistency of the mixture to be like a thick syrup, which can be poured into molds when it is hot/warm.

  6. You may optionally add vanilla extract for extra flavor. Add only about 1/4tsp for every 100g of butter(or 500g chocolate) or to taste.

  7. Pour into molds and chill in a refrigerator for about 2 hrs. or till completely solidified.

  8. Eat directly or use as cooking chocolate or make a hot cup of hot chocolate. Enjoy!



Note: If you want to add more cocoa powder or you find that you are not getting a shiny pourable liquid, you may want to try adding an emulsifier such as "soya lecithin" or "egg yolk" in a proportionate amount, a little at a time, stirring constantly till you get a liquid with a smooth consistency.

Tuesday, July 22, 2008

Wheat Pav

This is the recipe for Pav made from half maida(all-purpose flour) and half aata(whole wheat flour).

Ingredients:

  • 140g Maida

  • 140g Aata

  • 10g fresh yeast(crumbled)

  • 15g granular sugar

  • 10g Pure Cow's Ghee

  • 1 tsp. table salt

  • 2 tsp. melted butter(preferably salted; Amul butter)

  • Some water



Procedure:

  1. Mix the maida and aata, and make a well.

  2. Put the yeast and granular sugar.

  3. Add a bit of water to just cover the yeast and sugar mixture. You should see some bubbles some time after adding water. This is the CO2 expelled by the yeast on eating the sugar in the presence of moisture(water in this case).

  4. Make a dough and keep adding water till the dough "just" starts sticking a little bit. The trick is to add just enough water so that (a) the dough is workable and (b) the water should be in good enough quantity so that the dough is not "dry". So the balance is reached when you realize that adding more water will make it sticky and very difficult to work with.

  5. Cream the Ghee and salt well.

  6. Knead this mixture into the dough. The dough will now stop sticking to your hand till all the fat is incorporated into the dough. Try to knead it as much as possible, because once the fat is incorporated, it will start sticking again. This will take approx. 7-8 mins. depending upon your speed. Try to work fast. There reason we add a sufficient quantity of water is because we want a soft dough and some protection against over-baking.

  7. Make a big smooth round and keep it on a slightly greased surface(grease with with ghee) to prevent sticking of the dough to the surface. Cover with a moist cloth and let it rise in a draft-free place till it approximately doubles in size. It will take about 25-35mins.

  8. Divide the dough into 9 equal parts(do NOT stretch the dough. Use a knife or dough scraper to cut) and make rounds. Use "very" little of dusting flour(aata or maida) if the dough sticks to your hand.

  9. Set your oven temperature to 210C and set it to pre-heat.

  10. Line the rounds in a 3x3 grid, cover with a moist cloth, and place them in a draft-free place to let them again double in size. Approx. 35-50 mins.

  11. Place the tray in the oven, and bake till you get a nice brown top on each "Pav". This will take about 8 mins. but keep a close eye. It may take +/- 2mins. depending on the temperature error in your oven and the size and aeration of the oven.

  12. You can(to be on the safer side) over-bake for about 1 min. by turning off the TOP header coil so that the buns get cooked well, and the browning of the tops is unaffected. (Remember we used sufficient water?)

  13. The buns are done when you hear a "hollow" sound when you tap them on the top. Don't worry if the tops feel really hard. They are supposed to be that way. Now quickly, using a brush, apply the melted butter evenly and uniformly on top of each of the buns. This will soften the tops and give them a nice shiny finish.

  14. Don't forget to remove them from the baking tray and keep them on a "wire-rack" to cool off or else the bottoms will get soggy from the condensed moisture!



Link to photos:
http://picasaweb.google.com/dhruvbird/WheatPav

Sunday, June 29, 2008

Palak Beetwala

This is a dish I made in a hurry using lost of ingredients that were just lying around, and would have caught fungus if I hadn't used them. So, the previous night I had boiled 2 beetroots and 1 potato and they were lying in the refrigerator. We had 1 bunch of fresh palak(spinach) too, so I decided to make something out of it. I've named it Palak Beetwala after it's main ingredients. Easy enough for anyone to figure out what it may contain....

Ingredients:

  • 1 bunch palak(spinach), thoroughly cleaned

  • 2 small beetroots, boiled, peeled and cut into small pieces

  • 1 medium potato, boiled, peeled and cut into small pieces

  • 1 tomato, cut into small pieces

  • 1 small/medium onion, finely chopped

  • 1/4 tsp Hing powder(asafoetida)

  • 1/2 tsp Jeera(cumin seeds)

  • 1 clove garlic, peeled and finely sliced

  • 1 tsp finely ground ginger

  • 1/2 tsp Haldi(turmeric powder)

  • 1 tbsp butter(salted/unsalted)

  • Salt to taste(about 1/2 tsp)



Procedure:

  1. Take the Palak and add water just so that all the palak is immersed when you press down a bit. Boil it till the palak feels tender. The trick to boiling palak is to cook it on a medium-high flame instead of a low flame. This will prevent the green colour of the palak from fading away. Also cover it while cooking with a lid to prevent excessive oxidation which will again result in fading of the green colour.

  2. Remove the palak from the water(Do NOT throw away the water. It will be used later in the recipe and is quite nutritious) and put it into a food processor(mixer in India). Also add the tomato and beet pieces to it. Run mixer for about a minute or till the mixture is semi-solid(not a completely thin paste).

  3. Take a skillet and melt the butter in it. Heat the butter till it sizzles.

  4. Add the hing powder and jeera.

  5. Add onions and saute till they become golden-brown in colour.

  6. Add the garlic and ginger paste and mix well.

  7. Add the palak paste and potato pieces. Keep stirring to cook well. Add some of the water in which the palak was boiled to adjust the consistency of the mixture to something more desirable.

  8. Add the haldi powder and salt and stir to mix well. Taste the mixture and adjust salt or other spices as per your taste.

  9. Boil on low flame for about 10min or until desired consistency is reached.

  10. Serves 3.



You can use the excess water that is drained off for other cooking purposes, to make bread, or as I do, add some dhania(corriander) powder, jeera powder, rock salt and table salt and drink up!

Serving suggestions: You can serve this dish with either chapati or as a soup with poached egg in the bowl. The runny egg yolk in the poached egg will enrich the taste of this dish.

Thursday, May 29, 2008

Masala Bhaji Parantha

Today, we'll see how to make Masala Bhaji Parantha. The name encodes everything that this dish contains:

  1. Masala: Any Masala. I used Pav Bhaji Masala.

  2. Bhaji: A mixture of vegetables. I used cabbage, cauliflower, potatoes and onions.

  3. Parantha: A covering of wheat flour knead into a dough, and flattened into a roti like shape.



Total Time: 1 hour 30 minutes
Serves: 8-9

Ingredients:

  • Pre-knead dough for making about 8 chapatis

  • 1 large potato

  • 1/4 cabbage, thinly sliced

  • 1 large onion, cut into fine pieces

  • 1/3 cauliflower

  • Salt

  • 2 tsp Pav Bhaji masala

  • 2 Pinch Asafoetida(Hing)

  • 1 tsp Ginger paste

  • 2 garlic cloves, cut into fine pieces

  • 1 1/2 Tbsp Butter(salted/unsalted)

  • 1/3 tsp Turmeric powder(Haldi)

  • 9 Tbsp Ghee or Vegetable oil(approx.)



Special equipment required:

  • A potato masher



Procedure:

  1. Make about 8-9 small balls from the pre-knead chapati dough. You may optionally colour and flavour it by adding haldi(or pudina[mint] paste) and salt -- to taste.

  2. Roll these into chapatis. Keep aside.


  3. Boil the potato and all the vegetables(except the onion). You may add some salt in the water so that the vegetables soften faster.

  4. Once boiled, drain out most of the water. We will need some(about 1/4 cup) to cook the vegetables.

  5. Peel the potato.

  6. Heat butter in a pan, and add Hing to it.

  7. Saute the onions till they are light golden in colour.

  8. Add the ginger paste and garlic pieces. Mix well for a few seconds.

  9. Add the vegetables, and add the pav bhaji masala, haldi and salt to taste.

  10. Cook for a few minutes till all the water has evaporated and the vegetables are dry. Keep stirring or the vegetables will get burnt.

  11. Now use the masher and mash all the vegetables in the mixture above.

  12. Let this mixture cool for a while under the fan. As the mixture cools, it will also thicken a bit. This will help us in used it as a filling for the paranthas.


  13. Now use this as a filling for the paranthas, and again roll them into slightly thick paranthas.

  14. To fry, heat a thick tawa(roti pan) till it is completely and evenly heated up. Spread a little bit of ghee on it evenly.

  15. Reduce the flame to medium-low.

  16. Now spread the parantha on it, and sprinkle the sides with ghee. This should be about 1/4 tsp.


  17. When it feels done, use around 1/4 tsp ghee to coat the top side.

  18. Over-turn the parantha and sprinkle this side too with 1/4 tsp ghee.


  19. Use the rest of the ghee to cover the now top-side with ghee./li>
  20. When it is done, over-turn once again, check for doneness on both sides, and serve.


Tuesday, May 27, 2008

Sondesh

I started out making Doodh Peds, but the milk curdled, so I converted it into Sondesh. This is a bit different from Malai Peda, because the milk hadn't halved in volume when it curdled, so it is actually very close to a Sondesh.





Serves: 9 pieces.

Ingredients:

  • 1 ltr High Fat(bhains ka doodh -- buffalo milk)

  • 1/2 lemon

  • 125g granulated sugar

  • 1 1/2 pinch kesar(saffron) strands

  • 20 g(approx.) ground pista and badam(it should be quite grainy)



Procedure:

  1. Warm the saffron strands a bit so that they crumble easily.

  2. Grind them into powder and add about 1 Tbsp of warm milk so that they dissolve completely. You should get a bright yellow coloured mixture.

  3. Take milk in a large saucepan and heat on high flame, stirring continuously till it is boiling hot.

  4. Remove seeds from lemon and squeeze juice over the milk to completely curdle it.

  5. Heat for a while till the milk separates completely.

  6. Strain out all the water with the help of a strainer, or as is more traditionally done, by putting the entire thing in a cloth towel, and squeezing the towel hard to remove all the water.

  7. Place the paneer in the saucepan.

  8. When it is still quite warm, break into small pieces, add sugar, kesar syrup and mix well.

  9. Form small roundlets about 1 1/2 inch in diameter, and male a small depression in the center(The pedas will be quite crumbly, so be careful while to pinch depressions in them).

  10. Put the ground badam and pista in these depressions, and press so that they stick.

  11. Refrigerate till cool, or serve warm and fresh.

Hitchhiker's Noodles

Today I'm going to detail the recipe for Hitchhiker's Noodles which is a dish I just came up with. I eat noodles when I'm out of town or have a crunch situation in which to make something edible, or am in a mood to experiment with vegetables but don't want to make chapatis.

These noodles are called Hitchhiker's Noodles because they are supposed to be for the Hitchhiker -- quick easy and cheap to make.

There are 4 main steps to making these noodles:

  1. Cook the noodles

  2. Cook the gravy

  3. Boil the the vegetables

  4. Mix the above, add sauce and garnish to serve



Let's discuss each one of them in detail:

  1. Cook the noodles: You may use any flavour noodles. I generally use Masala flavour Top Ramen or Maggi noodles.

  2. Cook the gravy: The gravy can be any gravy of your choice. I have used a tomato and egg based gravy, which is both tasty and healthy. Tomatoes and eggs are generally very widely and freely available(even on other planets!!!! ;-))

  3. Boil the vegetables: You may choose any combination of vegetables to add to the dish. I chose Cauliflower, Peas, and French Beans.

  4. Mix, sauce, garnish and serve: You need to properly mix up the individual constituents of the dish discussed above, and add sauce and mix again. Top off with your choice of garnish, and serve....



Now that we know the basic framework of the recipe, let's discuss the the recipe itself:

Cooking time: 42 minutes
Serves: 2

Ingredients:

  • 1 packet(80g) Top Ramen Masala flavour noodles

  • 1 1/2 Tbsp Butter(salted/unsalted)

  • 1 onion, finely chopped

  • 1 medium green capsicum, finely chopped

  • 2 tomatoes, coarsely chopped

  • 1 Tbsp Ginger paste

  • 1 large Garlic clove, finely chopped

  • 2 Pinch Asafoetida(Hing) powder

  • 1 egg

  • 1 Tbsp Pudina(Mint) paste

  • 50g Cauliflower

  • 40g Peas

  • 50g French Beans

  • Salt

  • 1 tsp Soya Sauce(or to taste)

  • 1 1/2 tbsp Tomato ketchup(or to taste)

  • Fistful Coriander leaves for garnish



Procedure:

  1. Cook the Noodles as indicated on the packet. Add the flavouring when half the water has evaporated and mix well. Let some water remain after cooking so that the noodles can soak up the flavoured water. This will enhance the noodles' flavour.

  2. Remove from the heat and let them stand.



  3. Break the egg, and beat it for a few seconds till the white and yellow are mixed up well. Set aside.

  4. In a separate pan, add all the chopped up vegetables and put water so that all the vegetables are completely immersed in water. Add a teaspoon of salt(for faster cooking), and set aside to boil on a medium flame.



  5. In a separate pan, put the Butter, and when it is frothing hot, add the Hing and saute the onions till they are golden in colour.

  6. Add the Ginger paste and garlic and mix it up well.

  7. Add the finely chopped capsicum pieces till they are coated with butter.

  8. Add the tomato pieces, and salt to taste and cover with a lid. Cook on a low flame till the water in the tomatoes starts leaving it.

  9. Remove lid, and stir while cooking till most of the water from the tomatoes has evaporated.

  10. Now add the egg to the pan with the tomatoes. Keep stirring till the eggs are cooked. You may increase the flame to medium so that the egg gets cooked well, and the proteins coagulate. You will find that the egg will form a gravy with the moisture in the tomatoes. If we had used more eggs, we would have gotten scrambled eggs or bhurjee.



  11. Add the mint paste, and mix well. Turn off the flame, and set aside.



  12. Check if the vegetables have been boiled al dente. Once done, drain out all the water(and along with it, lots of the nutrients of the vegetables) and add it to the noodles.



  13. Now add the gravy we made to the noodles, and mix them all up well. Check the mixture. Add more salt if required.



  14. Add soya sauce, and tomato ketchup and mix it up well.

  15. Garnish with coriander leaves and serve in style ;-)





Variations:

  1. You may also add ajwain along with the Hing in the vaghaar(tadkaa) for a more aromatic flavour

  2. You may add more vegetables like carrots, cabbage. However, avoid using vegetables like cucumber, zucchini, sweet gourd(galka) since they give off lots of water, which will be lost when you drain off the water.

  3. Typically, each vegetable needs different amounts of time to cook properly. Peas cook fastest, followed by cauliflower, followed by french beans. So, expect your peas to be slightly over-cooked, your cauliflower to be cooked just right, and the french beans to be slightly under-cooked. It is the way it should be since this is a poor man's recipe. If you have the time, go ahead and cook them all separately.



I hope you enjoy cooking and experimenting with this recipe, and I wish you all the best :-)

Sunday, May 25, 2008

Make like a shrink

I've come to believe that most people can be classified into 2 categories based on their concentration span. I assume that everyone in the Universal Set of people has something to offer to everyone around them, no matter how little it may be. So, the 2 broad categories based on concentration span would be:

1. Those who can concentrate on something for long periods of time.
2. Those who can concentrate on something only for a short period of time.

I have further noticed that generally, the product concentration(C) X concentration span(CS) is constant over a large set of people.

So, if C X CS is constant(K), then, it would imply that people falling into category [1] don't concentrate very hard on what they are doing, but do it for longer(marathon athletes), whereas those falling into category [2] concentrate really hard on short bursts(short distance sprinters).

I think these basic differences dictate as a person what job you are most suited for. For example, managers and overseers of tasks could fall into category [1] whereas inventors into category [2]. Say you are working on building a large system. You would need someone from [1] to look after the general progress and well-being of the system, whereas you would also need someone from [2] to provide the much needed pushes at vital stages of the project when it is stuck or in need of an idea.

I think that if people try to cross these barriers and try to choose careers that violate this basic underlying trait of theirs, then they would find it very difficult to adapt to their job, and would feel under-qualified as compared to their peers who are from the suitable category of candidates.

Ambrosial Candy -- a tale of East v/s West.

I've been learning to make sweets of both the western and eastern(Indian) types. Westers sweets include cakes, breads, pies, and different types of pastries, etc.... Indian sweets include mawa, ghee and sugar based sweets such as Mysore Pak, Gud Papdi, Mohanthaal, laddu, etc....

The primary difference(from the little exposure I've had to both) between these sweet making paradigms I've noticed are the following:




















































































Parameter Western Indian
Basic Ingredient Flour, sugar, eggs Sugar, Ghee. Indian sweets are broadly classified further into either milk based or flour based, in which case a variety of flours are used
Preparation time Moderate Low
Cooking time Moderate/Low High
Sensitivity to change in ingredient proportion Very High Low/Moderate
Sensitivity to change in cooking time Moderate/Low Very High
Number of Ingredients Generally around 10 Generally less than 5
Heating Method Using Oven Using Stove
Shelf life of product Depends upon the product Depends upon the product
Concentration required during preparation Moderate/Low Very High. You can not leave the working area while the dish is being made
Fat content Moderate/Low High/Very High
Principle technique Leavening High temperature roasting in liquid
Artificial Ingredients May contain in the form of Baking Soda, Baking Powder, Cream of Tartar, etc.... Should not contain. However, commercial sweet vendors generally use Hydorgenated Vegetable Oil(which is not good for health) instead of Pure Ghee these days

Sweets.... should we buy them?

I've been trying to work out the costing of producing one of my favourite(and first Indian sweet I learned to make) Indian sweets, the famous Mysore Pak. Shops sell it for as much as Rs. 140/- a kg. However, armed with the knowledge that 4.5 units of the sweet require 2 units of Ghee(clarified butter), 1 unit of besan, and 1.5 units of Sugar I decided to work things out for myself.

For 1 kg of Mysore Pak, you need:
450g Ghee
225g Besan
330g Sugar

The rates of the items are as follows:
Ghee: Rs 100 for 500g
Besan: Rs 25 for 500g
Sugar: Rs 20 for 1000g

That means 1kg of Mysore Pak will cost(for the ingredients alone):
Ghee: Rs. 90
Besan: Rs 11
Sugar: Rs 6

Total cost of ingredients: Rs. 107.
Lets take cost of production to be about Rs. 8 per kg(fuel, labour, transport, etc....)
So, the total cost per kg is now Rs. 115.
The profit per kg is just Rs. 25!!!! And this is not including the cost for renting the shop and electricity bills, etc....

Surely the shop keepers must be making more money. The food industry is known to have a profit margin of at least 100%. the only way they can do this is by cutting down on the cost of the most expensive ingredient -- Ghee. It is most commonly substituted in India by Dalda(Hydrogenated Vegetable Oil[HVO]). However, it should be known that Dalda has very detrimental effects on human and animal health. Just search for "Hydrogenated vegetable oil" and you'll get many hits on your favourite search engine.

To cut a long story short, Dalda contains Trans-Fatty acids, which are not easily absorbed by the body, and they are comparable to "plastics" in the body which stick around for long. These are the equivalent of foreign substances in the body and lead to many diseases. So, please think twice before buying sweets from an un-trusted shop.

Notes:

  1. Actual incident: I went to a sweet shop asking for unsalted butter(makkhan) and the shopkeeper said that they generally cream the milk and use the butter at home(I could see he wasn't lying from the size of his waist-line).

  2. Pune Cow's Ghee can cost anywhere from 180 to 200 per kg, while Dalda costs anywhere from 110 to 130 per kg. It is a saving of about 40% as compared to using Ghee. Who knows if the shopkeepers are further cutting costs by using inferior quality HVO?

  3. Interesting aside: Dalda Ghee costs less than Dalda brand cooking oil!!!! When in fact the Ghee is Hydrogenated Vegetable Oil. What do you think makes up that extra weight and cost of production of Ghee from the oil(palm oil)?
    http://en.wikipedia.org/wiki/Palm_oil#Health

Saving Electricity

With oil touching $135 a barrel, and rising electricity costs in major cities, I thought it would be good to figure out how to keep those bills down.

  1. Turn off the switch on your phone's charger, and don't just remove the phone from the charger.

  2. Use room temperature water for bathing, esp. in this weather.

  3. Electricity costs more with more units used, much like taxes.

  4. Watch your computer usage. Turn off your PC(esp monitors) when not in use. Don't use screen savers.
    http://michaelbluejay.com/electricity/computers.html
    http://www.answerbag.com/q_view/39698

  5. If you have a habbit of falling asleep while watching TV, use that "auto off timer" on your TV. Most TVs these days have it. Read the manual.

  6. (For India) Turn off your CAS box if you have one.

  7. Turn off the monitor when not in use.

  8. Use power-saving lamps(CFLs)
    http://en.wikipedia.org/wiki/Compact_fluorescent_lamp

  9. Use Electronic chokes instead of the traditional induction types. They save up to 40% electricity.

  10. Make sure that there is at least 6 inches separation between the refrigerator and the wall behind it. It helps the air circulate and hence the heat dissipation from the coils.

  11. Use an electronic fan regulator v/s the traditional rheostat type which converts some of it's energy to heat to perform the function of a resistor(hence the heating of the regulator when you run the fan on low speeds for too long).

  12. Last but not the least -- please turn off the lights, fans, etc.... when leaving the room.


My friend has a collection of environment-philic blogs/pages on the web that he has collected and placed here: http://geek-o-pedia.blogspot.com/search/label/Environment?max-results=100

Thursday, May 15, 2008

Mysore Pak

I'm sure if you've come here, it is in search of the perfect Mysore Pak Recipe. I myself had been hunting for it for a while, and it took me as much as 6 attempts to finally get one that I liked eating. The recipe mentioned here will result in a firm Mysore Pak, that is crumbly enough to melt in your mouth, and whose cross-section shows 3 distinct layers, with the 2 outer layers being golden-yellow, and the middle one being light-brown. There are many parameters that affect the way the Mysore Pak will turn up. Mysore Pak is made using Gram Flour(besan), sugar syrup, and ghee(clarified butter). Varying the proportions of these ingredients will affect the "quality"(by quality I mean taste and texture) of the produced result. Let's discuss them in detail.

  1. Amount of Gram flour: We shall assume this to be kept constant and all other ingredients are chosen relative to this one ingredient.

  2. Amount of Sugar: This is typically taken to be anywhere between 1 to 2 times the amount of Besan used. More sugar will result in a softer final product. I personally take sugar to be about 1.4 times the amount of Besan used.

  3. Amount of Ghee: This mainly dictates the fattiness of the sweet. The more ghee you have, the smoother the texture, the more well cooked it will be and the more fatty your final produce will be. The ratio varies anywhere between 1 to 3 times the amount of Besan used. I personally try to restrict it to about 1.5 times the amount of Besan. However, I generally let the recipe dictate how much ghee to add. More on this below. You will also need(extra) 1 Tbsp Ghee per cup of Besan.

  4. Amount of Water in the sugar: Water should be about 1/4th of the amount of sugar used, or just enough to wet the sugar so that it can be heated uniformly.

So, my ratio would look something like this:


BesanSugarGheeWater
11.41.50.35

You may optionally add about 1/2 Tbsp of ground cardamom powder per cup of Besan to the mysore pak for that extra flavour and aroma.

You will need 2 medium sized pans, one large pan for cooking, one large steel plate and one sieve for sieving.

  1. Take the Ghee and heat it on a low flame till it is really hot.

  2. Drop about 1 tbsp of this hot Ghee on the besan and mix it well. Roast the Besan and Ghee mixture on a low flame till it starts giving off an aroma.

  3. Now sieve this mixture so that there are no or very few lumps.

  4. Take the sugar and the water mixture and heat it on a medium-low flame till it forms a single thread consistency. This can be checked by periodically taking this(very hot) sugar syrup) and pressing it between your index finger and thumb, and trying to separate them slowly. If the syrup at room-temperature(or slightly warmer) forms one single thread, then it is the right consistency. The sugar syrup will be bubbling. It is these air bubbles that the besan will trap and help create the holes in the final product. More viscous mixtures will result in a more crumbly Mysore Pak, and less viscous mixtures won't form as good a texture.

  5. Now add the sieved Besan to the sugar syrup, and stir till it is completely mixed and there are no lumps. This shouldn't take too long. Less than a minute.

  6. Add the cardamom to the mixture now if you are using it, because you won't have time later!!!!

  7. Now, add the very hot Ghee, about 1-2 tbsp at a time to the Besan and sugar mixture, and keep stirring. As the hot ghee falls on this mixture, it cooks the besan because of it's very high temperature, and will form a frothy mass. This is normal.

  8. Keep stirring continuously, and adding ghee every 20 sec, till the mixture lets go of the pan, and stops absorbing more ghee. This is generally when I stop adding ghee. (I start off with a little more ghee than I think I would need, and save the rest for later.)

  9. Do NOT let your concentration waver, since this is a very critical period in the preparation of Mysore Pak. Any lapse of concentration now will spell certain doom.

  10. You need to keep stirring till you see a distinct change in texture and colour of the Besan. The Besan will darken slightly(it will just start changing colour) and will form a thready molten-rock like mass. When this happens, quickly remove the Mysore Pak, and place it into a tray to cool. If you remove the Mysore Pak from the heat too early, then it won't solidify and will form a burfi, and if you heat it for too long, it will over-cook, and lose it's texture and will fail to solidify into a sturdy mass. Instead it will become a gooey mass, which will not solidify.

  11. (coming back)It will solidify in a few seconds, but will internally continue cooking for about 10 min, or until cooled sufficiently. You will know it is done if you don't hear a spurting/bubbling sound when you put your ear over the Mysore Pak. When you remove the Mysore Pak to cool, it is actually cooking inside because of all the heat trapped in the ghee. It is because of this latent cooking that the Mysore Pak is able to get a light brown center.

  12. Cut it into pieces and enjoy :-)



I hope you enjoy making this mouth-watering sweet, and I hope it turns out well. Mysore Pak is a very delicate dish to prepare, and requires precise timing of operations. Remember to not lose your concentration, and always start off with a patient mind :-)

In case you are wondering how I know what happens when you over/under-do something -- well, I've tried it out!!!! And wasted so much of my ingredients doing so.... In case your Mysore Pak has formed a burfi(won't solidity but has a smooth texture), all is not lost. You can still re-heat it (on a medium-low) flame, and keep stirring till you see forthing, and a molten-rock like texture of the mass. Turn off the heat, and let it solidify.

Note:
  1. The ghee has a higher boiling point than water, and hence is hotter than the sugar mixture(which at single-thread consistency is about 105C). Hence, it is able to cook the Besan better than the sugar mixture. If you use cool/room temperature ghee, you will have to wait for the mixture to become hot, and all the heat will be absorbed by the ghee instead of the Besan, and the Besan will be left under-cooked.

  2. Some people suggest using a 50% - 50% mixture of Vegetable Oil and Ghee instead of pure Ghee. DO NOT do that under any circumstances. I tried it, and it leaves quite a horrible after-taste of oil in your mouth. To bring out the real taste of Mysore Pak, use ONLY 100% Pune Cow's Ghee. Cow's Ghee is slightly yellow in colour, and I've had success with a brand called Dynamix. or make your own [1] [2] from Pure Butter.

  3. If you skip the roasting step, the Besan may not give off the proper taste.

  4. If the Ghee is not piping hot, the Besan will not get froth every time you pour the Ghee over it. This is Okay. However, it will take a while too cook the Mysore Pak, and you need to know how much Ghee to add in advance. The recipe will no longer dictate the amount of Ghee to be used. You will need to patiently cook the mixture on a medium flame. DO NOT use a high flame or you will burn the Mysore Pak, since Besan cooks very easily.

  5. Try to use a thick(18 gauge) stainless steel vessel in which to cook the Mysore Pak, since it will ensure equitable heat distribution and will not react with the mixture's contents. Using a larger pan(kadhai) will help, since it will help air the mixture.

Wednesday, March 05, 2008

Once bitten, twice backed.

Have you ever seriously thought about backing up your data? If not, chances are that you haven't been the victim of a system/hardware/disk failure. Most of the people who seriously think backing up their data and maintaining snapshots is an important part of their routine are the ones who have spent countless hours of their time trying to recover/rebuild their lost data after a system crash. Why does it require someone to suffer before they start becoming cautious with their precious data? Maybe the reason for it is; to quote from Shakespeare's The Merchant of Venice: "For sufferance is the badge of all our tribe".

Whatever, it may be, I would like to say that it's important to always back up your important data and protect it against system failure(s). In fact, I have set up an RAID-1(mirrored) array at home where I store my important data and my home directory. This way, even if one of my Hard Disks were to crash, I'd have the data safely backed up on the other one in the mirrored array. However, this solution does not prevent against:
  1. Accidental file deletion,

  2. Accidental Disk formatting.

  3. File System corruption.


To prevent against such problems, I'd want to have a separate backup(or preferably snapshotting) utility which saves versions of files as you save them. Ideally, the solution would be to introduce a surrogate file system such as a one written using the fuse file system, and have that file system save versions of the files as you save them. So, changes between an open() and close() on a file should be logged and saved as a file version. This way, the user will be able to recover files by how old it is and also get a fairly fine granularity control over the changes that happened. An optimization that could be done is to store only the changes to a file if only edits were made to it, whereas save a complete copy if the file size was changed.

I'm looking for more ideas and people interested in helping me develop such a solution, so if anyone is interested in helping out, please let me know and we'll try to work something out.

Hacking after a very long time!!!!

After very many months did I finally get down to doing some actual hacking on a program that I wanted to fool into thinking it something else. Please note that I'm use the word work hacking in the true sense of the word, and not to illegally gain access to a system. Please read this page to get a low-down on that controversy.

Anyways, so there was this utility very similar to the UNIX cat utility that read in a file, and wrote it to some other location. However, this utility also performs a check to determine if:
  1. There is sufficient space on the destination disk.

  2. The destination file is on a special file system

Only if both the conditions are met does the utility go ahead with the task of creating the destination file. A special feature of this utility is that it will create sparse files if the source file contains many holes in it. So, it is not strictly required that the destination file system contain as much space as the source file size. Also, the second check is made to make sure that the destination file system supports sparse files. However, if we know that there is another file system which supports sparse files, we can do away with that check as well.

All said and done, I did not have the source code to the utility that I am talking about, so I decided to do something else. I used the LD_PRELOAD environment variable available on all Linux machines to load in a custom compiled shared object file which overrides system calls such as statfs(), statvfs() and ioctl() that are the typical calls used to get this sort of information from the underlying OS, and viola! there it was. My hooks worked, and I was able to see what was being returned for each request. The only thing I had to do was fool the program into thinking it was getting the information it needed to go ahead with the file conversion. That again was just a matter of inspecting and inserting the correct values for each over-ridden system call. the whole process took about 4hrs, but it was time well spent. It felt good to get back to doing this sort of hacking-programming after a while....

Friday, February 29, 2008

A bug-fix.

I was writing a small php script to recursively delete all files and directories in a particular location that are more than a few hours old. I thought it wouldn't take more than 30min to do the whole thing. Additionally, I thought I'd use the Standard PHP Library(SPL) and the RecursiveDirectoryIterator class provided with it to implement directory scanning instead of the normal opendir(), readdir(), closedir() approach.

After writing the script, I tested it by making it spit out stuff saying Deleting file.... instead of actually making it delete any files/directories. The logic te script was used was that it checked the file/directory ctime which is the Inode Change time(not the file creation time as I earlier thought). Everything seemed to be working just fine when I uncommented the unlink() and rmdir() functions to test the real thing. Now, the script started saying different things, and wasn't even considering some directories for deletion. I was very surprised at this behaviour. I initially thought it was something to do with open directory handles or something, so went back to using the opendir(), readdir(), closedir() approach. However, even that approach yielded the same results. It's desperate times like these when you lose reason, and start to tinker with things which you know are not at fault in the hope of fixing the error. I inserted lots of debug output to be able to pin-point the error, but php kept saying that rmdir( was trying to delete a non-empty directory.

I'll give the directory structure below:

.
`-- aaa
`-- zzz
`-- hello.txt

2 directories, 1 file


The output indicated that the file hello.txt was being deleted, but the directory zzz wasn't even being considered for deletion. Further, the script was trying to delete the non-empty directory aaa. I couldn't understand why this was happening. It was after some more brainstorming that I realized that the operation unlink() on the file hello.txt was changing the ctime for the directory zzz which meant that the directory zzz was no longer being considered for deletion. However, the ctime for aaa was staying unchanged. This was happening because I was calling filectime() while scanning the directory instead of pre-computing all the ctimes for all the files.

So, I now decided to use the scandir() function to get the directory contents at one go, and get their ctimes before doing any further processing on that directory such as recursive scanning or deletion of files/directories within that directory. This fixed the error, and the script now started exhibiting the expected behaviour. Even though this may look silly, there were many things I learnt from it; the most important being to make sure I know the side-effects of any action that I may perform.

Sunday, November 25, 2007

Slave for life

Why do we need to pledge loyalty to some company? Yeah.... the usual answer is cause you want them to be faithful to you in return. But these days, the concept of staying with one company is alien to most. In fact, this attitude has percolated down to objects of daily use such as refrigerators, computers, telephones, and even relationships. People only so much of something. They feel overwhelmed if they get too much of anything. Speaking about jobs though, if you ask someone firms he/she has been in in the last 5 years, and if the answer is anything less than 2, then more often than not, the other person is saying to [him/her]self "what a loser"....

What is happening here people? There used to be a time in yesteryear India when people were happy to get just about any job as long as they took some money home at the end of the month. But things have changed a lot in the last few years. Jobs are much easier to come by because of the free economy, and spread of education. People are more educated; or lets just say they know more these days than they did a few years ago at their age. This argument is true of pretty much every successive generation though. Lets not confuse education with knowledge for some time now. There is a greater demand for knowledgeable people, and jobs for such kind of people in India at least, which is now driving the job market. You see industrial expansion all around these days. IPOs coming out pretty much every month these days is indicative of the industrial revolution happening here.

But the big questions I have is "Why should I be loyal to a company for a very long time, and thus enslave myself?" The answer may not be very simple; in fact, I don't know it myself, but at this point in time, I know that I don't need to be loyal to any company. If you look at people who are loyal, and are looking to grow in the company in which they are are doing it either because of the money, or the work, or the reputation of the company or the position they will attain in the next few years, or for come amount of satisfaction and job security, or because of peer pressure, or a certain combination of all of the above. Of course, there are many more reasons that I haven't mentioned or even thought of. However, may a times, these people are kind of under productive in nature. They seem to have settled into thinking that they can not be displaced from where they are now. If there's anywhere they are going, it's up the promotion ladder. In return, the company does them favours by giving them incentives, promoting them, and sending them on foreign trips, etc.... But, is the company acting in it's own benefit? I mean consider there is this under productive person (A), and a significantly more productive person (B). A is loyal to the company, and everyone knows it, but B is a carefree kind of person who doesn't care too much for anything/anyone. The company decides to send A to the client as their front, knowing well that they could have done better by sending B, but they don't cause they know that there is a greater chance of A staying with the company for longer than B. So, if they send B now, then they might temporarily get a good response from the client, but B will leave in a while, and A will be disgruntled because he/she wasn't sent, and will become even more under productive than before, and might even leave. However, if they send A, then A will probably grow up to the responsibility, and even though he/she might not create a great first impression, he/she will possibly stay back with the company, and will grow with the company providing it with a stable and possibly reliable front. I don't know if I agree with the philosophy. I don't even know if I disagree with it. In an age where employee retainment has become a buzz word, and companies pride themselves on their employee retention rate(which is inversely proportional to their attrition rate) this makes perfect sense. But is that a measure worth looking at with great amount of seriousness? Thinking about it from a rational perspective, it makes sense, since the attrition rates speaks a lot about the company. If people are leaving, it is generally true that their expectations haven't been met one way or the other. But is compromising company reputation for employee retainment justified at any cost?

Saturday, November 24, 2007

The one that got left behind

What comes to your mind when you read the title above? Make a quick list of a few things that do. It could be:
1. The ugly duckling
2. Some taste left behind in your mouth after having something utterly distasteful/pleasing
3. Some food speck left behind between your teeth
4. A good/bad memory, though more often than not, it's the latter that stays
5. The tune of some song that you just can't get out of your head
6. Some task on your list that you forgot to do

But, I ain't gonna to be talking about any of the above. What I'm going to focus my attention on today is on that last bit of poop left behind after you flush. No matter how hard your try, how many tumblers of water you put in, however fast, it just won't go down! It's like one of those resilient warriors; kind of reminds me of cockroaches. Every time you try a different angle to put the water in, and look in to see if you've managed to get rid of it, it just bobs up right back in your face. It's like as if it's there to stay. So, you try again, and again, and again, and before you know it, your bucket of water is over, and there's none left for you to wash your hiney!!!! You think "Now is a really bad time for me to run out of water". Reminds me of a few problems I've faced in my little life so far. They've mostly been self-created like this one, but more often than not, they just go away with time, or I find a solution if I think about it with a clear head; but not this one. No matter how much time you give it, it just stays there - probably soaking up more water, or doing whatever it does best. You know that the only way you are going to get rid of it is to flush again, or heave another full bucket of water in it, but you don't have the patience to wait till the flush tank is full again, and at the same time, don't want to waste another bucket of water, now that you've already used up one already. You start thinking and staring at that mass of excreta in a very contemplative way; but to no avail. Exasperated, you move on to let the next person clean up your shit.... Well, that's life....

Monday, October 22, 2007

The geek in you.

After reading the previous post(Of wed-locks and love-handles), a friend of mine pointed out a spelling mistake that I had made. However, when I went back and re-read the title, something very interesting struck me. If you notice carefully, the words locks and handles are technical terms used quite frequently in computer engineering ;-)

Sunday, October 21, 2007

Of wed-locks and love-handles.

I've been observing, examining, thinking, and concluding for quite a while now, and I've also discussed this theory with quite a few friends by now. However, many of them don't quite agree with it entirely or in part. I personally don't blame them for it. After all, it's just a theory and I haven't even bothered to take a sample space and conduct a proper examination. But you all must be wondering what it is that I'm theorising. Well, the thing that I've noticed is that people (both guys and gals) generally(not always) get plumper after marriage. So, I was just trying to think of reasons as to why this must be happening. This is true of most of the societies that I've been exposed to, so it made me think that is isn't a localised effect, but is more widespread. So, just before posting this, I did a quick google search for fat after marriage and was surprised with what turned up. Apparently, quite a few people before me had noticed it and also written about their findings. However, I decided to get done with my conclusions before reading theirs to avoid corrupting mine with theirs.
The explanation is actually quite simple, and the prelude might actually be longer than the actually reasons I want to present, but then again, every concise idea is also a very crisp one, and presents very few places it can go wrong in. According to me, people get fat after marriage because they no longer feel the need to attract people of the opposite sex, and hence begin neglecting their bodies, and indirectly their health. They feel that their job is over and they don't need to be at their best any more since their prey has been captivated. I on the other hand have very varied views. I feel that if you think that you don't need to look your best now, then it's because you either don't don't love yourself enough or you don't love your partner enough, because of which you don't want to put in the extra effort, and look your best for yourself and/or for someone who cares for you. This as far as I'm concerned is the primary reason for fatness after marriage. There may be others, which are mentioned in the pages given here(yes, I read them just before writing this line). However, after reading them, it may be the case that these reasons are equally important and it may be unjust to say that they aren't the main reasons.

  1. http://ezinearticles.com/?Why-Women-Gain-Weight-After-Marriage?&id=170650

  2. http://findarticles.com/p/articles/mi_m0NAH/is_3_33/ai_104836629

  3. http://forums.plentyoffish.com/datingPosts4342202.aspx

  4. http://answers.yahoo.com/question/index?qid=20070702022119AACDXLR

  5. And something on the lighter side. http://www.usaone.net/jokenet/jokes.asp?command=list&r=102


So as you can see my dear friends, I haven't been mistaken in thinking the way I did, and there are others who feel the same too.... An interesting side effect of this exercise is that it will make me use the web search features more often to try and validate my theories, or at least try and figure out if someone out there has already thought of and documented them online.
Ciao, and please keep in shape!!!!

A bumpy bus ride

A friend and I were returning to Mumbai from Pune on the MSRTC Volvo bus, and here is something that I wrote while on the bus.

We were sitting over the malfunctioning suspenders of a bus travelling at a relatively high speed(about 90km/hr) on a road littered with irregularities. The intermittent halt at the toll naka was a very welcome one. My hand writing did improve while we were stationary, but went back to its illegible self once the bus re-commenced its jerky ride back to Mumbai.

Sunday, September 23, 2007

An HTTP server with diff capabilities.

These days, there is a surge in the traffic content on the internet. Many sites are serving dynamic content to their users. However, the static content doesn't seem to have lost popularity. Many sites still serve a lot of their pages more or less statically. Furthermore, these static pages don't change very often even though clients are always re-requesting these pages, and asking them to be refreshed. An example would be google's home page. That apart, site administrators always want clients to not cache the page content, because they want clients to see the latest version of any static content that may have changed since the last time they visited. This makes them advertise HTTP headers which forbid the caching of web-pages by browser and proxy caches.

If you notice carefully, even if use wisely, the If-modified-since header involves sending the entire page back in case it was modified. What I'm suggesting here is to use a diff based scheme, wherein the client sends a request to the server indicating a previous page version that it already possesses, along with a flag indicating that it is willing to accept a diff to the current version of the page. The server will now(optionally) send back a patch to the client which it applies to the page that it already possesses. This sending of the patch is optional since the server may not have cached the page to which the client is referring, so that generation of the patch may not be possible at the server end. In this case, the server will send back the whole page as it would in the current scenario.

What this scheme will effectively do is reduce bandwidth consumption dramatically in places where a central proxy is being used to serve many users, and those users seem to be accessing the same static content repeatedly. If the content changes by a bit, or doesn't change at all, this scheme will result in a definite reduction in bandwidth consumption on the internet. However, the trade off here would be CPU time to network bandwidth, since the diff generation and application of the generated patch are both CPU intensive activities as compared to normally sending the whole page.

Bumping up the bandwidth usage.

Have you ever wondered how you can (without too much of effort) use a lot of bandwidth on your local LAN? Well, if you have a central proxy server(gateway machine) through which you connect to the internet or to other computers, then you could do this quite easily.

First of all, configure your browser to use the proxy server installed. Then change the settings so that the browser uses the proxy server even for localhost(your local machine). The browser defaults general bypass the proxy for localhost. On your machine, on port 80, configure a proxy server(squid) to use the proxy server on the gateway machine for making connections.

Now, type your machine's IP address on your browser's address bar, and hit enter, and watch while the packets keep bouncing to and fro the gateway machine and your machine. This happens because your browser will contact the proxy server for the request, which in turn will contact your machine, which will again contact the proxy at the gateway, and so on....

Residents of buildings without elevators live healthier, longer.

According to a recent survey conducted by research scientists at the Montgomery university at Timbaktoo, it has been observed that the average age of people living in buildings without elevators is greater than of those living in buildings with one. Scientists observed a group of people living in the northern part of Timbaktoo city where the buildings are old, do not have elevators and people have a generally lower standard of living as compared to those living in the south, where sky-scrapers abound, and the standard of living is considerably higher. It was expected that the richer would live longer, since they eat healthier food, and can afford costlier medication. The results however were not in accordance with that theory.

As it turns out, the poorer people, with their low standard of living, and simple eating outlive the rich by an average age of 6~7 years. The northers sample space had an average life expectancy of 89 years whereas the southern sample space recorded a mere 82 years. It is believed that this singular occurrence if because of the fact that people living in the poorer parts of the city do not have elevators in their buildings and are forced too use the stairs, which is considered to be a good exercise for the heart and kidneys. Researchers have yet to conclusively nail this as one of the main reasons as to why people in the north live longer.

Monday, September 17, 2007

Ampache

I was thinking about setting up a server for streaming music of their choice to users on the LAN, and also for writing software for such a purpose. However, I happened to chance upon this great software called Ampache that does just that and more. Have a look.... It might interest you. However, I feel that this software lacks certain statistics like showing you relations in songs such as those songs which are liked by people who like songs that you also like, but you haven't yet listened to. Otherwise, I feel this software is really well made, and promises to become much more.