Wednesday, August 11, 2010

My Dum Biryani

I decided to make the vegetable biryani because I was catering to at-least one vegetarian. So here goes...

सामग्री (serves 8 )

3 cups basmati rice
3 medium sized potatoes
3 large carrots
half a cauliflower
2 large onions
1.5 cups yoghurt (dahi)
3 tbsp vegetable oil
2 tbsp whole garam masala (corriander seeds, cumin seeds, cinnamon, black cardamom, cloves...you know, the whole shebang)
1 tsp haldi powder
1 tsp red chilli powder
2 tbsp pulav/biryani masala (store bought...or if you are adventurous, you can make your own)
half cup finely chopped cilantro (hara dhania)
half cup finely chopped mint leaves (hara pudina)
salt to taste

विधि

  • First of all, soak the basmati rice in warm water for at-least one hour in advance. Finely slice the onions and fry them in adequate quantity of oil till they acquire a dark brown color. Keep it aside. In the meantime, chop all the vegetables into bite size pieces. (make them larger than usual i.e. if you are cooking a sabzi)




  • In a large pan or kadhai, add some oil. When the oil gets hot, add the whole garam masala and saute for a couple of seconds. Add some jeera, and ginger garlic paste. Now add the chopped vegetables.  Add the red chilli powder, haldi powder, biryani masala and salt to taste. Saute for 5 minutes. Keep stirring occasionally. Add half the quantity of yoghurt, and half the quantity of the chopped mint and cilantro. Make sure that all the pieces of vegetables are coated nicely. We need to cook these vegetables to about 70-80%. Try to cut into a piece of potato. It should not be too hard, and at the same time, don't allow them to cook all the way.




  • In another pan, bring a quart of water to a rolling boil. Add some oil, and some whole garam masala to the water. Add the pre-soaked rice to the water. We need to cook this rice to about 70-80%. This will take only about 3-4 minutes in the boiling water since the rice has been soaked for an hour (keep checking the rice). Drain the excess water and keep the rice aside.

  • Now comes the part where we layer the vegetables and the rice in a medium sized container (I found the pressure cooker container to be ideal size for this). Add half the rice to the cooker. Add a little more than half of the cooked vegetables on top of the rice. Add the rest of the yoghurt on top. Heat this up a little on low flame while mixing it up nicely. Check for seasoning and add more salt if needed. Add a layer of the fried onions.




  • Now add all but a little of the remaining rice on top of the onions. Stack the remaining cooked vegetables on top of the rice, and add the rest of the chopped onions.  Finally top with the last bit of the rice. Garnish with the remaining chopped mint and cilantro




  • Cover the cooker with a flat plate, and seal the edges with a bit of dough. Place this vessel into a double boiler as shown in the image below. Cook on medium flame for 30 minutes.




  • Open the cooker after 30 minutes to a beautiful aroma.




  • Serve with boondi raita (recipe for that in another post).


Monday, August 09, 2010

Some Like it Cold

Vichyssoise soup is a thick vegetable based soup that is very often served cold.  There is some debate about whether this soup is a French or an American creation. This soup can be served both  hot and cold, but I wanted to cook it because I had never tried a cold soup before. The following is the recipe:




सामग्री (serves 5)


1 leek


1 bunch scallions


1 large zuccini


1 red potato


1/4 head cabbage


1/4 tsp ground nutmeg


2 tsp sugar


salt to taste


1/2 cup whole milk (I used this instead of heavy cream)


2 and a half cups water (or chicken broth)


1/2 stick butter


1 tbsp cooking oil (use your favourite)



विधि


Roughly chop all the vegetables and keep aside. In a large saucepan, add the butter, oil and ground nutmeg. Let the butter melt. Add all the chopped vegetables, salt and sugar and stir till the vegetables start to cook. Add the milk and water and bring to boil. Reduce the flame to medium and simmer covered for 20 minutes.




Remove the pan from the flame. Use a hand-blender to blend the contents of the pan to form a think soup like consistency. If you don't have a hand blender, use a tabletop blender or food processor. Fill only up to 1/3 the capacity of the blender at a time. Refrigerate the soup for at-least four hours.






Before serving, check seasoning, and stir in some heavy cream if you like (or not, if you are afraid of the calorie mafia. you can also substitute heavy cream by whole milk). Garnish with freshly chopped parsley. Serve with toasted baguette.



Wednesday, August 04, 2010

Blank Un-numbered pages in a latex manuscript

I recently submitted my MS thesis to the university graduate school. After a couple of days, I got an email from them saying:

Your manuscript requires three blank, unnumbered pages: one at the beginning of your manuscript, the second one after the copyright page and the third one at the end of your manuscript.


Now, since my thesis was formatted using latex, it took a little bit of searching. The solution was quite simple, but not so easy to find. Thanks Night Walker.

\newpage
\thispagestyle{empty}
\mbox{}

Add the above block of code to your main document and you will be good to go. Essentially this creates a new page with an empty style, and adds an mbox with empty text.

Monday, July 19, 2010

Sarah Dunant: The Birth of Venus



This book is the coming of age story of a girl in 15th century Florence, (and in many ways is also the coming of age story of the city itself). Alessandra grows up in Florence and witnesses the historical events that unfold in the city, like the death of Lorenzo de Medici, the iron fist of Girolamo Savonarola, and later, his downfall, the threat of the French invasion, and a terrible plague. There is also a serial killer on the lose who some readers believe, turned out to be a famous painter.

Alessandra is a young girl full of life, who is constrained by the mores of the society around her, as she struggles to find her freedom. Alessandra's story is the central plot of the novel, although several fates of the women of that period are represented through various female characters in the story. Dunant has very cleverly blended fact with fiction to produce a masterful tale full of the colors and textures of Florence. She adds a very artistic touch by describing episodes from the lives of contemporary painters and even dropping intriguing hints about their involvement in the story.

Monday, July 12, 2010

Cooking with beer

Yes, that is right. Beer can be, and is used in a lot of dishes. If you think that is strange, read this. Apart from what you will read on that page, let me tell you that beer adds a very distinct flavor to your food that is unlike anything you might have tasted before.

We will call this particular recipe squash and tofu in thai(?) peanut sauce and serve it on top of egg noodles.

Ingredients (serves 2)

  1. 2 nests egg noodles

  2. 4 medium sized yellow squash

  3. 1 cup diced tofu (preferably tofu patties that you get in the Asian store)

  4. 2/3 cup bitter-ish lager

  5. 5-6 cloves garlic

  6. 1 large onion

  7. 1/2 cup peanut butter

  8. 1 can coconut milk

  9. 1 tsp fish sauce

  10. 1/2 tsp chili garlic paste

  11. 1 and half tsp curry powder

  12. 1 lemon

  13. salt to taste



  • One thing I learned about cooking tofu is that you must marinate tofu in advance if you want it to soak all the flavors. Mix 1/3 cup beer (we used bitterish lager) with the juice of 1 lemon, crushed garlic from about 3-4 cloves, 1 tbsp sugar and 1 tsp of curry powder (important ingredient!). Marinate diced yellow squash and diced tofu in this mixture for 2 hours or more in the refrigerator. Preserve this marinate for later use. Do not discard.


Photobucket

  • In a pan, add finely chopped onions, and saute till they are translucent. Add crushed garlic from 1-2 cloves and saute for a minute. Add 1/2 tsp of curry powder and saute for a couple of more minutes.


Photobucket

  • In a large bowl, mix a can of coconut milk, 1 tbsp sugar, 1 tbsp lemon juice, 1/3 cup beer, 1/2 cup peanut butter, and 1 tsp fish sauce (you can find this at your nearby Asian store. substitute by soy sauce if you can't find it). Add the leftover marinate.


Photobucket

  • Add this mixture to the pan with onions. Add salt to taste, and 1/2 tsp chili garlic paste. Add the marinated tofu and squash. Cook till the gravy attains the desired consistency. Serve on top of egg noodles.


Photobucket

Cooking with beer

Yes, that is right. Beer can be, and is used in a lot of dishes. If you think that is strange, read this. Apart from what you will read on that page, let me tell you that beer adds a very distinct flavor to your food that is unlike anything you might have tasted before.

We will call this particular recipe squash and tofu in thai(?) peanut sauce and serve it on top of egg noodles.

Ingredients (serves 2)

  1. 2 nests egg noodles

  2. 4 medium sized yellow squash

  3. 1 cup diced tofu (preferably tofu patties that you get in the Asian store)

  4. 2/3 cup bitter-ish lager

  5. 5-6 cloves garlic

  6. 1 large onion

  7. 1/2 cup peanut butter

  8. 1 can coconut milk

  9. 1 tsp fish sauce

  10. 1/2 tsp chili garlic paste

  11. 1 and half tsp curry powder

  12. 1 lemon

  13. salt to taste



  • One thing I learned about cooking tofu is that you must marinate tofu in advance if you want it to soak all the flavors. Mix 1/3 cup beer (we used bitterish lager) with the juice of 1 lemon, crushed garlic from about 3-4 cloves, 1 tbsp sugar and 1 tsp of curry powder (important ingredient!). Marinate diced yellow squash and diced tofu in this mixture for 2 hours or more in the refrigerator. Preserve this marinate for later use. Do not discard.


Photobucket

  • In a pan, add finely chopped onions, and saute till they are translucent. Add crushed garlic from 1-2 cloves and saute for a minute. Add 1/2 tsp of curry powder and saute for a couple of more minutes.


Photobucket

  • In a large bowl, mix a can of coconut milk, 1 tbsp sugar, 1 tbsp lemon juice, 1/3 cup beer, 1/2 cup peanut butter, and 1 tsp fish sauce (you can find this at your nearby Asian store. substitute by soy sauce if you can't find it). Add the leftover marinate.


Photobucket

  • Add this mixture to the pan with onions. Add salt to taste, and 1/2 tsp chili garlic paste. Cook till the gravy attains the desired consistency. Serve on top of egg noodles.


Photobucket

Sunday, July 11, 2010

Updated to wordpress 3.0

I have been wanting to update my blogging software from its original archaic version that I installed over a year ago. Yesterday I finally decided that I cannot wait any longer because the old version of the wordpress software was not letting me link images from external hosting services like picasa. So I bit the bullet and did the whole updating process. I did the manual update because my ancient version did not even support the automatic update.

So I took a backup of the database, a manual backup of the entire blog directory using ftp, and just followed the instructions. True to the word, it updated the web-app and the MySQL database in a matter of seconds. I really like this new interface, but I am still looking for desktop publishing applications that can simplify the blog post process easier for me because I hate to have to muck with the HTML code myself. So, I am going to experiment with a couple of publishing applications for a while.

Friday, July 09, 2010

Poaching an egg



Do you remember this scene from Julie and Julia? After watching it, I felt that poaching an egg requires some kind of black magic, and that it is extremely difficult for you to poach an egg without an egg poacher. I checked out a book by Jamie Oliver, and his advice was similar to that of Julia Child (as in the video). A google search gives you a tonne of conflicting advise. Finally, I found a way that has always worked for me:

  • Take lots of water in a saucepan and bring it to a light boil. Add a teaspoon of salt, and a teaspoon of the secret ingredient: vinegar. Vinegar helps the egg white to cook as soon as the egg is dropped into the water. This is what helps you avoid the disastrous "scrambled egg soup".


adding-vinegar

  • Now reduce the flame a little so that the water is not boiling hard. When the water is relatively calm, use a spoon to twirl the water in the pan so as to create a mini-whirlpool.


image092.jpg

  • Gently crack an egg, taking care not to break the yolk; and drop it into the center of the whirlpool. Drop the egg from close to the surface of the water.


image093.jpg

  • That's it. Waiting and watching: the only two things you need to do. No need to push the egg-white around. You will notice that the egg starts to cook immediately as it falls into the water, and it starts to congeal around the yolk. Cooking time varies between 90 seconds to three minutes depending on how well done you want it to be.


image100.jpg

  • Use a slotted spoon to gently scoop the cooked egg from the pan. Serve it on some good toasted bread (for those in Baltimore, try the raisin pumpernickel from Atwaters)


image103.jpg

Poaching an egg







Do you remember this scene from Julie and Julia? After watching it, I felt that poaching an egg requires some kind of black magic, and that it is extremely difficult for you to poach an egg without an egg poacher. I checked out a book by Jamie Oliver, and his advice was similar to that of Julia Child (as in the video). A google search gives you a tonne of conflicting advise. Finally, I found a way that has always worked for me:

  • Take lots of water in a saucepan and bring it to a light boil. Add a teaspoon of salt, and a teaspoon of the secret ingredient: vinegar. Vinegar helps the egg white to cook as soon as the egg is dropped into the water. This is what helps you avoid the disastrous "scrambled egg soup".


adding-vinegar

  • Now reduce the flame a little so that the water is not boiling very hard. When the water is relatively calm, use a spoon to twirl the water in the pan so as to create a mini-whirlpool in the pan.


image092.jpg

  • Gently crack an egg and drop it in the center of the whirlpool. Make sure that you do not break the yolk, and drop it from close to the surface of the water.


image093.jpg

  • That's it. All you now need to do for poaching your egg is to wait and watch. No need to push the egg-white around. You will notice that the egg starts to cook immediately as it falls into the water, and it starts to congeal around the yolk. Cooking time varies between 90 seconds to three minutes depending on how well done you want it to be.


image100.jpg

  • Use a slotted spoon to gently remove the egg from the pan. Serve it on some good toasted bread (for those in Baltimore, try the raisin pumpernickel from Atwaters)


image103.jpg

Friday, June 18, 2010

Sunday Brunch

As a graduate Indian student in the US, my weekend meals are a not a deterministic phenomenon. Cooking turns on weekdays are a regular thing on the schedule, but one meal I always enjoy, and hence look forward to, is the Sunday morning breakfast/brunch (depending on the time of waking up). Moreover, the whole act of cooking together in the morning is an entertaining prospect in itself.

We are big fans of cooking eggs for breakfast. And why not? The number of really good breakfast dishes you can make with eggs, and other commonly available ingredients is just plain delightful. I think half the fun in cooking eggs is sometimes not knowing till the end, how it is going to turn out. I revel in the suspense of whether this is going to turn out to be an omelette or part-scrambled.

The uncertainty at all times is due to the unpredictable nature of some of the frying pans we use.A good quality frying pan always lets you cleanly slide your cooked eggs on to the plate. I just love it when that happens. But if your frying pan is old, then it may be a bit of an effort taking the eggs off the pan, and you may not get everything in one piece.

eggs

Anyway, enough said about the dynamics of eggs and pans. Lets cook breakfast for two.First up, the eggs. You will need six eggs (6 whites and 3 yolks for those who are inclined). Add some salt and black pepper powder and beat them up till they are real nice and fluffy. Add a little milk if you wish.

mushroomsNext, take a couple of button mushrooms. Chop them up into bite size pieces.

Fire up your frying pan now, and add some extra virgin olive oil (any cooking oil in your kitchen will do). Throw in the mushrooms and sauté till they are slightly brown.

mushrooms-and-ginger-garlic-pasteRemember that mushrooms cook really quickly; so you don't want to overcook them. Add a teaspoon of ginger and garlic paste, and continue to sauté.

spinachAdd some chopped spinach to the pan, if you have any, and continue to sauté till the spinach seems to be cooked (this does not take more than a few minutes). She taught me to do the following: use a pair of ordinary kitchen scissors to chop the spinach right over the pan for small quantities. It is quick, easy and clean.

eggsinthepanAfter doing this for a couple of minutes, add the eggs to the pan. Hold the handle of the pan and shake it a little so that the veggies and the eggs are spread evenly and form a uniform coat.

mozzarellaLet it cook for a minute or so, and then add a few pieces of mozzarella cheese into the pan. Any kind of cheese that mixes/melts easily will do. We like trying out different varieties of cheese. The last time it was goat cheese. The mexican three cheese blend that you get in the grocery store is also great for adding to eggs.

cooking-eggsNow reduce the heat to low flame, cover the pan and let it cook for a couple of minutes till the eggs are a lot less runny. You still want to keep them a bit runny in the end - don't overcook.

blenderIn the meantime, lets make some smoothie. Nothing better than something healthy to drink along with your eggs. Take some oatmeal in a bowl, add double the quantity of water, and cook it in the microwave for 3 minutes. Take a blender, add the cooked oatmeal, a bunch of blueberries (any berries of your choice will work),a banana cut into pieces, and a generous quantity of yoghurt.Blend for a couple of seconds.

Then add some milk and some maple syrup to taste (honey works just as well). Continue to blend till you get a smooth consistency. Pour into glasses. Meanwhile, keep checking on the eggs once in a while.

cutting-eggsWe like them when they are still a wee bit runny. Lob off a piece of butter on top of your omelette and let it melt. Use a table knife (or wooden spatula) to cut it into slices while still in the pan.

breakfastFinally, toast a few slices of some really good bread from your local bakery. For those in Baltimore, she highly recommends (and I endorse) the sunflower flaxseed bread from Atwaters. Enjoy your meal!

Friday, June 04, 2010

Can’t connect to MySQL server on ’server’

Its been a long time since I wrote anything here. So, I thought let me resume by sharing a little piece of information I gathered the other day. So, I have been using MySQL to manage some data related to my research. I have installations on multiple machines that I use, and recently I had to install it on another ubuntu machine. I did the following:

<code>sudo apt-get install php5 mysql-server apache2 phpmyadmin</code>

It worked fine, but then, my python script that runs on another machine began to complain that it could not connect to my MySQL server:

 Can't connect to MySQL server on 'server'

Now that was just ridiculous because this has never happened before. So I trolled and trolled till I found what I was looking for:

http://www.webmasterworld.com/forum10/6141.htm

So, turns out that there is this tiny piece of configuration information in your /etc/mysql/my.cnf file that says:

bind-address = 127.0.0.1

which essentially means that all connections coming in from anywhere other than the local machine will not be entertained. Remove or comment that line and restart your server. Things start working!

Sunday, September 27, 2009

Rick Riordan at the National Book Festival

I was at the National Book Festival yesterday in Washington DC where several authors including Rick Riordan, John Grisham, Jodi Picoult and the like did book signings and talked to their fans. The event by itself was sort of poorly managed because the management probably did not expect a crowd on such a big scale (the Smithsonian metro station was closed in the afternoon due to too much crowd!).

But all that apart, people who went with the intention of meeting their favourite authors had a successful day, and that was perhaps the only worthy reason to go to the festival because the book festival did not have any book stalls (other than a jam packed Borders tent selling only very specific books).

Anyway, so I wen't to catch a glimpse of  Rick Riordan since I am an insane Percy Jackson fan.I got to the pavilion atleast 15 minutes in advance while the previous author was still speaking. After some pushing and jostling I finally edged into the tent and escaped the rain outside. There was hardly any place to stand but I positioned myself so that I could operate my camera.

His talk was quite funny in general and he gave his eager fans a glimpse of what is in store for them in the upcoming months:

1. There will a second Camp Half Blood series of books (yes you heard it right!) coming up soon. I forget if he mentioned when it will be out, but he mentioned that there will be more of Percy and Annabeth to come although Percy will not be the main character in the new series and there will be a new generation of demigods. The new series will probably be based on the next big prophecy that we encountered in "the last olympian".

2. May next year is going to be about Riordan's next novel that is based on Egyptian mythology. Now that is something that sounds really exciting. Riordan even read the first few lines from this upcoming book that he says is currently with his editor now!

3. Finally he talked about the Lightning Thief movie that is set to release in February next year. He mentioned that the role of Chiron will be played by Pierce Brosnan and that of Medusa will be played by Uma Thurman. Now that is some interesting cast.

Since I am travelling currently, I will upload pictures soon.

Tuesday, June 30, 2009

Using multiple applications with ASPNETDB

As a web developer, I have used ASPNETDB several times to manage the membership and role information for my applications. It has been a while since I have done software development in ASP.NET. So when I try things now, I realize there are several small things that I knew at my fingertips back then, come with a little more effort right now. I hooked up a new application to use the ASPNETDB, and tried to create a new login. I got the error that the username already exists.

This was surprising, because it was a new application. I realized that the application was actually pointing to the same instance of ASPNETDB on my DB server. I knew that there was some way of isolating multiple applications in the same membership database. After a bit of research I recalled out to do it:

In the web.config file, look for the following section:

<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ApplicationServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
applicationName="/"
/>
</providers>
</membership>

Change the value of the applicationName attribute inside the providers element to then name of your application, and you are good to go!

Friday, June 05, 2009

Free Internet?

This is a short post from the Greater Rochester International Airport as I wait for my flight. No other service at an airport makes me happier than free internet. The first time I saw this was when my flight to Memphis was delayed by a couple of hours and I was stuck waiting at Charlotte Douglas Int'l airport. I saw an unusually high number of people using their laptops and somehow got the feeling that there might be internet connectivity. I booted up my machine and to my pleasant surprise, I was right. I was able to establish a secure connection to my school network and get some work done while I waited. For internet savvy people like us, there isn't really much you can do if you are stuck waiting at an airport, and a free connection just saves your day.

But I was wondering what is it that allows an airport to host a free wifi connection. Large and prestigious airports like the O'Hare Int'l airport at Chicago do not have a free wifi connection. What is it that prevents them from doing so? What is the business model followed at the lesser known airports that lets them provide this service to travellers?

Sunday, March 15, 2009

Shuffle shuffle

Several weeks ago, I found myself thinking, how I could shuffle a list/array given to me in a random order. This is a typically commonplace thing to do in several applications: online card games, your favourite music player etc.

The interesting thing about this problem is how some naive approaches, even though easy to code and efficient enough, do not achieve the desired randomness.

Lets define the problem: You have an input array which has elements in positions 1 through n. The objective is to produce a random permutation of the array. By a random permutation, we mean to say that each permutation of the array is equally likely. So a truly randomized algorithm will generate each permutation with a probability of 1/n!

The first approach that comes to mind is the naive approach of generating a random number between 1 and n for each element in the array and placing the element at the position indicated by the random number. This could be accomplished by using another auxillary array and placing elements into the new positions generated. The pseudocode could look something like the following:

NaiveShuffle(A[1...n], B[1....n])            //randomly permutes the elements in array A
for i from 1 to n
random <- RandomNumber(1,n)
B[random] <- A[i]
for i from 1 to n
A[i] <- B[i]



The above approach is very crude in the sense it uses an auxillary array and also parses through the array twice instead of just once. Still, the worst case running time of the above algorithm is O(n).

Random(1, n) generates a random number 1 and n (both inclusive). We assume that the random number generator generates truly random numbers in the interval specified. Also, we assume some kind of collision resolution mechanism. We are assuming that this method returns a random number in O(1) time.

All that said, a O(n) algorithm is not bad at all for this purpose. There is only one problem, this algorithm is WRONG! (hah...fat chance, didn't we name it a naive algorithm?). Why is that? This is because in every iteration, we generate n possible choices. Since there are n such iterations, the total number of permutations generated is n.n.n.n.......n times = n^n

The  total number of permutations possible while shuffling an array is n!. Since n^n is not exactly divisible by n!, there have to be some permutations which appear more frequently than the others (basic pigeonhole principle). Thus this naive algorithm does not generate truly random permutations.

Lets try something else. We generate a random priority between 1 and n^3 the Random(1, n^3)  routine, and assign a it to each element in the array. Then sort the array based on these weights.

e.g. if the original array is A<1,2,3,4> and we generate priorities randomly as P<34,56,8,77>, then when we sort array A based on the increasing order of the priorities assigned using array P, then we get the shuffled array as <3, 1, 2, 4>.

We used the interval [1, n^3] to generate priorities so as to reduce collisions. I will not delve into the correctness of this algorithm. The running time of this shuffling by sorting algorithm depends on which sorting algorithm we use. Typically it is Big-Theta(n lg n).

Another approach to solve this problem, is to shuffle by swapping:
Shuffle[1...n]
for i from 2 to n
temp = Generate(x from 1 to i)
swap(i,temp)


Notice that the interval for generating random numbers keeps decreasing. For the first iteration, there are n choices. For the 2nd iteration, there are (n-1) choices and so on.

Hence the total number of choices generated by this algorithm is: n(n-1)(n-2).....3.2.1 = n!

which is exactly equal to the total number of possible permutations. Moreover, since we iterate over the array only once, this algorithm runs in O(n) time.

Saturday, January 17, 2009

The White Tiger: Aravind Adiga

TheWhiteTigerCoverThis novel, published in the year 2008 won the Man Booker Prize in the same year. I bought the book out of instinct, although I haven't had a very pleasant experience with a couple of other books that have won the same prize. Many people said that the books that won this award were difficult to read and not well accessible. One of my friends gave me a very bad review of the book, but I had no choice but to read it since I had already bought it. I approached the book without any pre-concieved  expectations and I was pleasantly surprised. While I did not bother asking my friend why she did not like the book, there are several reasons why I would recommend the book to any reader.
First of all, the book is an effortless read, and the story flows at a good pace. The story is narrated in first person by Balram Halwai, who is the protagonist. It is his account of his rise from lowly origins in a village in rural India amidst crushing poverty where even the basic amenities of life are hard to come by; to his current position as a successful entrepreneur in a big city. But the story is not one of inspiration as one would imagine from such an account. Instead it is a story full of intrigue, corruption and crime, but narrated with an innocent and brutally honest tone that makes you chuckle throughout. The story takes a swipe at the corrupt political system of the country and how the people are forced to play along with it if they want to survive. What moves you while reading this story is how the honest and hardworking village boy is transformed into a shrewd, scheming man who does not hesitate to take the law into his own hands.
Adiga has done a masterful job in this darkly comic debut novel of his with a sharp observation and sardonic voice.

Thursday, January 15, 2009

Unaccustomed Earth: Jhumpa Lahiri

UnaccustomedEarth Edited Cover pageThis is Jhumpa Lahiri's third piece of work (after Interpreter of Maladies and The Namesake). Sticking to her theme, this is also a set of short stories, based on the lives of expatriate Bengali parents and their american-raised children. I used to really want happy endings from books and stories I read. Jhumpa Lahiri is not someone who would give me that. Her stories are colorful, full of real characters that you would come to love; her writing is superlative and flows with an effortless pace; but the stories end abruptly at a crucial emotional juncture when the characters are at some kind of an emotional high point. I am always left wanting for more, but I end up accepting the stories for what they are.
One thing I noticed in her first two works is her brilliant descriptions of food and cooking, so much so that I used to be amazed at her culinary knowledge. I was looking forward to the same, but found that missing in Unaccustomed Earth.
There are two parts in the book: the first one has 4 stories, and the 2nd part has 3 stories. I did not realize till the middle of the last story that the 3 stories in the 2nd part are actually related: based on the same two protagonists. Each story in the trilogy are spaced apart by a number of years .You could call me dim for not figuring this out earlier, but these stories are just like the previous ones, and each one could be read without any bearing on the previous ones, and none of them give any direct indication of a connection, except for the names of the characters (which could have been anything in any of the stories without affecting the plot). The first two parts are narrated by the two individual characters, based around their separate lives. The third story is narrated by the author, linking the two characters together finally. Being a fan of different narrative styles, I loved this.
Finally, Jhumpa proves that she can write not only about life in the US, but also Europe, where a considerable portion of the final story is based.
Brilliant piece of writing. Highly recommended reading.

Monday, January 12, 2009

one flew east, one flew west….

OneFlewOverTheCukoosNestCoverI recently finished reading One Flew Over the Cukoo's Nest: by Ken Kesey. This novel has been included in TIME Magazine's 100 Best English-language Novels from 1923 to 2005.

The novel is based in the mental ward in a psychiatric hospital in Oregon. It is an allegory on the psychopathic obsession of that time (the 1960s). The story is narrated by a gigantic, half-Indian "Chief Bromden", a patient of the ward who suffers from hallucinations and delusions.The ward is controlled by a tyrannical nurse: Nurse Ratched who reigns over all the inhabitants of the ward, including the orderlies, the staff nurses, and even the doctor. He controls everyone with surgical precision, using underhanded tactics to render everyone helpless and submissive.

Things change with the arrival of Randal McMurphy, a Korean veteral who has a history of insubbordination and street brawls. McMurphy quickly realizes that several patients in the ward are sane and simply emasculated because of the nurse and her controlling tactics.

This novel is about the fight between authority and free spirit.

Saturday, January 03, 2009

Pillars of the earth

PillarsOfTheEarthCoverI started reading this book by Ken Follet over 5 months ago. When I just had a couple of dozen pages left to finish the book, I went away to the US and for some reason I did not carry the book with me. Now that I am back in India for a while, I finished the book today. It is a really big book with over a thousand pages. There are several plots in the story, and like most really long stories, you feel that some of those could have been avoided for the sake of a smaller and crisper story.

The plot of the story revolves around the building of a cathedral in medieval England during the period of civil war and how the lives of several people around the cathedral is embroiled in politics and powerplay. The book spans several years and hence the author has been able to sketch the characters in great detail (no surprise there).

Several  reviews on amazon tout this book as a breakthrough in the historical fiction genre, which I think is a bunch of nonsense (no wonder since the book was a part of Oprah's book club). I don't really have good things to say about Oprah's book club and I would probably have not picked up this book had I known earlier, but the book did turn out to be entertaining, with a lot of gratuitous sex and violence thrown in. Sometimes it drags simply because the plot is very twisted and long.

I did learn a bit about medieval architecture, cathedrals, clergymen, nobles and the like. All in all, I recommend this book for a one time read. Entertaining, but long.

Wednesday, December 24, 2008

Sending bulk emails using Outlook and C#

I have always derived pleasure writing programs that solve real world problems. This is one such problem that I was able to solve. With the holiday season on, you might want to send greetings to your numerous business contacts. If you have several contacts that you want to send personalized messages to, then you very well can imagine how much time and effort that will take.
So this is what I set out to do: create an application that would send out emails to several contacts, with a personalized greeting line, but similar message body. Also, depending on the type of contact, you might want to send a different message. E.g. if it is a close colleague of yours, then you might want to send a more personalized mail rather than a one liner. Since these are personalized emails, these need to be sent from your actual email id rather than an SMTP server on your dev machine. Also, I needed this application to work for someone else who runs only MS Office on his machine. So I decided to use Microsoft Office Outlook 2007 for this task.
The first thing to do was to decide the fomat in which I would store all the configuration information that would be used by the application: So I created two different text files, mail1.txt and mail2.txt each with a separate email message:

Hello {0}
Mail body

Where {0} is a placeholder that will be replaced by the receiver name. mail1.txt and mail2.txt have the same structure except for the mail body depending on the requirement.
Next, I needed to create a list of names and the corresponding email IDs to which the mails are to be sent. Also, I needed a flag that will indicate the type of message that is to be sent, i.e. mail1 or mail2. I created a comma separated file with the following format:

<Receiver’s name>, <email id>, <mail body to be sent, i.e. 1 or 2>

I wrote a console application in C# that uses the Microsoft Office 2007 Primary Interop assemblies to automate sending emails to all these contacts specified. The emails get sent using the default account configured in your Outlook. The code looks something like the following. Please note that this is a quick hack which actually works and that I have not really done a lot of error handling or exception management on this because I know the conditions under which this will be used.

Microsoft.Office.Interop.Outlook.Application app = null;
Microsoft.Office.Interop.Outlook._NameSpace ns = null;
Microsoft.Office.Interop.Outlook.PostItem item = null;
Microsoft.Office.Interop.Outlook.MAPIFolder inboxFolder = null;
Microsoft.Office.Interop.Outlook.MAPIFolder subFolder = null;
Microsoft.Office.Interop.Outlook.MailItem memo = null;
Microsoft.Office.Interop.Outlook.MAPIFolder sentFolder = null;
StreamReader addressReader = null;
StreamReader contentsReader = null;
StreamWriter logWriter = null;

try
{
addressReader = new StreamReader(ConfigurationManager.AppSettings["addresses"]);
String currentLine = String.Empty;
String[] currentReceiver = null;
String messageBodyFile = String.Empty;
logWriter = new StreamWriter(Path.Combine(Environment.CurrentDirectory, "Log.txt"), false);
while (!addressReader.EndOfStream)
{
currentLine = addressReader.ReadLine();
currentReceiver = currentLine.Split(',');
switch (currentReceiver[2])
{
case "1":
messageBodyFile = ConfigurationManager.AppSettings["contentsFile1"];
break;

case "2":
messageBodyFile = ConfigurationManager.AppSettings["contentsFile2"];
break;

default:
Console.WriteLine("Could not send email to ", currentReceiver[0]);
logWriter.WriteLine("Could not send email to ", currentReceiver[0]);
currentReceiver[1] = String.Empty;
break;
}

#region EmailInit

app = new Microsoft.Office.Interop.Outlook.Application();
ns = app.GetNamespace("MAPI");
ns.Logon(null, null, false, false);
sentFolder = ns.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
memo = (Microsoft.Office.Interop.Outlook.MailItem)app.CreateItem(OlItemType.olMailItem);

#endregion

contentsReader = new StreamReader(messageBodyFile);
memo.To = currentReceiver[1].Trim();
memo.Subject = ConfigurationManager.AppSettings["mailSubject"].Trim();
memo.Body = String.Format(contentsReader.ReadToEnd(), currentReceiver[0]);
memo.BodyFormat = OlBodyFormat.olFormatHTML;
memo.Send();
Console.WriteLine("{0}: Sent email with body {1} to {2}:{3}", DateTime.Now, currentReceiver[2], currentReceiver[0], currentReceiver[1]);
logWriter.WriteLine("{0}: Sent email with body {1} to {2}:{3}", DateTime.Now, currentReceiver[2], currentReceiver[0], currentReceiver[1]);
contentsReader.Close();
contentsReader.Dispose();
}
}

catch (System.Exception ex)
{
Console.WriteLine(ex.ToString());
EventLog.WriteEntry("Email Automation", ex.Message, EventLogEntryType.Error);
}

finally
{
ns = null;
app = null;
inboxFolder = null;
addressReader.Close();
addressReader.Dispose();
logWriter.Close();
logWriter.Dispose();
}