Theju's tryst with lifehttps://thejaswi.info/2023-04-09T00:00:00+00:00The Anarchy2023-04-09T00:00:00+00:002023-04-09T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2023-04-09:/personal/blog/2023/04/09/the-anarchy/<p>The English East India Company (EIC) is known for its role in colonising India. But
it also has other notorieties to its name, like being one of the first joint stock
companies to have a monopoly; to be bailed out by a government; to lobby by buying
access to MPs …</p><p>The English East India Company (EIC) is known for its role in colonising India. But
it also has other notorieties to its name, like being one of the first joint stock
companies to have a monopoly; to be bailed out by a government; to lobby by buying
access to MPs; to build its private militia.</p>
<p>William Darlymple, the author of this book ends it trying to draw parallels with
contemporary corporations and how we should be wary of them even if they don't
match up in power to the EIC.</p>
<p>This book is a brilliant biography of a greedy corporation that devoured a vibrant
country and left it emaciated in a few decades.</p>
As the Crow Flies2023-03-06T00:00:00+00:002023-03-06T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2023-03-06:/personal/blog/2023/03/06/as-the-crow-flies/<p>"As the Crow Flies" is a fiction work of Jeffrey Archer. It is a biography of
Charlie Trumper, an English retail magnate. It documents Charlie's life from
his childhood until he retires from the huge retail empire he builds.</p>
The Lust for Life2022-12-21T00:00:00+00:002022-12-21T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2022-12-21:/personal/blog/2022/12/21/the-lust-for-life/<p>Vincent Van Gogh is extremely famous now but he was barely able to make ends meet
and struggled with mental health issues while alive. His work became extremely
famous posthumously. "The Lust for Life" is his biography written by Irving Stone.</p>
The Motorcycle Diaries2022-12-11T00:00:00+00:002022-12-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2022-12-11:/personal/blog/2022/12/11/the-motorcycle-diaries/<p>Ernesto Guevera, popularly known as Che Guevera, along with his friend Alberto
wanted to go on an adventure. An adventure that would span the whole South
American continent partly on their motorcycle and the rest hitch hiking. This
journey would plant the inklings of revolution in Che and Alberto.</p>
Algorithms to live by2022-12-07T00:00:00+00:002022-12-07T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2022-12-07:/personal/blog/2022/12/07/algorithms-to-live-by/<p>Our lives are heavily controlled by algorithms, far more than we concede. Our
choice of entertainment, shopping, commute to work, appraisal at work etc
are all driven by algorithms. Sometimes we feel that algorithms are better
than humans because they are not arbitrary.</p>
<p>"Algorithms to live by" is a collection …</p><p>Our lives are heavily controlled by algorithms, far more than we concede. Our
choice of entertainment, shopping, commute to work, appraisal at work etc
are all driven by algorithms. Sometimes we feel that algorithms are better
than humans because they are not arbitrary.</p>
<p>"Algorithms to live by" is a collection of case studies of how algorithms
are shaping our daily life and how they can impact us in ways we have not
yet fully comprehended. From low dimensionality of results, biased training
data and opaqueness and lack of reasoning; this book covers all the major
drawback that deployment of algorithms can bring.</p>
The Rainmaker2022-11-29T00:00:00+00:002022-11-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2022-11-29:/personal/blog/2022/11/29/the-rainmaker/<p>What are the odds that a person will consult their lawyer when denied a health
insurance claim? If the odds are extremely small, the insurance company benefits
immensely! Rudy Baylor, who has recently passed the bar has picked up a insurance
bad faith case. It's a tough case to crack …</p><p>What are the odds that a person will consult their lawyer when denied a health
insurance claim? If the odds are extremely small, the insurance company benefits
immensely! Rudy Baylor, who has recently passed the bar has picked up a insurance
bad faith case. It's a tough case to crack for a new lawyer especially when
going against a large corporation who will deploy their large legal force to
scuttle every bid.</p>
<p>Rudy Baylor will need more than luck to win a case and deliver a victory to
a mother who has lost her son due to the inaction by the insurance company.</p>
The Odessa File2022-10-03T00:00:00+00:002022-10-03T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2022-10-03:/personal/blog/2022/10/03/the-odessa-file/<p>Peter Miller, a journalist, receives a diary from an old Jew who committed suicide.
He begins to read the diary and learns that the old man was liberated from a
concentration camp after the second World War and that he had spotted the in-charge
of the camp recently. Peter turns …</p><p>Peter Miller, a journalist, receives a diary from an old Jew who committed suicide.
He begins to read the diary and learns that the old man was liberated from a
concentration camp after the second World War and that he had spotted the in-charge
of the camp recently. Peter turns in the diary to the prosecutor's office but
realises they are reluctant to investigate. He then comes across a group of vigilantes
who go after war criminals and deliver justice.</p>
<p>They help Peter infiltrate the ODESSA, a secret organization of former Nazis, who
have slowly and quietly diffused back into every organization in Germany. Peter's
aim to go face to face with "The Butcher of Riga" and deliver justice. If Peter
succeeds in this quest forms the rest of the story authored by Frederic Forsyth.</p>
The mystery of the Parsee Lawyer2022-09-20T00:00:00+00:002022-09-20T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2022-09-20:/personal/blog/2022/09/20/the-mystery-of-the-parsee-lawyer/<p>Imagine you are incarcerated for a crime you haven't committed. The reason for targeting
being your race and skin colour. But you have the world's best detective novel author
untiringly championing your cause. Would you be exonerated?</p>
<p>"The mystery of the Parsee Lawyer" is the story of the curious case …</p><p>Imagine you are incarcerated for a crime you haven't committed. The reason for targeting
being your race and skin colour. But you have the world's best detective novel author
untiringly championing your cause. Would you be exonerated?</p>
<p>"The mystery of the Parsee Lawyer" is the story of the curious case of George Edalji,
a Christian Parsee who moved with his family to Britain in the late 1800s. In a few years,
mysterious letters were being circulated and gory animal mutilations began. George Edalji
got dragged into the investigation and imprisoned. Sir Arthur Conan Doyle (ACD) of Sherlock
Holmes fame learnt of Edalji's case and after an investigation strongly believed that
Edalji was not responsible for any of the incidents. He made Edalji's release his personal
battle and worked untiringly towards it. But would ACD be able to defeat the racial feelings
of the local public and the police?</p>
Norse Mythology2022-07-11T00:00:00+00:002022-07-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2022-07-11:/personal/blog/2022/07/11/norse-mythology/<p>Having grown up reading India mythology, it is uneasy to read about Gods who
are petty, vengeful and flawed. Neil Gaiman's "Norse Mythology" is a collection
of stories from the Nordic. While the stories are entertaining, it is a tad
difficult to keep track of the various realms, characters and …</p><p>Having grown up reading India mythology, it is uneasy to read about Gods who
are petty, vengeful and flawed. Neil Gaiman's "Norse Mythology" is a collection
of stories from the Nordic. While the stories are entertaining, it is a tad
difficult to keep track of the various realms, characters and terminology.</p>
Ego is the Enemy2022-06-29T00:00:00+00:002022-06-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2022-06-29:/personal/blog/2022/06/29/ego-is-the-enemy/<p>Ryan Holiday, the author of "Ego is the Enemy" got the book's title tattooed on
his arm to be constantly reminded that one of the largest obstacles in life is
'internal'.</p>
<p>Through various case studies of famous personalities, he delivers the message
that one should be humble and never let …</p><p>Ryan Holiday, the author of "Ego is the Enemy" got the book's title tattooed on
his arm to be constantly reminded that one of the largest obstacles in life is
'internal'.</p>
<p>Through various case studies of famous personalities, he delivers the message
that one should be humble and never let their ego take control.</p>
Weapons of Math Destruction2022-05-05T00:00:00+00:002022-05-05T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2022-05-05:/personal/blog/2022/05/05/weapons-of-math-destruction/<p>As automation sweeps the world, algorithms are beginning to decide almost every
aspect of our life. This doesn't necessarily mean it's a good thing as Cathy O'Neil
explains in this book. From bad data, small sample sizes and biased training,
algorithms could go rogue and deny people even the most …</p><p>As automation sweeps the world, algorithms are beginning to decide almost every
aspect of our life. This doesn't necessarily mean it's a good thing as Cathy O'Neil
explains in this book. From bad data, small sample sizes and biased training,
algorithms could go rogue and deny people even the most basic human rights.</p>
Twelve years a slave2022-04-03T00:00:00+00:002022-04-03T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2022-04-03:/personal/blog/2022/04/03/twelve-years-a-slave/<p>Solomon Northup was a free black citizen from New York. He was kidnapped
and sold into slavery in the fields of Georgia, where slavery had still not
been abolished. "12 years a slave" is the autobiography of Solomon and a
descriptive account of slavery in the South of USA.</p>
God is not Great2022-02-18T00:00:00+00:002022-02-18T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2022-02-18:/personal/blog/2022/02/18/god-is-not-great/<p>"God is not Great" by Christopher Hitchens is a book that pans "organized religion".
Using the Abrahamic religions, he exposes the hypocrisy of organized religion.</p>
King Leopold's Ghost2022-02-07T00:00:00+00:002022-02-07T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2022-02-07:/personal/blog/2022/02/07/king-leopolds-ghost/<p>King Leopold II of Belgium was the first European imperialist who colonised Africa.
This book by Adam Hochschild documents the deceit, greed and exploitation of
Congo. It's an extremely disturbing read and shakes one's conscience.</p>
Gene Machine2021-12-21T00:00:00+00:002021-12-21T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-12-21:/personal/blog/2021/12/21/gene-machine/<p>The gene machine is the story of the imaging of the ribosome authored by
Venki Ramakrishnan. While the book is quite technical, it is also a
thriller as multiple groups are shown to be racing towards the goal.</p>
Sea of Poppies2021-11-28T00:00:00+00:002021-11-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-11-28:/personal/blog/2021/11/28/sea-of-poppies/<p>One of the exports from the British trading outposts in India was Poppy. The other
and least discussed item was "indentured labour". This labour was shipped to their
other colonies to act as the muscle.</p>
<p>The Sea of Poppies by Amitav Ghosh is a collage of poignant stories that intersect …</p><p>One of the exports from the British trading outposts in India was Poppy. The other
and least discussed item was "indentured labour". This labour was shipped to their
other colonies to act as the muscle.</p>
<p>The Sea of Poppies by Amitav Ghosh is a collage of poignant stories that intersect
on a ship that generally shipped poppy.</p>
The Joy of Mathematics2021-10-01T00:00:00+00:002021-10-01T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-10-01:/personal/blog/2021/10/01/the-joy-of-mathematics/<p>The Joy of Mathematics is a great introductory book to the various branches of
Mathematics like geometry, calculus and numbers. It is extremely well-written
and can be a great introduction even for people with no math background.</p>
Queen's Gambit2021-09-30T00:00:00+00:002021-09-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-09-30:/personal/blog/2021/09/30/queens-gambit/<p>Beth Harmon is a chess prodigy who has burst into the male-dominated game and is
taking it by storm. But all is not well in her personal life. She has only goal
of becoming the World No. 1 and if she achieves that forms the rest of the story.</p>
The Guardians2021-09-19T00:00:00+00:002021-09-19T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-09-19:/personal/blog/2021/09/19/the-guardians/<p>"The Guardians" are a group of small lawyers who help free innocent convicts.
When they take up the case of Quincy Miller, they get more than they bargained for.
This is an extremely well written thriller that keeps you glued until the last page.</p>
The Little Prince2021-09-02T00:00:00+00:002021-09-02T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-09-02:/personal/blog/2021/09/02/the-little-prince/<p>The Little Prince is a short novel describing the conversation between a pilot who
is stranded in the Sahara desert after his plane has crashed and a little kid from
a far away planet.</p>
Gone with the wind2021-08-29T00:00:00+00:002021-08-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-08-29:/personal/blog/2021/08/29/gone-with-the-wind/<p>"Gone with the wind" is a novel and a history book rolled into one. It describes the evolution of
Scarlett O'Hara, the hero of the story against the backdrop of the American Civil War.</p>
Shoe Dog2021-07-23T00:00:00+00:002021-07-23T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-07-23:/personal/blog/2021/07/23/shoe-dog/<p>"Shoe Dog" is the autobiography of Nike founder, Phil Knight. I wasn't aware of the
history of Nike and this came as an extremely refreshing and lively story, one which
epitomises hustle and perseverance.</p>
The Righteous Mind2021-07-08T00:00:00+00:002021-07-08T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-07-08:/personal/blog/2021/07/08/the-righteous-mind/<p>"The Left" and "The Right" are the same in one aspect according to Jonathan Haidt
in his book "The Righteous Mind: Why Good People are Divided by Politics and Religion".
The aspect being receptive to ideas across the aisle.</p>
<p>The book is divided into two parts, the first where he …</p><p>"The Left" and "The Right" are the same in one aspect according to Jonathan Haidt
in his book "The Righteous Mind: Why Good People are Divided by Politics and Religion".
The aspect being receptive to ideas across the aisle.</p>
<p>The book is divided into two parts, the first where he discusses the history of how
institutions helped model people's beliefs and in the second of how people react to
opposing beliefs.</p>
Seven Brief Lessons on Physics2021-06-11T00:00:00+00:002021-06-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-06-11:/personal/blog/2021/06/11/seven-brief-lessons-on-physics/<p>Modern physics was born with Einstein's theory of special relativity. But common
man has still been quite ignorant of it's after-effects. "Seven brief lessons
on physics" by physicist Carlo Rovelli is an attempt to give an approachable
introduction to relativity and quantum mechanics.</p>
The Design of Everyday Things2021-05-29T00:00:00+00:002021-05-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-05-29:/personal/blog/2021/05/29/the-design-of-everyday-things/<p>"Design is subjective" is something we have heard often but that is not the
case says Dan Norman. It should clearly communicate with every user without
any ambiguity.</p>
<p>The examples that he quotes to build the book are of a faucet and a door.
Design issues that should have been …</p><p>"Design is subjective" is something we have heard often but that is not the
case says Dan Norman. It should clearly communicate with every user without
any ambiguity.</p>
<p>The examples that he quotes to build the book are of a faucet and a door.
Design issues that should have been fixed but still cause a lot of grief
world over. We have all been there where we aren't sure if we should push
or pull at a door or turn a faucet clockwise/anti-clockwise or lift it.</p>
<p>Through this book, Dan Norman explains some fundamental principles of
design and how a designer should adhere to them to make it easy for the
users.</p>
Woof2021-05-02T00:00:00+00:002021-05-02T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-05-02:/personal/blog/2021/05/02/woof/<p><strong>DISCLAIMER</strong>: I know the author personally and had read early drafts of the book.</p>
<p>Woof, by Aparna Karthikeyan, is the story of a pack of street dogs on some Mumbai beach
for young adults. These dogs who have been on the beach all their lives find a new pup
abandoned …</p><p><strong>DISCLAIMER</strong>: I know the author personally and had read early drafts of the book.</p>
<p>Woof, by Aparna Karthikeyan, is the story of a pack of street dogs on some Mumbai beach
for young adults. These dogs who have been on the beach all their lives find a new pup
abandoned in their midst. They name her Shingmo and she is assigned a mentor to get her
used to the life of a street dog.</p>
<p>The book sensitively handles the struggles of a street dog, loyalty and abandonment, and
highlights the generosity of the people who feed and care for them.</p>
Temporary People2021-04-21T00:00:00+00:002021-04-21T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-04-21:/personal/blog/2021/04/21/temporary-people/<p>What is with Malayali people and the gulf? How do they lead their lives across
the sea? Deepak Unnikrishnan's "Temporary People" is a collection of short
stories of regular Malayali immigrants in the Middle East. The stories make
use of fantasy and hyperbole to convey the 'concealed and relegated' status …</p><p>What is with Malayali people and the gulf? How do they lead their lives across
the sea? Deepak Unnikrishnan's "Temporary People" is a collection of short
stories of regular Malayali immigrants in the Middle East. The stories make
use of fantasy and hyperbole to convey the 'concealed and relegated' status
of the immigrants.</p>
Factfulness2021-04-10T00:00:00+00:002021-04-10T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-04-10:/personal/blog/2021/04/10/factfulness/<p>Statistics can be tortured to convey whatever the captor wishes. And this
is being done every day across the political spectrum and ideologies.</p>
<p>Hans Rosling feels that while statistics quoted daily all over may provide
a negative picture, the world has improved a lot despite people (all over
the world …</p><p>Statistics can be tortured to convey whatever the captor wishes. And this
is being done every day across the political spectrum and ideologies.</p>
<p>Hans Rosling feels that while statistics quoted daily all over may provide
a negative picture, the world has improved a lot despite people (all over
the world) being woefully ignorant. This is one of those books that gives
you hope that not everything is screwed up in the world and we are making
slow and steady progress.</p>
Of Mice and Men2021-04-03T00:00:00+00:002021-04-03T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-04-03:/personal/blog/2021/04/03/of-mice-and-men/<p>The Great Depression of the 1930s devastated America and left a lot of people
without livelihoods. George and Lennie are two farm hands on the lookout for
work. They have been driven out of their previous work due to accusations of
inappropriate behaviour by Lennie who is mentally disabled.</p>
<p>George …</p><p>The Great Depression of the 1930s devastated America and left a lot of people
without livelihoods. George and Lennie are two farm hands on the lookout for
work. They have been driven out of their previous work due to accusations of
inappropriate behaviour by Lennie who is mentally disabled.</p>
<p>George is Lennie's protector as they have been together for a long time. He
also knows that Lennie will keep getting him into trouble until they have some
land of their own.</p>
<p>They find a job which they hope is their last job before they buy some land.
But will it be their last job?</p>
Akbar: The Great Mughal2021-03-31T00:00:00+00:002021-03-31T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-03-31:/personal/blog/2021/03/31/akbar-the-great-mughal/<p>Jalaluddin was 13 when his father Humayun passed away, a reign that was
precarious. There were many claimants to the throne, from the Surs who
were dethroned by Humayun, to brothers of Humayun and even the Adil Shahs
from the south.</p>
<p>Until he came of age, Akbar was placed under …</p><p>Jalaluddin was 13 when his father Humayun passed away, a reign that was
precarious. There were many claimants to the throne, from the Surs who
were dethroned by Humayun, to brothers of Humayun and even the Adil Shahs
from the south.</p>
<p>Until he came of age, Akbar was placed under the regency of Bairam Khan
and the women of his household like Gulbadan Begum (sister of Humayun) and
Maham Anga (foster mother of Akbar) acted like a counterbalance.</p>
<p>After he took over the reins, he began assimilating neighbouring provinces
either through conquests or through alliances. Once he secured the borders,
a period of relative peace began that lasted throughout his reign. This
allowed Akbar to reform his administration and ruminate on theology.</p>
The Shining2021-02-13T00:00:00+00:002021-02-13T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-02-13:/personal/blog/2021/02/13/the-shining/<p>"The Shining" by Stephen King was a difficult novel to read. Not because of
the writing but from the disturbing recollections of events by Danny, a
central character in the book who is gifted with clairvoyance, a trait
referred to as "The Shining".</p>
<p>Jack, his wife Wendy and Danny their …</p><p>"The Shining" by Stephen King was a difficult novel to read. Not because of
the writing but from the disturbing recollections of events by Danny, a
central character in the book who is gifted with clairvoyance, a trait
referred to as "The Shining".</p>
<p>Jack, his wife Wendy and Danny their son are off to the Overlook hotel located
in a remote part in the winter to look after it while it is shut down to guests
from the heavy snow. Jack had thrown away his promising writing career due to
alcoholism. He has one last chance to prove himself and he hopes that the
secluded location and the idyllic environs will help him recover and provide
inspiration to complete his writing.</p>
<p>But things don't go as per plan.</p>
Plassey2021-02-11T00:00:00+00:002021-02-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-02-11:/personal/blog/2021/02/11/plassey-battle-that-changed-course-indian-history/<p>Mir Jaffer, a name that I kept hearing a lot during the West Bengal elections this year.
It was a name connected to Bengal and Indian history but one that I had hardly heard of
while at school. And serendipitously I would run into that name again through a book …</p><p>Mir Jaffer, a name that I kept hearing a lot during the West Bengal elections this year.
It was a name connected to Bengal and Indian history but one that I had hardly heard of
while at school. And serendipitously I would run into that name again through a book
recommendation - "Plassey: The battle that changed the course of Indian history".</p>
<p>Sudeep Chakravarti through his book contends that Plassey was the beginning of the
colonisation of India by the British. The British had pockets of presence in India
through trading posts and as envoys in multiple courts for many decades until the 1700s
but they never seemed to have a large ambition. Events transpiring in Europe (the 100
years war between France and England) and competing trading interests in India first
put the two colonial powers onto a war path and sets the tone for the battle in 1757.
A yearning for the crown makes Mir Jaffer switch loyalties. While he succeeds in
capturing the throne (albeit for a short duration) with the assistance of the
British, his name gets stained for ages to come; synonymous with a 'traitor'.</p>
<p>The book makes a lot of effort to provide context for the events that led to the
war. It relies on a handful of sources, one which is extensively quoted before the
war and the second being the English themselves post-war. Despite being fairly
one-sided, the author has worked hard to provide an objective narrative.</p>
Masala Lab2021-01-10T00:00:00+00:002021-01-10T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-01-10:/personal/blog/2021/01/10/masala-lab/<p>I had heard of Nathan Myhrvold's "Modernist Cuisine", a book which merged science
and cooking. So when I was gifted "Masala Lab: The science of Indian cooking", it
piqued my interest. Krish Ashok does a good job of explaining some Indian cooking
processes while providing tips on taking it to …</p><p>I had heard of Nathan Myhrvold's "Modernist Cuisine", a book which merged science
and cooking. So when I was gifted "Masala Lab: The science of Indian cooking", it
piqued my interest. Krish Ashok does a good job of explaining some Indian cooking
processes while providing tips on taking it to the next level.</p>
The Calculus Story2021-01-01T00:00:00+00:002021-01-01T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2021-01-01:/personal/blog/2021/01/01/the-calculus-story/<p>"The Calculus Story: A Mathematical Adventure" by David Acheson is a gentle
introduction to Calculus. It is light on formulae and mathematics as it's
intended audience is supposed to be beginners who wish to get into calculus.</p>
<p>It starts with a brief history of the feud between Newton and Leibniz …</p><p>"The Calculus Story: A Mathematical Adventure" by David Acheson is a gentle
introduction to Calculus. It is light on formulae and mathematics as it's
intended audience is supposed to be beginners who wish to get into calculus.</p>
<p>It starts with a brief history of the feud between Newton and Leibniz on who
the inventor of calculus is and then gets into explaining the various concepts
like differentiation, integration etc through some real world problems.</p>
<p>This is a small book, one that can be finished quickly and is pleasurable.</p>
Unaccustomed Earth2020-12-22T00:00:00+00:002020-12-22T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-12-22:/personal/blog/2020/12/22/unaccustomed-earth/<p>Unaccustomed Earth is a collection of short stories by Jhumpa Lahiri. Most stories
deal with Indian immigrants or their descendants in the US. The stories tug the
whole gamut of emotions - from jealousy to disconnectedness; from sympathy to grief.</p>
How Not to be Wrong2020-12-07T00:00:00+00:002020-12-07T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-12-07:/personal/blog/2020/12/07/how-not-to-be-wrong/<p>Mathematics is everywhere! Jordan Ellenberg reminds us that it is behind
every aspect of our life and it helps make our life better if we understand
it.</p>
<p>This book is divided into 6 chapters and each chapter picks one real world
scenario and teaches how mathematics influences it. This book …</p><p>Mathematics is everywhere! Jordan Ellenberg reminds us that it is behind
every aspect of our life and it helps make our life better if we understand
it.</p>
<p>This book is divided into 6 chapters and each chapter picks one real world
scenario and teaches how mathematics influences it. This book is a brilliant
read even for those people who don't like maths.</p>
Punjab: From Aurangzeb to Mountbatten2020-11-30T00:00:00+00:002020-11-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-11-30:/personal/blog/2020/11/30/punjab-from-aurangzeb-to-mountbatten/<p>It's a well known fact in India that Punjab was the eastern-most province
of India that had to be protected from external aggressions lie from the time
of Alexander to Nadir Shah.</p>
<p>But very little is known of Punjab after the decay of the Mughal empire. This
book by Rajmohan …</p><p>It's a well known fact in India that Punjab was the eastern-most province
of India that had to be protected from external aggressions lie from the time
of Alexander to Nadir Shah.</p>
<p>But very little is known of Punjab after the decay of the Mughal empire. This
book by Rajmohan Gandhi is an effort to address this shortcoming. The book
details the various principalities of Punjab and how they coalesced under
the Maharaja Ranjit Singh. Treachery brought down this empire and the English
swept in thereafter.</p>
<p>Well after the English took over most of the country, Punjab still remained
on the forefront by gifting leaders like Lala Lajput Rai, Bhagath Singh and
others to the freedom struggle.</p>
The Man who knew Infinity2020-11-14T00:00:00+00:002020-11-14T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-11-14:/personal/blog/2020/11/14/the-man-who-knew-infinity/<p>A shipping clerk put India on the mathematical map in the early 1900s. His
work is still being decoded to this day and his genius is still as mysterious.</p>
<p>Srinivasa Ramanujan had an ordinary life until his letter to the famous English
mathematician, GH Hardy brought him to England to …</p><p>A shipping clerk put India on the mathematical map in the early 1900s. His
work is still being decoded to this day and his genius is still as mysterious.</p>
<p>Srinivasa Ramanujan had an ordinary life until his letter to the famous English
mathematician, GH Hardy brought him to England to work on numbers and their series.
Culturally neither could understand each other but their professional collaboration
would be the matter of discussion for decades to come.</p>
<p>Robert Kanigel's biography of Ramanujan provides a window into his childhood
while providing a context through the societal norms in colonial India. Just this
makes it a worthwhile book.</p>
<p>The struggles of Ramanujan in England with the climate, the culture and the
wartime rationing break your heart and wish that Ramanujan would have been
better off if he had been born a few decades later.</p>
Pachinko2020-10-25T00:00:00+00:002020-10-25T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-10-25:/personal/blog/2020/10/25/pachinko/<p>Pachinko is a multi-generational story written by Min Jin Lee. Sunja, the
daughter of a Korean fisherman falls in love with a trader only to realise
that he is already married. She refuses to be his paramour and by curious
turn of fate gets married to a parish minister only …</p><p>Pachinko is a multi-generational story written by Min Jin Lee. Sunja, the
daughter of a Korean fisherman falls in love with a trader only to realise
that he is already married. She refuses to be his paramour and by curious
turn of fate gets married to a parish minister only for him to die soon.
Single, she brings up her children under Japanese occupation braving a lot
of hardships and stigma. Do her children appreciate her sacrifices?</p>
Benjamin Franklin: An American Life2020-10-11T00:00:00+00:002020-10-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-10-11:/personal/blog/2020/10/11/benjamin-franklin-an-american-life/<p>Walter Isaacson is a brilliant biographer. He brings out a balanced biography and
doesn't get carried with the weight of the personality. Benjamin Franklin's
biography is no different!</p>
<p>Known as one of the founding fathers of America, the biography covers all aspects
of his life - a publisher, satirist, author, scientist …</p><p>Walter Isaacson is a brilliant biographer. He brings out a balanced biography and
doesn't get carried with the weight of the personality. Benjamin Franklin's
biography is no different!</p>
<p>Known as one of the founding fathers of America, the biography covers all aspects
of his life - a publisher, satirist, author, scientist and finally a diplomat!</p>
A fine balance2020-08-28T00:00:00+00:002020-08-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-08-28:/personal/blog/2020/08/28/a-fine-balance/<p>Set during the dark time of Emergency, "A Fine Balance" traces the story of 4
characters from different backgrounds but who find themselves under one roof
in the megacity of Mumbai.</p>
<p>Their lives are poignantly described through various facets like caste, community
and ideology and yet they all have one …</p><p>Set during the dark time of Emergency, "A Fine Balance" traces the story of 4
characters from different backgrounds but who find themselves under one roof
in the megacity of Mumbai.</p>
<p>Their lives are poignantly described through various facets like caste, community
and ideology and yet they all have one thing in common - "hope". Hope that they
can escape their circumstances and their lives will improve.</p>
Right Ho, Jeeves2020-08-15T00:00:00+00:002020-08-15T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-08-15:/personal/blog/2020/08/15/right-ho-jeeves/<p>Any regular reader of the Jeeves series will tell you that there can only be one
ending yet they love to read it. It's probably because of Wodehouse's writing
style. It effortlessly transports you to aristocratic England where masters loved
to frequent the club and hang out with buddies and …</p><p>Any regular reader of the Jeeves series will tell you that there can only be one
ending yet they love to read it. It's probably because of Wodehouse's writing
style. It effortlessly transports you to aristocratic England where masters loved
to frequent the club and hang out with buddies and their valets looked after their
domestic needs. "Right Ho, Jeeves" doesn't disappoint on that count and Jeeves,
Bertram Wooster's valet, saves the day for his master and his family.</p>
Everybody Lies2020-04-29T00:00:00+00:002020-04-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-04-29:/personal/blog/2020/04/29/everybody-lies/<p>"Everybody Lies: Big Data, New Data and What The Internet Can Tell Us About Who We Really Are"
is a mouthful. Seth Stephens-Davidowitz analyses the 'new' data sources that
are now available to researchers, corporations and governments to sometimes expose the
hypocrisy in the society. We claim to be more …</p><p>"Everybody Lies: Big Data, New Data and What The Internet Can Tell Us About Who We Really Are"
is a mouthful. Seth Stephens-Davidowitz analyses the 'new' data sources that
are now available to researchers, corporations and governments to sometimes expose the
hypocrisy in the society. We claim to be more liberal and progressive but our search engine
queries show a different picture. In some cases, corporations are using these sources to
gleam information even before our near and dear are aware of it. Like Target sending
coupons for baby products to expecting mothers just based on their purchase history. Or
political parties targeting our latent biases based on our social media posts or our
friends.</p>
<p>This is a book that is fascinating and scary at the same time.</p>
The Power of Habit2020-03-30T00:00:00+00:002020-03-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-03-30:/personal/blog/2020/03/30/the-power-of-habit/<p>Habits as some say can be made in 21 days. But does this stick?
Is there any science behind these claims? Charles Duhigg explores the
power of creating and modifying habits through some stories featured
in the news media.</p>
Leonardo2020-03-12T00:00:00+00:002020-03-12T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-03-12:/personal/blog/2020/03/12/leonardo/<p>Leonardo from Vinci aka Leonardo da Vinci is a name that needs no introduction.
Most people recognize him from his paintings and scribblings from his note book.</p>
<p>But what was he as a person? How did he build such a powerful brand during the
peak of the Italian renaissance amongst …</p><p>Leonardo from Vinci aka Leonardo da Vinci is a name that needs no introduction.
Most people recognize him from his paintings and scribblings from his note book.</p>
<p>But what was he as a person? How did he build such a powerful brand during the
peak of the Italian renaissance amongst contemporaries like Michelanegelo,
Raphael, Bramante etc.</p>
<p>Walter Isaacson again (see Einstein and Steve Jobs) delights with a well-researched
book that deals with a famous person about whom people know sparsely beyond their
masterpiece.</p>
Surely you are joking Mr. Feynman2020-02-28T00:00:00+00:002020-02-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-02-28:/personal/blog/2020/02/28/surely-you-are-joking-mr-feynman/<p>"Surely you are joking, Mr. Feynman" is a memoir of Nobel Prize winning
physicist Richard Feynman written by a close friend based on stories he
heard from Richard Feynman during their time together.</p>
<p>This book has not much to do with science but showcases Richard Feynman's
multiple interests like in …</p><p>"Surely you are joking, Mr. Feynman" is a memoir of Nobel Prize winning
physicist Richard Feynman written by a close friend based on stories he
heard from Richard Feynman during their time together.</p>
<p>This book has not much to do with science but showcases Richard Feynman's
multiple interests like in samba music, languages, safe-cracking etc. It's
a fairly light reading and gives you an idea of the kind of person he was
outside his lab.</p>
India's Struggle For Independence2020-02-15T00:00:00+00:002020-02-15T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-02-15:/personal/blog/2020/02/15/indias-struggle-for-independence/<p>What were the societal conditions that triggered the 1857 revolt? How did
the Congress movement come into existence? Why was a movement that was
dominated by peasants tilt towards the middle-class? This book is divided
by various time periods and analyses the various strategies of the
different classes of society …</p><p>What were the societal conditions that triggered the 1857 revolt? How did
the Congress movement come into existence? Why was a movement that was
dominated by peasants tilt towards the middle-class? This book is divided
by various time periods and analyses the various strategies of the
different classes of society in achieving a common goal of freedom from
colonial rule.</p>
The Namesake2020-02-09T00:00:00+00:002020-02-09T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-02-09:/personal/blog/2020/02/09/the-namesake/<p>What's in a name? For some, there is a long and emotional story. "The Namesake"
by Jhumpa Lahiri is a beautiful story of a couple that immigrates to America
and their American-born children.</p>
Guns, Germs and Steel2020-01-24T00:00:00+00:002020-01-24T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-01-24:/personal/blog/2020/01/24/guns-germs-and-steel/<p>Have you ever wondered why the American Indians (natives) didn't cross the Atlantic
and colonize Europe or why the Aborigines in Australia could not successfully resist
a European colonization?</p>
<p>Jared Diamond answers these questions and more on how and why society is today shaped
through the events in history. A …</p><p>Have you ever wondered why the American Indians (natives) didn't cross the Atlantic
and colonize Europe or why the Aborigines in Australia could not successfully resist
a European colonization?</p>
<p>Jared Diamond answers these questions and more on how and why society is today shaped
through the events in history. A fascinating book on how a few environmental factors
helped a few civilizations to leap frog technologically and societally.</p>
Why we sleep?2020-01-06T00:00:00+00:002020-01-06T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2020-01-06:/personal/blog/2020/01/06/why-we-sleep/<p>Why do we sleep? To rest the body and brain? Or does it have any other function?
Matthew Walker, a sleep researcher has written this book to answer the question.</p>
<p>The author starts off with an explosive statement that sleep deprivation is the
largest undiagnosed global epidemic. He then describes …</p><p>Why do we sleep? To rest the body and brain? Or does it have any other function?
Matthew Walker, a sleep researcher has written this book to answer the question.</p>
<p>The author starts off with an explosive statement that sleep deprivation is the
largest undiagnosed global epidemic. He then describes the various stages of sleep
and their role in our well-being. And then citing studies, he suggests that one
should maintain a good sleep hygiene.</p>
Pride and Prejudice2019-12-30T00:00:00+00:002019-12-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-12-30:/personal/blog/2019/12/30/pride-and-prejudice/<p>"Pride and Prejudice" by Jane Austen is a beautiful novel which one can
read just for it's style. Mr. Bennet has 5 daughters of marriageable age.
A rich and eligible bachelor moves into town. Mr. Bingley hosts a ball
to acquaint himself with his new townsmen and here takes a …</p><p>"Pride and Prejudice" by Jane Austen is a beautiful novel which one can
read just for it's style. Mr. Bennet has 5 daughters of marriageable age.
A rich and eligible bachelor moves into town. Mr. Bingley hosts a ball
to acquaint himself with his new townsmen and here takes a liking for
Miss Jane, the eldest of Bennet daughters. His friend, Mr. Darcy
disappoints a lot of people with his display of arrogance and
snobbishness. He hurts Elizabeth's (second daughter) pride by
claiming he found her unattractive.</p>
<p>A lot more characters make their entry and the plot gets murkier until a
letter from Elizabeth's aunt sets things in perspective.</p>
Quiet: The Power of Introverts2019-12-21T00:00:00+00:002019-12-21T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-12-21:/personal/blog/2019/12/21/quiet-the-power-of-introverts/<p>"Quiet: The power of introverts in a world that can't stop talking" is a
a non-fiction book authored by Susan Cain. The purpose of the book is to
correct the view that introverts are a bane to the society.</p>
<p>The author starts off with how we got to this stage …</p><p>"Quiet: The power of introverts in a world that can't stop talking" is a
a non-fiction book authored by Susan Cain. The purpose of the book is to
correct the view that introverts are a bane to the society.</p>
<p>The author starts off with how we got to this stage where being an "extrovert"
is considered an ideal. She describes the problem of seeking extroversion.
Then she sets the record straight on what introversion is (being silent is
not one), how to distinguish and nurture it.</p>
<p>The take-away from this book is that society needs diversity (of all kinds)
and it should try to achieve a balance rather than move towards homogenization.</p>
The Myth of Sisyphus2019-12-10T00:00:00+00:002019-12-10T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-12-10:/personal/blog/2019/12/10/the-myth-of-sisyphus/<p>Albert Camus' "The Myth of Sisyphus" can essentially be distilled into a
single question - "Is suicide ethical?". This question has divided philosophers
for centuries.</p>
<p>To answer the question, Camus builds upon the arguments of Kierkegaard and Nietzche
and comes up with the philosophy of the "absurd". This philosophy states that …</p><p>Albert Camus' "The Myth of Sisyphus" can essentially be distilled into a
single question - "Is suicide ethical?". This question has divided philosophers
for centuries.</p>
<p>To answer the question, Camus builds upon the arguments of Kierkegaard and Nietzche
and comes up with the philosophy of the "absurd". This philosophy states that all
life is absurd because one hopes for a better tomorrow even though tomorrow brings
us closer to death. It is this contradiction that provides direction to people's
lives.</p>
<p>The last portion of the book explains the story of Sisyphus, who is punished
by the Gods to eternally keep hauling a huge rock to the top of a mountain
to only have it roll back down. Albert Camus wonders about the questions going
through Sisyphus' head. Why is he up for a task knowing well that he can never
complete it? Isn't it better for him to quit than to be part of this absurd?</p>
The Martian2019-11-20T00:00:00+00:002019-11-20T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-11-20:/personal/blog/2019/11/20/the-martian/<p>Imagine you were on an year-long space mission to Mars and you got stranded.
And your next chance of being rescued is a few years away. How would you
survive?</p>
<p>"The Martian" by Andy Weir is based on that premise. Mark Watney gets blown
away in a Martian storm while …</p><p>Imagine you were on an year-long space mission to Mars and you got stranded.
And your next chance of being rescued is a few years away. How would you
survive?</p>
<p>"The Martian" by Andy Weir is based on that premise. Mark Watney gets blown
away in a Martian storm while trying to evacuate along with his team.
They assume him dead and start their journey back to earth without him. But
fate has something else in store for him. He survives but has no means of
contacting earth. His only chance of returning back to earth is on a future
expedition scheduled in a few years.</p>
<p>The book is a fascinating read on Mark's indomitable spirit, fluid adaptations
and quick thinking.</p>
Nine Rupees an Hour2019-11-02T00:00:00+00:002019-11-02T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-11-02:/personal/blog/2019/11/02/nine-rupees-an-hour/<p><strong>Disclaimer</strong>: I know the author personally and have read early drafts.</p>
<p>Why does a livelihood practised over generations disappear? Can "Nine
Rupees an Hour" be considered a fair wage for the exquisite skill of
the Pattamadai Pai weavers? Would society be richer by the loss of
such livelihoods?</p>
<p>Aparna Karthikeyan …</p><p><strong>Disclaimer</strong>: I know the author personally and have read early drafts.</p>
<p>Why does a livelihood practised over generations disappear? Can "Nine
Rupees an Hour" be considered a fair wage for the exquisite skill of
the Pattamadai Pai weavers? Would society be richer by the loss of
such livelihoods?</p>
<p>Aparna Karthikeyan, a journalist from Tamil Nadu answers these questions
while documenting ten rural-based traditional livelihoods that are on
the verge of disappearing.</p>
<p>She uses simple story-telling to make it accessible to a large audience
while not sounding preachy.</p>
The Day of the Jackal2019-10-21T00:00:00+00:002019-10-21T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-10-21:/personal/blog/2019/10/21/the-day-of-the-jackal/<p>Charles de Gaulle is the French President, loved by some but also hated by a few.
The few feel he betrayed their cause and want him bumped off. They are hounded out
of the country after a failed assassination attempt. Fearing a mole within their
ranks, the rebels decide to …</p><p>Charles de Gaulle is the French President, loved by some but also hated by a few.
The few feel he betrayed their cause and want him bumped off. They are hounded out
of the country after a failed assassination attempt. Fearing a mole within their
ranks, the rebels decide to hire a foreign assassin one who can't be tracked and
one who won't be exposed by internal leaks. An English man code-named "The Jackal"
is chosen for the job of putting a bullet into the heart of the French President.</p>
<p>The story documents this operation of "The Jackal". While Frederick Forsyth, the
author gives it away at the beginning that the assassination was averted but the
cat and mouse game between the French police and the assassin is gripping.</p>
A Brief History of Time2019-10-09T00:00:00+00:002019-10-09T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-10-09:/personal/blog/2019/10/09/a-brief-history-of-time/<p>Science can be hard to write and harder to read. But once in a while a scientist
comes along and explains science in an understandable manner. Stephen Hawking is
one such scientist. A Brief History of Time is the biography of the universe. It
starts with how our idea of …</p><p>Science can be hard to write and harder to read. But once in a while a scientist
comes along and explains science in an understandable manner. Stephen Hawking is
one such scientist. A Brief History of Time is the biography of the universe. It
starts with how our idea of the universe evolved from the times of early Greek
philosophers to our current understanding. There is a clear explanation of black
holes with answers to some common questions related to them.</p>
One Hundred Years of Solitude2019-10-01T00:00:00+00:002019-10-01T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-10-01:/personal/blog/2019/10/01/one-hundred-years-of-solitude/<p>This is the first book in my life for which I had to build and constantly keep
referring to a family tree. With so many characters (most with the same name!),
the book gets confusing and inter-breeding and incest only adds to the disgust.</p>
<p>"One Hundred Years of Solitude" is …</p><p>This is the first book in my life for which I had to build and constantly keep
referring to a family tree. With so many characters (most with the same name!),
the book gets confusing and inter-breeding and incest only adds to the disgust.</p>
<p>"One Hundred Years of Solitude" is Gabriel Garcia Marquez's fictional history
of a town in Colombia and it's first family - the Buendias. Spanning over
multiple generations, the family's fortunes are linked with that of the town.</p>
<p>While the family boasts of many members during each generation, they are always
lonely just like the town which is isolated from the rest of the country by it's
location.</p>
<p>The book requires a lot of persistence to complete and I wouldn't blame you if you
put it down well before the end.</p>
Whole: Rethinking the Science of Nutrition2019-09-18T00:00:00+00:002019-09-18T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-09-18:/personal/blog/2019/09/18/whole-rethinking-the-science-of-nutrition/<p>"Whole: Rethinking the Science of Nutrition" is Colin Campbell's book that
advocates whole-foods and plant-based diet. A biochemist by profession, the
author mostly quotes his own research to try to prove that any other diet
has higher incidences of cancer.</p>
<p>There is a lot in the book that is agreeable …</p><p>"Whole: Rethinking the Science of Nutrition" is Colin Campbell's book that
advocates whole-foods and plant-based diet. A biochemist by profession, the
author mostly quotes his own research to try to prove that any other diet
has higher incidences of cancer.</p>
<p>There is a lot in the book that is agreeable like how research nowadays
is mostly reductionist instead of holistic, pharma companies infiltrating
academia to discredit opposing research and pushing their agenda, governments
spending billions on symptomatic treatment instead of prevention, processed
foods and factory farming are damaging not just the food but the ecosystem
etc. But ad hominem attacks and discredited study methodologies (by author
itself) dilute his message and raise doubts.</p>
Adulting2019-09-05T00:00:00+00:002019-09-05T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-09-05:/personal/blog/2019/09/05/adulting/<p>Adulting is supposed to mean "behaving like an adult" but in the book by Neharika
Gupta, there doesn't appear to be anyone that matches this meaning. Ruhi, Aisha
and Tejas are the only characters in the book and they behave like immature teenagers.</p>
<p>Ruhi is a workaholic who runs a …</p><p>Adulting is supposed to mean "behaving like an adult" but in the book by Neharika
Gupta, there doesn't appear to be anyone that matches this meaning. Ruhi, Aisha
and Tejas are the only characters in the book and they behave like immature teenagers.</p>
<p>Ruhi is a workaholic who runs a fledgling publishing house and earning her mother's
approval is one of the biggest dreams of her life. Tejas is a first-time author whose
book is published by Ruhi's company. He is romantically involved with Ruhi and she
goes all out to promote him. She hires Aisha, a social media influencer to promote
the publishing house and Tejas. But Aisha has her own demons, she purges her stomach
regularly to maintain her appearance on her social feeds. Tejas proposes to Aisha
after a few weeks of working together (teenage mistake #2) and hurts Ruhi. Tejas
loses his contract with the publishing house and Ruhi's hard work goes down the drain
when her mom winds down the publishing house. A cold war ensues between Aisha and
Ruhi and Aisha finds herself unemployed. The stress gets to Aisha and she breaks up
with Tejas.</p>
<p>Will Tejas make amends and ask for forgiveness from Ruhi and Aisha and finally behave
like a responsible adult?</p>
The Diary of a Young Girl2019-09-02T00:00:00+00:002019-09-02T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-09-02:/personal/blog/2019/09/02/the-diary-of-a-young-girl/<p>"The Diary of a Young Girl" is the diary of Anne Frank, a teen who was captured
in 1944 along with her family by the Nazis as they were hiding in Amsterdam.</p>
<p>The diary starts a few weeks before her family's escape to a warehouse where they
hide for 2 …</p><p>"The Diary of a Young Girl" is the diary of Anne Frank, a teen who was captured
in 1944 along with her family by the Nazis as they were hiding in Amsterdam.</p>
<p>The diary starts a few weeks before her family's escape to a warehouse where they
hide for 2 years. Aged 13 when she started penning her entries, the book leaves
a moving and disturbing picture of human behaviour as the families in hiding
fought hunger, unhygenic conditions, loneliness and each other.</p>
<p>Their only contact with the outside world was a radio that relayed news of the
Allies. The progress of the Allies brought them hope but news of stiff
resistance would bring gloom upon the inhabitants of the warehouse.</p>
The Kite Runner2019-08-03T00:00:00+00:002019-08-03T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-08-03:/personal/blog/2019/08/03/the-kite-runner/<p>Generally, I don't pick up books after I have watched it's movie adaptation. I
don't know what was going on in my head when I picked up "The Kite Runner". The
movie moved me to tears and I wasn't sure if I was comfortable revisiting it.</p>
<p>"The Kite Runner" by …</p><p>Generally, I don't pick up books after I have watched it's movie adaptation. I
don't know what was going on in my head when I picked up "The Kite Runner". The
movie moved me to tears and I wasn't sure if I was comfortable revisiting it.</p>
<p>"The Kite Runner" by Khaled Hosseini is the story of Amir and his closest friend
Hassan. Though they are friends, Hassan also happens to be the son of his servant.
The sectarian nature of the then Afghani society complicates their relationship
further.</p>
<p>Amir betrays his friend and lives with that guilt life long. The guilt follows him
to America which has offered him asylum. Many years later he is given a chance at
redeeming himself. Will he take up the chance to make amends with Hassan? Or will
he let his new life in America come in the way?</p>
<p>Both the book and the movie are well done and equally powerful. Choose the medium
that you prefer but do check it out.</p>
The Old Man and the Sea2019-07-28T00:00:00+00:002019-07-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-07-28:/personal/blog/2019/07/28/the-old-man-and-the-sea/<p>This novella by Ernest Hemingway describes the story of an old fisherman and
a marlin. Santiago has had months without a catch and he is written off as
"The unlucky one". His young apprentice is also forbidden by parents from
joining the old man. Though the boy cannot fish with …</p><p>This novella by Ernest Hemingway describes the story of an old fisherman and
a marlin. Santiago has had months without a catch and he is written off as
"The unlucky one". His young apprentice is also forbidden by parents from
joining the old man. Though the boy cannot fish with him, he helps the old
man haul his fishing gear to his home and prepares a meal.</p>
<p>Santiago never gives up and on his eighty fifth day, he manages to catch a fish
but he can't get it onto the boat because it is large and keeps pulling the boat
along. He gets into the long haul and lets the fish tire itself out before trying
to haul it. In the two days before the fish gives up, Santiago's respect for the
fish, his opponent increases. On the way back, the body of the marlin is attacked
by sharks and hardly anything remains by the time he is ashore.</p>
<p>Bruised, tired and famished, Santiago gets home and falls asleep. But he wakes up
next morning with a renewed enthusiasm and promises the boy to fish together once
again like the old times.</p>
Gone Girl2019-07-27T00:00:00+00:002019-07-27T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-07-27:/personal/blog/2019/07/27/gone-girl/<p>"Gone Girl" is an amazing thriller of a wife who goes missing while
planning for her fifth marriage anniversary. The husband finds himself
implicated in her missing. He has to make use of the clues that his
wife has left him in the anniversary treasure hunt to learn more about …</p><p>"Gone Girl" is an amazing thriller of a wife who goes missing while
planning for her fifth marriage anniversary. The husband finds himself
implicated in her missing. He has to make use of the clues that his
wife has left him in the anniversary treasure hunt to learn more about
her and her disappearance.</p>
<p>With an interleaved (husband and wife's accounts) narration and gripping
storyline, this book is a worthwhile read.</p>
One flew over the cuckoo's nest2019-07-17T00:00:00+00:002019-07-17T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-07-17:/personal/blog/2019/07/17/one-flew-over-the-cuckoos-nest/<p>This book had been recommended by many as a good case-study of sociopathic
personalities (people identified their bosses, teachers etc as the Nurse
Ratched in their lives). "One flew over the cuckoo's nest" is set in a
psychiatric facility with Nurse Ratched, an emotionally manipulative nurse,
as the chief overseer …</p><p>This book had been recommended by many as a good case-study of sociopathic
personalities (people identified their bosses, teachers etc as the Nurse
Ratched in their lives). "One flew over the cuckoo's nest" is set in a
psychiatric facility with Nurse Ratched, an emotionally manipulative nurse,
as the chief overseer. She shames her wards into submission to control them.
She goes uncontested until McMurphy, a convict who fakes insanity to escape
prison is admitted. McMurphy tries to instigate his wards to stand up for
themselves and his efforts catch the eye of the nurse who devises some plans
for him. When he learns of them, McMurphy becomes docile and tries to expedite
his discharge from the hospital.</p>
<p>But one cannot keep a gambler subdued for too long and soon things escalate - changing
everyone's life in the ward.</p>
Homodeus2019-07-11T00:00:00+00:002019-07-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-07-11:/personal/blog/2019/07/11/homodeus/<p>"Homodeus: A brief history of tomorrow" is supposed to be the sequel to the
wildly popular Homosapiens by Yuval Noah Harari. As the title suggests, it
is a set of predictions by the author that will elevate the human race to
the level of god (Deus is latin for "god …</p><p>"Homodeus: A brief history of tomorrow" is supposed to be the sequel to the
wildly popular Homosapiens by Yuval Noah Harari. As the title suggests, it
is a set of predictions by the author that will elevate the human race to
the level of god (Deus is latin for "god").</p>
<p>There were hardly any predictions that I agreed with but nevertheless it was
a breezy read.</p>
Einstein: His Life and Universe2019-06-30T00:00:00+00:002019-06-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-06-30:/personal/blog/2019/06/30/einstein-his-life-and-universe/<p>"Einstein: His Life and Universe" is the biography of scientist Albert Einstein
written by Walter Isaacson (who also authored Steve Jobs biography). Generally
one would expect that a lot of focus would be on Einstein's scientific career but
Isaacson devotes far more to Einstein's personal and political life.</p>
<p>I started …</p><p>"Einstein: His Life and Universe" is the biography of scientist Albert Einstein
written by Walter Isaacson (who also authored Steve Jobs biography). Generally
one would expect that a lot of focus would be on Einstein's scientific career but
Isaacson devotes far more to Einstein's personal and political life.</p>
<p>I started this before before I embarked on a long travel and struggled to complete
it during the travel but the journey (both the travel and the book) was worth it.
Einstein's political beliefs highlighted in this book make you wish he was alive
during these times.</p>
The Handmaid's Tale2019-04-30T00:00:00+00:002019-04-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-04-30:/personal/blog/2019/04/30/the-handmaids-tale/<p>"The Handmaid's Tale" is a dystopian novel along the lines of "1984" and "A Brave New World"
with the distinction that it's narrated through the voice of a woman (one largely absent
in the other two books). Offred (a name assigned) is a handmaid to a wife and her primary …</p><p>"The Handmaid's Tale" is a dystopian novel along the lines of "1984" and "A Brave New World"
with the distinction that it's narrated through the voice of a woman (one largely absent
in the other two books). Offred (a name assigned) is a handmaid to a wife and her primary task
is to procreate with the Commander - master of the house. The world is at war not between nation
states but between religious sects and handmaidens are forced into this practise to arrest the
low birth rates. She describes the society and how it's layered while comparing it with the
one in the not so long past. In that past, she was married and had a daughter. She longs
for her family and accepts this position because her other option was to be banished to the
Colonies - polluted wastelands.</p>
<p>Her Commander is sterile and is unable to get her pregnant and she is racing against time as
she could be labelled barren and shipped off to the Colonies. The wife then decides to setup
a forbidden sexual liaison with Nick, a valet to the Commander so that she can have a baby
and bask in the jealousy of the other wives. This relationship is discovered and the police
come for Offred and the ending is open to our imagination.</p>
<p>The book riles up it's readers by describing a highly conservative society where all personal
liberties are forbidden and how women bear most of it's brunt.</p>
Life of Pi2019-04-15T00:00:00+00:002019-04-15T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-04-15:/personal/blog/2019/04/15/life-of-pi/<p>When life gives you no choices, would you still stick to your beliefs and values?
Or let practicality dictate your decisions? "Life of Pi" by Yann Martel explores
these questions through the life of Piscine Patel aka Pi. The Patel family is based
out of Pondicherry and run the city …</p><p>When life gives you no choices, would you still stick to your beliefs and values?
Or let practicality dictate your decisions? "Life of Pi" by Yann Martel explores
these questions through the life of Piscine Patel aka Pi. The Patel family is based
out of Pondicherry and run the city zoo. When the emergency of the 1970s is declared,
the family decides to emigrate to Canada along with a few animals from the zoo. Midway,
the ship sinks mysteriously and Pi is marooned on a life boat with a handful of animals.
One of them is a Royal Bengal Tiger. After a few days, only Pi and the tiger are left
on board. Pi survives nearly an year on board with Richard Parker, the tiger. He is
forced to make a lot of decisions that he previously would have found unpalatable and
uncivilized. But it's a question of survival and a challenge keeping the tiger
alive as long as possible even though it could kill him in an instant if he isn't
cautious.</p>
The Agony and The Ecstacy2019-03-31T00:00:00+00:002019-03-31T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-03-31:/personal/blog/2019/03/31/the-agony-and-the-ecstacy/<p>"The agony and the ecstacy" is a biographical novel written by Irving Stone
on the master sculptor, Michelangelo Buonarroti. Irving Stone relies mostly
on Michelangelo's correspondence and the Buonarroti chroniclers for earlier
history.</p>
<p>Despite being a master marble sculptor, Michelangelo was forced to take
commissions on material he hadn't worked …</p><p>"The agony and the ecstacy" is a biographical novel written by Irving Stone
on the master sculptor, Michelangelo Buonarroti. Irving Stone relies mostly
on Michelangelo's correspondence and the Buonarroti chroniclers for earlier
history.</p>
<p>Despite being a master marble sculptor, Michelangelo was forced to take
commissions on material he hadn't worked with under pressure from popes and
aristocrats. In most cases, the work was abandoned due to the benefactor
dying, going bankrupt or just changing their mind. In some cases, he had to
modify his work midway because the benefactors forced changes even after signing
off on smaller scale wax replicas. The agony of being forced to take up
uninspiring work for clueless benefactors ruined the ecstacy he experienced working
on his ideas with marble.</p>
<p>Despite not having a huge body of work, the few that he could complete are
masterpieces. Imagine if he was given a free hand!</p>
<p>While Michelangelo lived in medieval Italy, I could draw a lot of parallels with
software development - where projects get shelved suddenly due to circumstances
or requirements/goals are changed midway and the frustrated team is forced to
change direction.</p>
Florence: The biography of a city2019-03-22T00:00:00+00:002019-03-22T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-03-22:/personal/blog/2019/03/22/florence-biography-of-city/<p>Another book by Christopher Hibbert and this is mostly a repetition of
"The rise and fall of Medici" with a fast narration before and after the
Medicis. The difference being a little more emphasis on the monuments of
Florence. Possibly a good guide book if you are planning to visit …</p><p>Another book by Christopher Hibbert and this is mostly a repetition of
"The rise and fall of Medici" with a fast narration before and after the
Medicis. The difference being a little more emphasis on the monuments of
Florence. Possibly a good guide book if you are planning to visit.</p>
The House of Medici: Its Rise and Fall2019-03-17T00:00:00+00:002019-03-17T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-03-17:/personal/blog/2019/03/17/the-house-of-medici-its-rise-and-fall/<p>Christopher Hibbert is a historian for the tl;dr (too long; didn't read) generation.
He condenses a huge span of history making it a great starting point to the reader
who otherwise would be lost over where to begin.</p>
<p>The Medici family was one of the most powerful families in …</p><p>Christopher Hibbert is a historian for the tl;dr (too long; didn't read) generation.
He condenses a huge span of history making it a great starting point to the reader
who otherwise would be lost over where to begin.</p>
<p>The Medici family was one of the most powerful families in Florence but their impact
was felt well beyond - throughout Italy and sometimes in neighbouring France. The book
starts in the late 1300s with the story of the founder of the Medici bank and chronicles
the stories of all the Medicis that followed until Cosimo III in the early 18th century.</p>
<p>Apart from the history of the family, there is an emphasis on the villas, art work and
cathedrals commissioned by the family. A lot of their commissions still stand to this day
and this book may act like a mini-guide book.</p>
The Gene: An intimate history2019-03-13T00:00:00+00:002019-03-13T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-03-13:/personal/blog/2019/03/13/the-gene-an-intimate-history/<p>Very few authors have the capability of successfully explaining science to the layperson.
Siddhartha Mukherjee is one of them. His previous book, "The Emperor of All Maladies:
A Biography of Cancer", brought out cancer onto our coffee tables and this brings genetics.
Like in his book on cancer, the author …</p><p>Very few authors have the capability of successfully explaining science to the layperson.
Siddhartha Mukherjee is one of them. His previous book, "The Emperor of All Maladies:
A Biography of Cancer", brought out cancer onto our coffee tables and this brings genetics.
Like in his book on cancer, the author starts with a story, here it is familial - with
uncles being affected by mental diseases that are later discovered to be genetic.</p>
<p>Then he traces the history of scientists and how they stumbled upon the gene and how it
drives almost every aspect of our life. Phase by phase, milestone by milestone he documents
the developments in genetics without getting into too many technical details. And he
concludes the book with the moral conundrum if humans should get into editing genes (eugenics)
to build a better self.</p>
The Long March2019-03-05T00:00:00+00:002019-03-05T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-03-05:/personal/blog/2019/03/05/the-long-march/<p><strong>Disclaimer</strong>: I know the author of this book personally and read an early draft.</p>
<p>When I first read the draft of "The Long March" in 2016, I remember informing Namita that
the ending was too filmy. Boy, some words come back to haunt you! I am glad that she
held …</p><p><strong>Disclaimer</strong>: I know the author of this book personally and read an early draft.</p>
<p>When I first read the draft of "The Long March" in 2016, I remember informing Namita that
the ending was too filmy. Boy, some words come back to haunt you! I am glad that she
held her conviction and didn't change the ending.</p>
<p>"The Long March" is a fictional (with lots borrowed from real life and events) novel
about rural distress in the Vidarbha region of Maharashtra. Vikram Sonare,
is devastated after his father - a heavily indebted farmer commits suicide. He harnesses
the anger amongst the rural youth and the power of social media to start a revolution.</p>
<p>The book is primarily narrated through the character of Mallika Joshi, a social worker
who works in the same region and is inspired by the efforts of Vikram Sonare. The revolution
morphs into a political movement (for a book written between 2008 and 2014, it had lot of
foresight!).</p>
<p>Will Vikram Sonare and Mallika Joshi be able to successfully achieve their goals and awake
people from their indifference? You should read this book to find out the answer.</p>
Atlas Shrugged2019-02-07T00:00:00+00:002019-02-07T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-02-07:/personal/blog/2019/02/07/atlas-shrugged/<p>1200 pages and 47 days! That's the longest it has taken me to complete a book yet.
Atlas Shrugged by Ayn Rand is a fictional story set in the United States of America
where the government has been captured by crony capitalists who lobby to pass laws
that restrict innovation …</p><p>1200 pages and 47 days! That's the longest it has taken me to complete a book yet.
Atlas Shrugged by Ayn Rand is a fictional story set in the United States of America
where the government has been captured by crony capitalists who lobby to pass laws
that restrict innovation and competition to safeguard their fiefs.</p>
<p>Hard working and conscientious businessmen who are hit by these regulations start
vanishing; leaving their businesses imploding. Dagny Taggart, a scion of Taggart
Transcontinental Rails and a ruthless businesswoman who loves competition and free
enterprise is caught in the cross fires of these regulations. She is torn between
protecting her life's ambition of running an efficient rail company and feeding the
looters who have put regulatory restrictions in her tracks.</p>
<p>While Ayn Rand's writing style is beautiful; the book would've been better with
crisper editing. The repetition and the length just dampen the premise of the book
much like the regulations dull the spirit of the businessmen in the novel. The book
reads like propaganda for Capitalism. Not sure how Ayn Rand would've reacted to the
levels of inequality in society today caused by the crony capitalism globally.</p>
Kahlil Gibran Selected Couplets2019-01-13T00:00:00+00:002019-01-13T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2019-01-13:/personal/blog/2019/01/13/kahlil-gibran-selected-couplets/<p>I love Kahlil Gibran's poetry and have been collecting his couplets as I read his
books. Here are a few that I loved:</p>
<ul class="simple">
<li>A little knowledge that acts is worth infinitely more than much knowledge that is idle.</li>
<li>He who does not seek advice is a fool. His folly blinds …</li></ul><p>I love Kahlil Gibran's poetry and have been collecting his couplets as I read his
books. Here are a few that I loved:</p>
<ul class="simple">
<li>A little knowledge that acts is worth infinitely more than much knowledge that is idle.</li>
<li>He who does not seek advice is a fool. His folly blinds him to truth and makes him evil, stubborn and a danger to his fellow man.</li>
<li>The heart's affections are divided like branches of the cedar tree, if the tree loses one strong branch, it will suffer but it does not die. It will pour all of it's vitality into the next branch so that it will grow and fill the empty place.</li>
<li>Not everyone in chains is subdued. At times, a chain is greater than a necklace.</li>
<li>Oh Jesus, they have built these churches for the sake of their own glory, and embellished them with silk and melted gold. They left the bodies of the chosen poor wrapped in tattered raiment in the cold night. They filled the sky with the smoke of burning candles and incense and left the bodies of thy faithful worshippers empty of bread. They raised their voices with hymns of praise, but deafened themselves to the cry and moans of widows and orphans.</li>
<li>Come again, O Living Jesus, and drive the vendors of thy faith from thy sacred temple, for they have turned into a dark cave where vipers or hypocrisy and falsehood crawl and abound.</li>
<li>What is it to be a good citizen? It is to acknowledge the other person's rights before asserting your own, but always to be concious of your own. It is to create the useful and beautiful with your own hands and to admire what others have created in love and with faith. It is to produce by labour and only by labour and to spend less than you have produced that your children may not be dependent upon the state for support when you are no more.</li>
<li>The clergyman erects his temple upon the graves and bones of the devoted worshippers.</li>
<li>We who live amid the excitements of the city know nothing of the life of the mountain villagers. We are swept into the current of urban existence, until forget the peaceful rhythms of simple country life, reap in autumn, rest in winter, imitating nature in all her cycles. What we sow we reap not, they reap what they sow. We are slaves of gain, and they children of contenment. Our draught from the up of life is mixed with bitterness and despair, fear and weariness but they drink the pure vector of life's fulfilment.</li>
<li>For the criminal who is weak and poor the narrow cell of death awaits but honour and glory await the rich who conceal the crimes behind their gold and silver and inherited glory.</li>
<li>Man is like the foam of the sea, that floats upon the surface of the water. When the wind blows, it vanishes, as if it had never been. Thus are our lives blown away by death.</li>
<li>Death is an ending to the son of the earth, but to the soul it is the start, the triumph of life.</li>
<li>Remember, one just man causes the devil greater affliction than a million blind followers.</li>
<li>There is something in our life which is nobler and more supreme than fame, and this something is the great deed that invokes fame.</li>
<li>Are you a governor looking down on those you govern, never stirring abroad except to rifle their pockets or to exploit them for your own profit? If so, you are like tares upon the threshing floor of the nation. Are you a devoted servant who loves the people and is ever watchful over their welfare, and zealous for their success? If so, you are a blessing in the granaries of the land.</li>
<li>Say not, "There goes a learned man". Nor, "There a chieftain dignified". The best of men are in the herd and heed the shepherd as their guide.</li>
<li>Are you a husband who regards the wrongs he committed as lawful, but those of his wife unlawful? If so, you are like those extinct savages who lived in the caves and covered their nakedness with hides. Or are you a faithful companion, whose wife is ever at his side, sharing his every thought, rapture and victory? If so, you are as one who at dawn walks at the head of the nation toward the high moon of justice, reason and wisdom.</li>
<li>Are you a journalist who sells his principles in the market of slaves and who fattens on gossip, misfortune and crime? If so, you are like a ravenous vulture praying upon rotting carrion.</li>
<li>Are you a politician who says to himself: "I will use my country for my own benefit?". If so, you are naught but a parasite living on the flesh of others. Or are you a devoted patriot, who whispers into the ear of his inner self: "I love to serve my country as a faithful servant". If so, you are an oasis in the desert, ready to quench the thirst of the wayfarer.</li>
<li>Progress is not merely improving the past; it is moving forward toward the future.</li>
<li>Great truth that transcends nature does not pass from one being to another by way of human speech. Truth chooses silence to convey her meaning to loving souls.</li>
<li>Whoever would be a teacher of men, let him begin his teaching himself before teaching others; and let him teach by example before teaching by word. For he who teaches himself and rectifies his own ways is more deserving of respect and reverence than he who would teach others and rectify their ways.</li>
<li>In the mouth of the society are many diseased teeth, decayed to the bones of the jaws. But society makes no efforts to have them extracted and be rid of the affliction. It contents itself with gold fillings. Many are the dentists who treat the decayed teeth of the society with glittering gold.</li>
</ul>
Getting Things Done2018-12-30T00:00:00+00:002018-12-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-12-30:/personal/blog/2018/12/30/getting-things-done/<p>Just looking at the title, I decided to take a dive into getting things done
even before I started reading the book. So I started reading the book simultaneously
with other books. And boy was I wrong! Not only does the book clearly discourage
multi-tasking; it took me 3 months …</p><p>Just looking at the title, I decided to take a dive into getting things done
even before I started reading the book. So I started reading the book simultaneously
with other books. And boy was I wrong! Not only does the book clearly discourage
multi-tasking; it took me 3 months to get through the book even though it's fairly
simple.</p>
<p>"Getting Things Done" is a collection of tips by David Allen on improving your
productivity. They are quite simple to read, understand and implement:</p>
<p>1. Make a note of every task that pops into your head and file them. This reduces
the cognitive load and you feel less stressed.</p>
<p>2. Keep going back to this pile of tasks that you keep filing and process them
based on some rules. You could either trash the tasks, defer them to someone else
or for some other time or immediately act upon it if it takes less than 2 minutes.</p>
Saving Capitalism from the Capitalists2018-12-26T00:00:00+00:002018-12-26T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-12-26:/personal/blog/2018/12/26/saving-capitalism-from-capitalists/<p>Raghuram Rajan (former governor of RBI) and Liugi Zingales, a professor
from Chicago's Booth School of Business have written this book to drive
home the point that most capitalistic societies around the world are
mostly crony capitalism; where the incumbents make use of a nascent market
and capture it and …</p><p>Raghuram Rajan (former governor of RBI) and Liugi Zingales, a professor
from Chicago's Booth School of Business have written this book to drive
home the point that most capitalistic societies around the world are
mostly crony capitalism; where the incumbents make use of a nascent market
and capture it and then work their political connections to build a
regulatory moat to protect their fief from upstarts.</p>
<p>The authors lay down the ideal form of capitalism and how financial markets
need to be mature enough for it to succeed. As a part of the prerequisites
for capitalism to succeed:</p>
<ol class="arabic simple">
<li>A government must play an active role in setting up the infrastructure.</li>
<li>A government must honour the right to property.</li>
<li>A government must allow open borders and exercise transparency in flow of information.</li>
<li>A government must invest in retraining and providing safety to the disincentivized (not corporations but workers).</li>
</ol>
<p>The book might sound technical but isn't. They use a lot of historical
events as case studies to explain and use jargon minimally.</p>
Coromandel : A personal history of South India2018-12-13T00:00:00+00:002018-12-13T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-12-13:/personal/blog/2018/12/13/coromandel-a-personal-history-of-south-india/<p>"Ashoka - the search for India's lost emperor" by Charles Allen was a
mind-blowing book that showed how even history can be presented to it's
readers like a thriller. To better such a book is a challenging task and
thankfully Charles Allen sets the tone for the kind of book in …</p><p>"Ashoka - the search for India's lost emperor" by Charles Allen was a
mind-blowing book that showed how even history can be presented to it's
readers like a thriller. To better such a book is a challenging task and
thankfully Charles Allen sets the tone for the kind of book in his
introduction. He puts forward the disclaimer that the book is not
comprehensive but mostly covers aspects of his personal choice.</p>
<p>Starting from the prehistoric ages, Charles Allen discusses the significant
events and stages of history to the south of the Narmada. Most of these
aspects are generally ignored or considered auxiliary like the impact of
Buddhism and Jainism on South India or the history of early Tamil and
Malayalam nations.</p>
<p>Despite the disclaimer, the book is a good starting point for a lot of
people who wish to learn more about South India. At the end, the author
exhorts the reader to go beyond the mainstream interpretations and
appreciate the multi-faceted aspect of Indian culture.</p>
Steve Jobs2018-12-03T00:00:00+00:002018-12-03T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-12-03:/personal/blog/2018/12/03/steve-jobs/<p>Leonardo da Vinci, Benjamin Franklin, Albert Einstein and Henry Kissinger - all
geniuses (possibly debatable). And then when you add Steve Jobs into the list,
you know the author is out to prove a point. Walter Isaacson helms the only
official biography of Steve Jobs, a mercurial genius.</p>
<p>It documents the …</p><p>Leonardo da Vinci, Benjamin Franklin, Albert Einstein and Henry Kissinger - all
geniuses (possibly debatable). And then when you add Steve Jobs into the list,
you know the author is out to prove a point. Walter Isaacson helms the only
official biography of Steve Jobs, a mercurial genius.</p>
<p>It documents the journey of Steve Jobs from his childhood until his demise and
claims to be as unbiased as possible. Isaacson taps a lot of sources from the
various stages of Job's life to reduce the impact of his revisionist recollections.
He has done a good job on this front but still feels like flattery in most portions
of it. Almost every negative episode of Steve Jobs life is mentioned in the book
but is combined with a contrast giving it an apologetic touch.</p>
K.A Nilakanta Sastri - Writings in The Hindu2018-11-20T00:00:00+00:002018-11-20T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-11-20:/personal/blog/2018/11/20/nilakanta-sastri-writings-in-the-hindu/<p><a class="reference external" href="https://en.wikipedia.org/wiki/K._A._Nilakanta_Sastri">K.A Nilakanta Sastri</a> was an Indian historian who specialized in South Indian
history and was an expert in Cholas. The Hindu compiled a list of his best
contributions there and released them as a book.</p>
<p>Most of these essays are from the 1950s and some from the early 60s …</p><p><a class="reference external" href="https://en.wikipedia.org/wiki/K._A._Nilakanta_Sastri">K.A Nilakanta Sastri</a> was an Indian historian who specialized in South Indian
history and was an expert in Cholas. The Hindu compiled a list of his best
contributions there and released them as a book.</p>
<p>Most of these essays are from the 1950s and some from the early 60s and discuss
various aspects of the Tamil Sangam era, the Cholas - their contributions and
conquests and the other significant rulers of South India.</p>
<p>This book has set up the pitch for me to read his other books especially the one
on the Cholas.</p>
The Godfather2018-11-11T00:00:00+00:002018-11-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-11-11:/personal/blog/2018/11/11/the-godfather/<p>Vito Corleone is the head of the Corleone Family in New York City, one of the most
powerful Sicilian families that controls organized crime in the city. He is a friend
to those who seek his help and in turn expects a reasonable favour in return when
the time arrives …</p><p>Vito Corleone is the head of the Corleone Family in New York City, one of the most
powerful Sicilian families that controls organized crime in the city. He is a friend
to those who seek his help and in turn expects a reasonable favour in return when
the time arrives. He is worshipped and feared by his men and foes alike.</p>
<p>An attempt is made on the life of the Don by a rival family and he is indisposed.
A power struggle erupts in the city with the elder son of the Don taking over the
family's businesses and enforcing his will ruthlessly. Other families start facing
the heat and plot to eliminate him. The youngest son of the Don who isn't connected
with the family business gets dragged into this bloody affair and has to flee the
country. The elder son is assassinated during an operation and the Don has to step
in to take back control. He gathers all the families and threshes out a peace plan
to prevent more bloodshed. In the meantime, he makes arrangements to get his youngest
son back and succeed in the family business.</p>
<p>Will Micheal Corleone, the youngest of the sons, stays true to his Sicilian blood
and avenge his family or abide by his father's peace deal with the Mafiosa like
an obedient Sicilian son?</p>
Delivering Happiness2018-10-30T00:00:00+00:002018-10-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-10-30:/personal/blog/2018/10/30/delivering-happiness/<p>I generally don't pick business books unless it is highly recommended. "Delivering
Happiness" by Tony Hsieh was recommended by a manager at one of my previous workplaces.
Tony Hsieh documents the story of Zappos, an online footwear retailer until it's
acquisition by Amazon. The primary focus of this book is …</p><p>I generally don't pick business books unless it is highly recommended. "Delivering
Happiness" by Tony Hsieh was recommended by a manager at one of my previous workplaces.
Tony Hsieh documents the story of Zappos, an online footwear retailer until it's
acquisition by Amazon. The primary focus of this book is on the values that guide the
company, how they were framed and their role in the company's success. The lode star of
the company is "delivering great customer experience to wow the user" and Tony Hsieh
quotes multiple anecdotes to showcase this.</p>
Ranjit Singh: Maharaja of Punjab2018-10-14T00:00:00+00:002018-10-14T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-10-14:/personal/blog/2018/10/14/ranjit-singh-maharaja-punjab/<p>Khushwant Singh, a noted author pens the biography of Ranjit Singh, referred to
as 'The Lion of Punjab' by the Sikhs. He was the first king to have unified the
Punjab and built a huge empire. The book documents the events in Ranjit Singh's
life chronologically with a lot of …</p><p>Khushwant Singh, a noted author pens the biography of Ranjit Singh, referred to
as 'The Lion of Punjab' by the Sikhs. He was the first king to have unified the
Punjab and built a huge empire. The book documents the events in Ranjit Singh's
life chronologically with a lot of focus on the battles and his negotiations with
the British. It doesn't cover details like administration, economy or elaborate
on the king's character.</p>
The Last Lecture2018-10-08T00:00:00+00:002018-10-08T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-10-08:/personal/blog/2018/10/08/the-last-lecture/<p>Randy Pausch's "The Last Lecture" may not be as evocative and stylish as Paul
Kalanithi's "When Breath Becomes Air" but is heart-breaking nevertheless.
He was a professor at the computer science department at Carnegie Mellon when
he was diagnosed with pancreatic cancer that later metastized into the liver.
Randy delivered …</p><p>Randy Pausch's "The Last Lecture" may not be as evocative and stylish as Paul
Kalanithi's "When Breath Becomes Air" but is heart-breaking nevertheless.
He was a professor at the computer science department at Carnegie Mellon when
he was diagnosed with pancreatic cancer that later metastized into the liver.
Randy delivered "The Last Lecture" not only as a way of helping students
achieve their dreams but also communicating with his kids when they grow up.
The lecture became a hit and was viewed by millions, prompting Randy to
write a book offering more details that he couldn't accommodate in the lecture.</p>
An Era of Darkness2018-09-30T00:00:00+00:002018-09-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-09-30:/personal/blog/2018/09/30/an-era-of-darkness/<p>"An Era of Darkness" sprung out of a popular lecture by Shashi Tharoor in London.
This speech was appreciated by a lot of Indians even across the political spectrum
but caused some stir amongst the English. To address these, the author deemed it
fit to write a book as it …</p><p>"An Era of Darkness" sprung out of a popular lecture by Shashi Tharoor in London.
This speech was appreciated by a lot of Indians even across the political spectrum
but caused some stir amongst the English. To address these, the author deemed it
fit to write a book as it served a better medium. The main argument of the book
is that the English need to own up to the misdeeds of their colonial past and
make reparations to the Indians. He primarily addresses the points of the English
historians and Anglophiles who claim that the English gave a lot to India and
it is India that should be grateful to Her Majesty.</p>
The Book Thief2018-09-16T00:00:00+00:002018-09-16T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-09-16:/personal/blog/2018/09/16/the-book-thief/<p>Lisa is on the cusp of adolescence while she is put up for adoption by Nazi
authorities and finds herself in the home of Hans and Rosa Hubermann. She is
confused as to why she has to live with her foster parents when her mom is alive.
After settling into …</p><p>Lisa is on the cusp of adolescence while she is put up for adoption by Nazi
authorities and finds herself in the home of Hans and Rosa Hubermann. She is
confused as to why she has to live with her foster parents when her mom is alive.
After settling into her foster home, she takes a liking for her adopted parents.
She makes new friends and when not playing with them, learns to read with her dad.
She loves the exhilarating feeling that books give her and begins to lift them
(books apart from Nazi propaganda were banned in Germany then) from the house of
an influential Nazi politician who was probably exempt from the rule. The books
help her maintain sanity during the trying war and assist in the blossoming
of a special relationship with Max, a Jew being hidden from the Nazi authorities
by Lisa's parents in their basement. Do the Nazi authorities capture Max and
punish the Hubermann family?</p>
<p>Death has a special role as that of a narrator and sympathetic spectator.</p>
Importing OpenStreetMap data into Postgresql2018-09-14T00:00:00+00:002018-09-14T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-09-14:/tech/blog/2018/09/14/import-openstreetmap-postgresql/<p>I had the requirement of extracting hospitals from <a class="reference external" href="https://openstreetmap.org/">OpenStreetMap</a> into <a class="reference external" href="https://postgresql.org/">Postgresql</a>
so that some data analysts could run some scripts off it.</p>
<p>I fired up an AWS EC2 server (t3.large) running Ubuntu and installed the <cite>awscli</cite>
package and configured it using my AWS Key and Secret Key.</p>
<pre class="code bash literal-block">
sudo apt-get …</pre><p>I had the requirement of extracting hospitals from <a class="reference external" href="https://openstreetmap.org/">OpenStreetMap</a> into <a class="reference external" href="https://postgresql.org/">Postgresql</a>
so that some data analysts could run some scripts off it.</p>
<p>I fired up an AWS EC2 server (t3.large) running Ubuntu and installed the <cite>awscli</cite>
package and configured it using my AWS Key and Secret Key.</p>
<pre class="code bash literal-block">
sudo apt-get install awscli
aws configure
</pre>
<p>Then I downloaded the PBF file from AWS S3 (you don't incur a charge if downloaded
from S3 if you are using EC2)</p>
<pre class="code bash literal-block">
aws s3 cp s3://osm-pds/2018/planet-180903.osm.pbf .
</pre>
<p>The file size was about 42GB and took 20 minutes to download. Next, I used <a class="reference external" href="https://github.com/omniscale/imposm3">Imposm3</a>
instead of <a class="reference external" href="https://wiki.openstreetmap.org/wiki/Osm2pgsql">Osm2pgsql</a> to read the PBF file and import into postgresql server.</p>
<pre class="code bash literal-block">
imposm import -config config.json -appendcache -read planet-180903.osm.pbf -write
</pre>
<p>The <cite>config.json</cite> specified the database and mapping parameters.</p>
<pre class="code json literal-block">
<span class="p">{</span>
<span class="nt">"cachedir"</span><span class="p">:</span> <span class="s2">"/home/ubuntu/cache"</span><span class="p">,</span>
<span class="nt">"connection"</span><span class="p">:</span> <span class="s2">"postgis://osm:osm@localhost:5432/osm"</span><span class="p">,</span>
<span class="nt">"mapping"</span><span class="p">:</span> <span class="s2">"mapping.json"</span><span class="p">,</span>
<span class="nt">"srid"</span><span class="p">:</span> <span class="mi">4326</span>
<span class="p">}</span>
</pre>
<p>Since I was only interested in the location of hospitals and didn't require other tags
or admin boundaries, relations etc, this is how my <cite>mapping.json</cite> looked.</p>
<pre class="code json literal-block">
<span class="p">{</span>
<span class="nt">"tags"</span><span class="p">:</span> <span class="p">{</span><span class="nt">"load_all"</span><span class="p">:</span> <span class="kc">true</span><span class="p">},</span>
<span class="nt">"tables"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"amenities"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"columns"</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"id"</span><span class="p">,</span>
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"osm_id"</span><span class="p">,</span>
<span class="nt">"key"</span><span class="p">:</span> <span class="kc">null</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"geometry"</span><span class="p">,</span>
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"geometry"</span><span class="p">,</span>
<span class="nt">"key"</span><span class="p">:</span> <span class="kc">null</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"string"</span><span class="p">,</span>
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"name"</span><span class="p">,</span>
<span class="nt">"key"</span><span class="p">:</span> <span class="s2">"name"</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"mapping_value"</span><span class="p">,</span>
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"type"</span><span class="p">,</span>
<span class="nt">"key"</span><span class="p">:</span> <span class="kc">null</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"hstore_tags"</span><span class="p">,</span>
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"tags"</span><span class="p">,</span>
<span class="nt">"key"</span><span class="p">:</span> <span class="s2">"tags"</span>
<span class="p">}</span>
<span class="p">],</span>
<span class="nt">"type"</span><span class="p">:</span> <span class="s2">"polygon"</span><span class="p">,</span>
<span class="nt">"mapping"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"amenity"</span><span class="p">:</span> <span class="p">[</span>
<span class="s2">"hospital"</span>
<span class="p">]</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
</pre>
<p>The <cite>imposm import</cite> command took nearly 19 hours to import the data into postgresql.
You can push the data into the <cite>public</cite> schema using the <cite>-deploytoproduction</cite> flag
or just use the <cite>import</cite> schema if you are comfortable with it.</p>
<p>Additionally, I exported the data from the <cite>osm_amenities</cite> table into a json file
(a json line for every row in the table) using the following PSQL command:</p>
<pre class="code sql literal-block">
<span class="k">COPY</span> <span class="p">(</span><span class="k">SELECT</span> <span class="n">row_to_json</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
<span class="k">FROM</span> <span class="p">(</span><span class="k">SELECT</span> <span class="n">id</span><span class="p">,</span> <span class="n">osm_id</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="k">type</span><span class="p">,</span>
<span class="n">hstore_to_json</span><span class="p">(</span><span class="n">tags</span><span class="p">)</span> <span class="k">as</span> <span class="n">tags</span><span class="p">,</span>
<span class="n">ST_AsGeoJSON</span><span class="p">(</span><span class="n">geometry</span><span class="p">)::</span><span class="n">json</span> <span class="k">as</span> <span class="n">geometry</span>
<span class="k">FROM</span> <span class="n">import</span><span class="p">.</span><span class="n">osm_amenities</span><span class="p">)</span> <span class="n">t</span>
<span class="p">)</span>
<span class="k">TO</span> <span class="s1">'/tmp/output.json'</span><span class="p">;</span>
</pre>
My Muttrc2018-09-13T00:00:00+00:002018-09-13T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-09-13:/tech/blog/2018/09/13/my-muttrc/<p>I have been using <a class="reference external" href="http://www.mutt.org/">Mutt</a>, a text-based email client for ages for some self-hosted
email that I use internally. Someone recently asked me to share my <cite>.muttrc</cite> and
so here goes:</p>
<pre class="code text literal-block">
set editor = "emacs -nw"
set mbox_type=Maildir
set mbox="~/Mail/Inbox"
set spoolfile="~/Mail/Inbox"
set folder="~/Mail/"
set …</pre><p>I have been using <a class="reference external" href="http://www.mutt.org/">Mutt</a>, a text-based email client for ages for some self-hosted
email that I use internally. Someone recently asked me to share my <cite>.muttrc</cite> and
so here goes:</p>
<pre class="code text literal-block">
set editor = "emacs -nw"
set mbox_type=Maildir
set mbox="~/Mail/Inbox"
set spoolfile="~/Mail/Inbox"
set folder="~/Mail/"
set record="~/Mail/Sent/"
set postponed="~/Mail/Drafts"
unset record
set my_pass = "password"
set my_user = "username"
set my_host = "example.com"
set realname = "John Doe"
set pop_user = $my_user
set pop_pass = $my_pass
set pop_host = $my_host
set pop_host = pops://$pop_user:$pop_pass@$pop_host
set from = "username@example.com"
set use_from = yes
set envelope_from = yes
set smtp_url = smtp://$my_user:$my_pass@$my_host:25/
set ssl_starttls = yes
set ssl_force_tls = yes
set ssl_verify_host = no
</pre>
A People's History of the United States2018-08-31T00:00:00+00:002018-08-31T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-08-31:/personal/blog/2018/08/31/a-peoples-history-of-the-united-states/<p>"History is written by the victors" goes a famous quote. Every reading of history
should be treated with some scepticism. "A People's History of the United States"
written by Howard Zinn narrates history not through the government's propaganda
but through common people's movements.</p>
<p>The book opens with Christopher Columbus' armada …</p><p>"History is written by the victors" goes a famous quote. Every reading of history
should be treated with some scepticism. "A People's History of the United States"
written by Howard Zinn narrates history not through the government's propaganda
but through common people's movements.</p>
<p>The book opens with Christopher Columbus' armada reaching the shores of the Americas.
Official sources will claim this as a historical event that changed the world and
honour this hero. But the same event through the view of the native Americans will
reveal widespread genocide.</p>
<p>The English start settling and expanding from the north-eastern shores to the west
while constantly displacing and destroying the natives. The settlers slowly become
politically concious and rebel against the Queen to gain independence. The "founding
fathers" (most of whom happened to be landed and slave owners) framed a constitution
that safeguarded the elite's interests.</p>
<p>Even before the independence, ship loads of slaves from Africa were being brought in
by the rich land owners to work on their farms. The southern states of the US' rebelled
over a proposal to ban slavery and the American Civil war broke out.</p>
<p>Within a few decades, the country was pulled into the First World War and upon
conclusion, it's economy was in dire straits and culminated in the Great Depression.
They slowly crept out of it only to get dragged into the Second World War which ended
with the dropping of nuclear bombs on Japan.</p>
<p>After that it regularly flirted with wars in Vietnam, Cambodia, Korea, Kuwait, Iraq etc.</p>
<p>The book dives deep into the class-aspect of history. How the poor and the working
class were disenfranchised from the beginning. Their struggles to get their voice
heard and how administration after administration failed to make any difference.</p>
<p>The author admits that this book is biased; tilted in favour of the oppressed and
goes against the grain. But it gives a new perspective into how we understand
history.</p>
Port Forwarding with HAProxy2018-08-11T00:00:00+00:002018-08-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-08-11:/tech/blog/2018/08/11/port-forwarding-with-haproxy/<p>I recently acquired a beefy bare-metal server and wanted to run a bunch of services
within VMs based on KVM managed by libvirt. Only ports 80 and 443 for these VMs would
be exposed and the rest of the ports (say SSH) visible only from the internal network.</p>
<p>Initially, I …</p><p>I recently acquired a beefy bare-metal server and wanted to run a bunch of services
within VMs based on KVM managed by libvirt. Only ports 80 and 443 for these VMs would
be exposed and the rest of the ports (say SSH) visible only from the internal network.</p>
<p>Initially, I just thought of going with Nginx because I was familiar with it. But I had
heard a lot about HAProxy and wanted to give it a shot.</p>
<p>I had libvirt assign a static IPv4 address for each VM and then used that to correctly
forward the terminated TLS connection at HAProxy.</p>
<p>Here's the libvirt network configuration:</p>
<pre class="code xml literal-block">
<span class="nt"><network></span>
<span class="nt"><name></span>default<span class="nt"></name></span>
<span class="nt"><uuid></span>{uuid}<span class="nt"></uuid></span>
<span class="nt"><forward</span> <span class="na">mode=</span><span class="s">'nat'</span><span class="nt">/></span>
<span class="nt"><bridge</span> <span class="na">name=</span><span class="s">'virbr0'</span> <span class="na">stp=</span><span class="s">'on'</span> <span class="na">delay=</span><span class="s">'0'</span><span class="nt">/></span>
<span class="nt"><mac</span> <span class="na">address=</span><span class="s">'52:54:00:34:12:10'</span><span class="nt">/></span>
<span class="nt"><ip</span> <span class="na">address=</span><span class="s">'192.168.122.1'</span> <span class="na">netmask=</span><span class="s">'255.255.255.0'</span><span class="nt">></span>
<span class="nt"><dhcp></span>
<span class="nt"><range</span> <span class="na">start=</span><span class="s">'192.168.122.2'</span> <span class="na">end=</span><span class="s">'192.168.122.254'</span><span class="nt">/></span>
<span class="nt"><host</span> <span class="na">mac=</span><span class="s">'52:54:00:a9:2c:0b'</span> <span class="na">name=</span><span class="s">'vm1'</span> <span class="na">ip=</span><span class="s">'192.168.122.2'</span><span class="nt">/></span>
<span class="nt"><host</span> <span class="na">mac=</span><span class="s">'52:54:00:a9:2c:0c'</span> <span class="na">name=</span><span class="s">'vm2'</span> <span class="na">ip=</span><span class="s">'192.168.122.3'</span><span class="nt">/></span>
...
<span class="nt"></dhcp></span>
<span class="nt"></ip></span>
<span class="nt"></network></span>
</pre>
<p>I then created VMs with the above host mac addresses and the corresponding IP address got
attached.</p>
<p>The HAProxy config was as below:</p>
<pre class="code text literal-block">
frontend http
bind :::80 v4v6
bind :::443 v4v6 ssl crt-list /home/fedora/ssl-list.txt
mode http
option forwardfor
option http-server-close
redirect scheme https if !{ ssl_fc }
use_backend vm1_example if { req.ssl_sni -i vm1.example.com }
use_backend vm1_example if { hdr(Host) -i vm1.example.com }
use_backend vm2_example if { req.ssl_sni -i vm2.example.com www.vm2.example.com }
use_backend vm2_example if { hdr(Host) -i vm2.example.com www.vm2.example.com }
backend vm1_example
server vm1 192.168.122.2:80 maxconn 32
backend vm2_example
server vm2 192.168.122.3:80 maxconn 32
</pre>
<p>HAProxy forwards the HTTP connections either based on the SNI (if supported by your SSL
certificate provider) or the HTTP Header.</p>
<p>The <cite>ssl-list.txt</cite> file held the location of the SSL certificates (thanks LetsEncrypt):</p>
<pre class="code text literal-block">
/etc/letsencrypt/live/vm1.example.com/full_cert.pem vm1.example.com
/etc/letsencrypt/live/vm2.example.com/full_cert.pem vm2.example.com www.vm2.example.com
</pre>
<p>Later on, I ran an SMTP server within it's own VM and port-forwarded to it as well.
The HAProxy configuration file had the following lines appended to it:</p>
<pre class="code text literal-block">
frontend smtpd
bind :::25 v4v6
mode tcp
no option http-server-close
timeout client 1m
log global
option tcplog
default_backend smtp
backend smtp
mode tcp
no option http-server-close
log global
option tcplog
timeout server 1m
timeout connect 5s
server postfix 192.168.122.4:25 send-proxy
</pre>
Shantaram2018-07-28T00:00:00+00:002018-07-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-07-28:/personal/blog/2018/07/28/shantaram/<p>Looks can be deceptive. Very deceptive. When some villagers name the protagonist
"Shantaram" after his calm nature, little idea did they have of his fierce past.
Shantaram tries hard to melt into his surroundings and maintain a low-key but keeps
getting into trouble.</p>
<p>Gregory David Roberts, the author, embellishes his …</p><p>Looks can be deceptive. Very deceptive. When some villagers name the protagonist
"Shantaram" after his calm nature, little idea did they have of his fierce past.
Shantaram tries hard to melt into his surroundings and maintain a low-key but keeps
getting into trouble.</p>
<p>Gregory David Roberts, the author, embellishes his life events to build the story.
He escapes prison in Australia and flies to India under an assumed name (Lin) to
lay low for a while before escaping to Europe. He meets an unreserved tourist
guide, Prabhakar who becomes a dear friend. After a robbery, Lin loses all his
money and relocates to a slum in Mumbai. During the course of his stay, he gets
acquainted with a lot of foreigners, an underworld don - Abdel Khader
Khan, being one of them. Due to some unforeseen circumstances, he ends up in
Arthur road prison where he faces abuse that almost leaves him dead before he is
rescued by Khader Khan. Lin dedicates his life to the don and blindly follows him
to Afghanistan to help the mujahideen liberate the country from the Soviets. This
trip opens his eyes and he realises that he has become someone he loathes. He resolves
to return and reset his life.</p>
<p>The novel is over 900 pages and protracted. There were many instances where I felt
like dropping the book but carried on hoping for a satisfying experience at the end.
While I didn't feel so after I was done, it wasn't lousy either.</p>
When breath becomes air2018-06-11T00:00:00+00:002018-06-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-06-11:/personal/blog/2018/06/11/when-breath-becomes-air/<p>What would you do if you are informed that you are dying (no timeline provided)?
Would you continue working towards your dream? Or give up and spend the rest of
the time cursing your fate?</p>
<p>Paul Kalanithi is close to completing his neurosurgeon residency at Stanford. He
has worked hard …</p><p>What would you do if you are informed that you are dying (no timeline provided)?
Would you continue working towards your dream? Or give up and spend the rest of
the time cursing your fate?</p>
<p>Paul Kalanithi is close to completing his neurosurgeon residency at Stanford. He
has worked hard all his life to get here but is diagnosed with terminal lung
cancer. As a doctor he knows his chances are bleak but his doctors (who were
colleagues until the diagnosis) try to motivate him. The diagnosis exacerbates
his family life (already strained due to the long hours at the hospital). He
pulls through with a lot of positivity and support from family and friends.
When the first round of treatment appears to be working, he gets back to medical
practise. But he realises he is a shade of his past and it's only a matter of
time before the impending eventuality.</p>
<p>While the book discusses morbidity, Paul the writer is lively and his writing
spirited.</p>
Mahashweta2018-06-08T00:00:00+00:002018-06-08T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-06-08:/personal/blog/2018/06/08/mahashweta/<p>Dr.Anand falls in love with Anupama and it appears to be progressing like a fairy
tale. After marriage, her husband leaves to England for higher studies and she
is expected to follow him shortly. But she is diagnosed with Vitiligo and is
shunted out of her in-laws and parents …</p><p>Dr.Anand falls in love with Anupama and it appears to be progressing like a fairy
tale. After marriage, her husband leaves to England for higher studies and she
is expected to follow him shortly. But she is diagnosed with Vitiligo and is
shunted out of her in-laws and parents. She moves to Mumbai with the help of
her friend and starts working as a lecturer. Does her husband (unaware of her
condition) come back and reconcile? Or does she find her true life partner?</p>
On the Origin of Species2018-06-01T00:00:00+00:002018-06-01T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-06-01:/personal/blog/2018/06/01/on-the-origin-of-species/<p>I have heard of the phrase "Survival of the fittest" since childhood in contexts
unrelated to Charles Darwin's (this phrase was added in a later edition) usage.
It always piqued my curiousity on how he (and some people before him) proposed
this revolutionary idea. They didn't observe the evolution of …</p><p>I have heard of the phrase "Survival of the fittest" since childhood in contexts
unrelated to Charles Darwin's (this phrase was added in a later edition) usage.
It always piqued my curiousity on how he (and some people before him) proposed
this revolutionary idea. They didn't observe the evolution of any species. Nor
could they run experiments in the lab.</p>
<p>It turns out that this influential and still controversial theory 'evolved'
out of hundreds of anecdotal observations! This book describes the evidence Darwin
and other naturalists collected over decades and the resulting facts and inferences.
This is a multi-part book and finished after more than two months of arduous reading.</p>
Pakistan; or the partition of India2018-03-29T00:00:00+00:002018-03-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-03-29:/personal/blog/2018/03/29/pakistan-partition-of-india/<p>Every person in the Indian subcontinent is aware of the misery caused by the partition
of India. A lot of people believe that the Indian Congress Party and the first Prime
Minister of India were responsible. They insist that the partition could have been
avoided and history would've been kinder …</p><p>Every person in the Indian subcontinent is aware of the misery caused by the partition
of India. A lot of people believe that the Indian Congress Party and the first Prime
Minister of India were responsible. They insist that the partition could have been
avoided and history would've been kinder.</p>
<p>Dr.Ambedkar analyses this question dispassionately through historical events (division of
Greece), data (army recruitment numbers, tax revenues) and the legitimacy and feasibility
of demands by the Muslim League and the Indian Congress.</p>
<p>I won't go into the solutions proposed by him but those would have earned him the
'anti-national' tag if he were alive today.</p>
The Bourne Identity2018-03-13T00:00:00+00:002018-03-13T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-03-13:/personal/blog/2018/03/13/the-bourne-identity/<p>Countless number of times people have recommended this book but I pushed back by
claiming that this book didn't fit my interests. Recently I realised that my reading
has been wide-ranging and I don't have a favourite genre.</p>
<p>A man is found almost dead by fishermen in the middle of …</p><p>Countless number of times people have recommended this book but I pushed back by
claiming that this book didn't fit my interests. Recently I realised that my reading
has been wide-ranging and I don't have a favourite genre.</p>
<p>A man is found almost dead by fishermen in the middle of the sea. A doctor nurses him
and realizes that his patient has amnesia and has no recollections. A negative film
print embedded in him could be the only way to learn of his identity. How this clue
helps him unravel his identity forms the pacy story of "The Bourne Identity".</p>
Mein Kampf2018-02-28T00:00:00+00:002018-02-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-02-28:/personal/blog/2018/02/28/mein-kampf/<p>Sometimes one just needs to read history without being judgemental to appreciate
the context. It puts certain things into perspective. You don't necessarily have
to take a stand but only use it to expand your realm.</p>
<p>Mein Kampf is Adolf Hitler's autobiography. The book traces his journey from his
childhood …</p><p>Sometimes one just needs to read history without being judgemental to appreciate
the context. It puts certain things into perspective. You don't necessarily have
to take a stand but only use it to expand your realm.</p>
<p>Mein Kampf is Adolf Hitler's autobiography. The book traces his journey from his
childhood, stint in the German army during the first World War and political
debut into the National Socialist German Workers' Party (popularly known as the
Nazi Party). He uses the book (authored in 1925 after the WW-I and a decade and half
before WW-II) to discuss domestic and foreign policy shortcomings and his solutions
to them.</p>
<p>Some of his proposals in the books make a lot of sense but then he doubles down
with outlandish ones diluting the essence. Take the example of proposing sports as
a subject in school and where physical activity would get as much weightage as the
other subjects. But then follows it up with an idea that women should discontinue
education after school and get into maternal training and dedicate themselves to
nation-building through child rearing (born out of the blood of pure German race)!</p>
Aurangzeb: The man and the myth2018-01-25T00:00:00+00:002018-01-25T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-01-25:/personal/blog/2018/01/25/aurangzeb-the-man-and-myth/<p>History shouldn't be used to judge even though a lot of people claim
that history should be the best judge. To judge a historical period, one
must also factor in the context then. Without appreciating the context,
one may end up distorting history. Aurangzeb is probably the most hated
Mughal …</p><p>History shouldn't be used to judge even though a lot of people claim
that history should be the best judge. To judge a historical period, one
must also factor in the context then. Without appreciating the context,
one may end up distorting history. Aurangzeb is probably the most hated
Mughal for exactly this reason. He is hated by Hindus, Sikhs and Muslims
alike!</p>
<p>Audrey Truschke, a professor in history cites various historical sources
to build the context and leaves the judgement to the readers.</p>
The Great Gatsby2018-01-20T00:00:00+00:002018-01-20T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-01-20:/personal/blog/2018/01/20/the-great-gatsby/<p>When the going is good, everyone is 'friends' with you. But when the first
signs of trouble appear, only the true friends remain. "The Great Gatsby"
is a novel by Scott Fitzgerald that mashes friendship, love and betrayal
in a story set in America in the 1920s (post the World …</p><p>When the going is good, everyone is 'friends' with you. But when the first
signs of trouble appear, only the true friends remain. "The Great Gatsby"
is a novel by Scott Fitzgerald that mashes friendship, love and betrayal
in a story set in America in the 1920s (post the World War-I).</p>
<p>While a lot of novels may cover the above themes, this one narrates a
credible story using fictitious location and characters. By the end of the
story, one can feel a strong feeling of sympathy for the main character, Gatsby
and a disgust at some of the other characters.</p>
My inventions: Autobiography of Nikola Tesla2018-01-16T00:00:00+00:002018-01-16T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-01-16:/personal/blog/2018/01/16/my-inventions-autobiography-nikola-tesla/<p>Nikola Tesla may not be as famous as his contemporary Thomas Edison but his
inventions (like the AC motor and his experiments in telephony) have had larger
impact than Edison's.</p>
<p>If you keep the descriptions of his inventions aside, Tesla was an interesting
character. He was a polyglot, believed in …</p><p>Nikola Tesla may not be as famous as his contemporary Thomas Edison but his
inventions (like the AC motor and his experiments in telephony) have had larger
impact than Edison's.</p>
<p>If you keep the descriptions of his inventions aside, Tesla was an interesting
character. He was a polyglot, believed in quite a few pseudo-scientific
beliefs like chastity kept his scientific acumen sharp, claiming that 2-3 hours
of sleep was sufficient etc, authored multiple books and articles, cultivated
hobbies and was good friends with famous personalities like Mark Twain.</p>
Three thousand stitches2018-01-13T00:00:00+00:002018-01-13T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-01-13:/personal/blog/2018/01/13/three-thousand-stitches/<p>"Three Thousand Stitches" is a collection of short stories by Sudha Murthy.
Unlike her other short story books I have read, most of the stories here are
anecdotes from her life and sound vain and righteous. Decent for a quick read.</p>
Who moved my cheese?2018-01-11T00:00:00+00:002018-01-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-01-11:/personal/blog/2018/01/11/who-moved-my-cheese/<p>The tagline of the book is "An amazing way to deal with change in your work
and life" and summarizes the book perfectly. Dr Spencer Johnson creates four
fictitious characters (2 humans and 2 mice) who are stuck in a maze trying to
locate their cheese. One day, their cheese …</p><p>The tagline of the book is "An amazing way to deal with change in your work
and life" and summarizes the book perfectly. Dr Spencer Johnson creates four
fictitious characters (2 humans and 2 mice) who are stuck in a maze trying to
locate their cheese. One day, their cheese vanishes from it's usual location
and hell breaks loose for the humans. The mice don't while away time lamenting
but head on an expedition to locate newer sources of cheese. The humans
(over-)analyze the situation and get into a blame game. Only when hunger kicks
in do they set out to find their cheese.</p>
<p>The last page of the book ends with a message:</p>
<ul class="simple">
<li><strong>Change Happens</strong>: They keep moving the cheese</li>
<li><strong>Anticipate Change</strong>: Get ready for the cheese to move</li>
<li><strong>Monitor Change</strong>: Smell the cheese often so you know when it's getting old</li>
<li><strong>Adapt to Change quickly</strong>: The quicker you let go of old cheese, the sooner you can enjoy new cheese</li>
<li><strong>Change</strong>: Move with the cheese</li>
<li><strong>Enjoy Change!</strong>: Savor the adventure and enjoy the taste of new cheese</li>
<li><strong>Be ready to Change quickly and Enjoy again</strong>: They keep moving the cheese</li>
</ul>
Common Sense2018-01-10T00:00:00+00:002018-01-10T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-01-10:/personal/blog/2018/01/10/common-sense/<p>Why should the US claim independence from Great Britain? Well, it was "Common
Sense" according to Thomas Paine, one of the founders of America. In this
pamphlet later converted into a book, Thomas Paine lists out the various
reasons for ceding from Britain and taking the next steps towards drafting …</p><p>Why should the US claim independence from Great Britain? Well, it was "Common
Sense" according to Thomas Paine, one of the founders of America. In this
pamphlet later converted into a book, Thomas Paine lists out the various
reasons for ceding from Britain and taking the next steps towards drafting a
constitution and forming a government. This is a well thought out document
and it's more fascinating to observe how much America has drifted away from
these ideals and become an 'elitist' republic!</p>
Who were the Shudras?2018-01-06T00:00:00+00:002018-01-06T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2018-01-06:/personal/blog/2018/01/06/who-were-the-shudras/<p>How does one expose the hypocrisy of an orthodoxy? By studying their sources of
'truth' and invalidate them. That's the approach taken by BR Ambedkar in his book
"Who were the Shudras?". He quotes the Vedas and other scriptures to demonstrate
tampering and selective reading as a basis to prop …</p><p>How does one expose the hypocrisy of an orthodoxy? By studying their sources of
'truth' and invalidate them. That's the approach taken by BR Ambedkar in his book
"Who were the Shudras?". He quotes the Vedas and other scriptures to demonstrate
tampering and selective reading as a basis to prop up the caste system. In addition,
he cites scientific studies (one theory regarding the head size which has since been
debunked) to prove the origin of the Shudras and put the Aryan invasion theory to
doubt. Quite a hard-hitting book!</p>
On Nationalism2017-12-29T00:00:00+00:002017-12-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-12-29:/personal/blog/2017/12/29/on-nationalism/<p>"On Nationalism" is a collection of essays by historian Romila Thapar,
jurist AG Noorani and journalist Sadanand Menon. The JNU sedition row
of 2016 prompted these personalities to pen down their thoughts on the
concept of nationalism and how vested interests misuse it (not just
restricted to India but a …</p><p>"On Nationalism" is a collection of essays by historian Romila Thapar,
jurist AG Noorani and journalist Sadanand Menon. The JNU sedition row
of 2016 prompted these personalities to pen down their thoughts on the
concept of nationalism and how vested interests misuse it (not just
restricted to India but a global phenomenon) to push their agenda.</p>
The temple tiger and more man-eaters of Kumaon2017-12-25T00:00:00+00:002017-12-25T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-12-25:/personal/blog/2017/12/25/temple-tiger-man-eaters-kumaon/<p>I was aware of Jim Corbett's role as a conservationist where he spent a
large portion of his life trying to save the tiger in the United Provinces
(currently the state of Uttarakhand) but little did I know that he
started off as a hunter. He would be commissioned by …</p><p>I was aware of Jim Corbett's role as a conservationist where he spent a
large portion of his life trying to save the tiger in the United Provinces
(currently the state of Uttarakhand) but little did I know that he
started off as a hunter. He would be commissioned by the British government
(pre-independence) to put down man-eaters.</p>
<p>"The Temple Tiger and more man-eaters of Kumaon" is a collection of short-stories
where he recollects his encounters with the beasts that wreaked havoc and terrified
the villagers from the hilly region of Uttarakhand.</p>
Postfix SMTP Delegation2017-12-23T00:00:00+00:002017-12-23T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-12-23:/tech/blog/2017/12/23/postfix-smtp-delegation/<p>Email still continues to be a popular communication and collaboration tool
especially within enterprises. And Postfix (configurable SMTP server) has
withstood the test of time and remains popular.</p>
<p>Programmable SMTP servers like Haraka, Lamson make building applications
on top of email easy but I am not comfortable exposing them as …</p><p>Email still continues to be a popular communication and collaboration tool
especially within enterprises. And Postfix (configurable SMTP server) has
withstood the test of time and remains popular.</p>
<p>Programmable SMTP servers like Haraka, Lamson make building applications
on top of email easy but I am not comfortable exposing them as the primary
server. In comes SMTP delegation; Postfix forwards mails over to Haraka
which then process the mails based on javascript (user-configured) rules.</p>
<p>Postfix needs to be made aware of the domains whose mails are to be delegated.
This is achieved through the <cite>virtual_mailbox_domains</cite> setting in the <cite>main.cf</cite>
configuration file.</p>
<p>Then in the <cite>transport</cite> configuration file, you need to list out the domains and
the locations where the mails have to be delegated/forwarded.</p>
<p>Here's an snippet of a <cite>main.cf</cite> config file with the relevant change:</p>
<pre class="literal-block">
virtual_mailbox_domains = domain1.com domain2.com
</pre>
<p>And the <cite>transport</cite> file forwarding the emails to Haraka running on port 2525:</p>
<pre class="literal-block">
domain1.com smtp:127.0.0.1:2525
domain2.com smtp:127.0.0.1:2525
</pre>
<p>Finally, you restart postfix to reflect the changes.</p>
Hosting multiple python apps different url mount points2017-12-22T00:00:00+00:002017-12-22T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-12-22:/tech/blog/2017/12/22/multiple-python-apps-different-url-path/<p>If you host multiple (virtual hosting) python web apps (django, flask etc)
behind nginx on a single server, you have two options:</p>
<blockquote>
<ol class="arabic simple">
<li>Using subdomains</li>
<li>On different URL mount points</li>
</ol>
</blockquote>
<p>Using subdomains, you will have to update your DNS records for every app that
you deploy. While the deployment is cleaner …</p><p>If you host multiple (virtual hosting) python web apps (django, flask etc)
behind nginx on a single server, you have two options:</p>
<blockquote>
<ol class="arabic simple">
<li>Using subdomains</li>
<li>On different URL mount points</li>
</ol>
</blockquote>
<p>Using subdomains, you will have to update your DNS records for every app that
you deploy. While the deployment is cleaner (no sharing of cookies etc), this
requires a little more effort to setup.</p>
<p>With the second method ie different URL mounts, you don't have to update any
DNS record but there is a chance of cookies getting overwritten if you aren't
careful.</p>
<p>The gunicorn server handles multiple URL mount points through the <cite>SCRIPT_NAME</cite>
header set by the reverse proxy (in our case <cite>nginx</cite>).</p>
<p>Here's an nginx config snippet of hosting two different apps A at <cite>/abc/</cite> and
B at <cite>/def/</cite>. So when you visit say <cite>/abc/about/</cite> and <cite>/def/about/</cite>, you are
visiting the <cite>/about/</cite> URL on the apps A and B respectively.</p>
<pre class="code text literal-block">
server {
...
location /abc {
proxy_pass http://localhost:8001;
include proxy_params;
proxy_set_header SCRIPT_NAME /abc;
}
location /def {
proxy_pass http://localhost:8002;
include proxy_params;
proxy_set_header SCRIPT_NAME /def;
}
}
</pre>
The First War of Independence2017-12-22T00:00:00+00:002017-12-22T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-12-22:/personal/blog/2017/12/22/the-first-war-of-independence/<p>"The First War of Independence" is the translation of Vinayak Damodar Savarakar's
Marathi book on the Sepoy Mutiny of 1857. This is a book I will suggest all English
readers to avoid because there are a lot of typos, grammatical errors, bad formatting
and factual contradictions (within the book). These …</p><p>"The First War of Independence" is the translation of Vinayak Damodar Savarakar's
Marathi book on the Sepoy Mutiny of 1857. This is a book I will suggest all English
readers to avoid because there are a lot of typos, grammatical errors, bad formatting
and factual contradictions (within the book). These errors ruin the whole reading
experience. Maybe if you understand Marathi, you can give this book a shot.</p>
Men without women2017-12-06T00:00:00+00:002017-12-06T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-12-06:/personal/blog/2017/12/06/men-without-women-haruki-murakami/<p>I was supposed to have picked up collection of short stories with the same
name by Ernest Hemingway but got confused and ended up purchasing this.
This was my first Murakami book (also a collection of short stories) and
it is a blend of comedy with tragedy. The common theme …</p><p>I was supposed to have picked up collection of short stories with the same
name by Ernest Hemingway but got confused and ended up purchasing this.
This was my first Murakami book (also a collection of short stories) and
it is a blend of comedy with tragedy. The common theme of all the seven
short stories is 'lone' men (either widower, divorced or single). Most
endings are open and the translations (originally written in Japanese)
are high quality.</p>
How to create a mind2017-12-02T00:00:00+00:002017-12-02T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-12-02:/personal/blog/2017/12/02/how-to-create-a-mind/<p>The human brain is a masterpiece! It can recognize so many patterns and
store a lot of memories. But how did the brain evolve and can it be
mathematically simulated? Ray Kurzweil's book - "How to create a mind",
answers these questions through a series of thought experiments.</p>
<p>Through these experiments …</p><p>The human brain is a masterpiece! It can recognize so many patterns and
store a lot of memories. But how did the brain evolve and can it be
mathematically simulated? Ray Kurzweil's book - "How to create a mind",
answers these questions through a series of thought experiments.</p>
<p>Through these experiments, he concludes that the brain is a pattern
recognition system based on the <a class="reference external" href="https://en.wikipedia.org/wiki/Hierarchical_hidden_Markov_model">Hierarchical Hidden Markov Model</a>. He
claims that in the not so distant future scientists will be able to not
only build an artificial brain but also surpass it. He makes a prediction
that when this happens, humans will begin to supplant their brains with
additional intelligence to make us smarter!</p>
<p>I don't have much idea of the workings of the brain but I find it hard to
believe that something as complex as the working of the human brain could
be distilled into a single algorithm.</p>
The Serpent's Revenge: Unusual Tales from the Mahabharata2017-11-24T00:00:00+00:002017-11-24T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-11-24:/personal/blog/2017/11/24/the-serpents-revenge-unusual-tales-from-the-mahabharata/<p>Sudha Murthy has compiled 25 short stories (some localised) from the
fringes of the Mahabharata. Some stories like that of the Akshayapatra
are well known whereas the others like the yagna by Janamejaya (great
grandson of Arjuna) to slay all snakes (to avenge the death of his father
Parikshit) not …</p><p>Sudha Murthy has compiled 25 short stories (some localised) from the
fringes of the Mahabharata. Some stories like that of the Akshayapatra
are well known whereas the others like the yagna by Janamejaya (great
grandson of Arjuna) to slay all snakes (to avenge the death of his father
Parikshit) not so.</p>
Fahrenheit 4512017-11-23T00:00:00+00:002017-11-23T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-11-23:/personal/blog/2017/11/23/fahrenheit-451/<p>I used to wonder if only the English wrote dystopian novels. But Ray Bradbury,
an American writer swept that doubt away when I picked up "Fahrenheit 451".</p>
<p>In a distant future, firemen are tasked with searching, raiding and destroying
books and snuffing out knowledge. The protagonist of this book, Guy …</p><p>I used to wonder if only the English wrote dystopian novels. But Ray Bradbury,
an American writer swept that doubt away when I picked up "Fahrenheit 451".</p>
<p>In a distant future, firemen are tasked with searching, raiding and destroying
books and snuffing out knowledge. The protagonist of this book, Guy Montag, a
fireman, meets a free-spirited girl in his neighbourhood. After interacting with
her, he starts introspecting on knowledge, happiness and life. In search for
answers, he gets drawn by into books - a forbidden possession. He is declared an
outlaw and has to escape and join the rebels.</p>
<p>Though written in 1953, this book is anachronistic. You could replace books
with thought, art, philosophy or thinkers and this story could be playing out in
your nation.</p>
Untouchable2017-11-20T00:00:00+00:002017-11-20T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-11-20:/personal/blog/2017/11/20/untouchable/<p>Untouchable is the story of a teenage boy born into a lower caste of untouchables.
He has aspirations like the rest of the kids of his age. Everyday, he is slurred
on the basis of his caste and nagged of his ancestors and his subservience to
the upper castes. Fed …</p><p>Untouchable is the story of a teenage boy born into a lower caste of untouchables.
He has aspirations like the rest of the kids of his age. Everyday, he is slurred
on the basis of his caste and nagged of his ancestors and his subservience to
the upper castes. Fed up with such a suffocating life and when left with no other
hope, a speech by Gandhi rekindles an optimism in him - of a caste-free India.</p>
<p>This book happens to be Mulk Raj Anand's first novel and takes on a serious issue
of caste oppression- an issue that was not widely discussed during the freedom
struggle.</p>
The Emperor of All Maladies: A Biography of Cancer2017-11-17T00:00:00+00:002017-11-17T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-11-17:/personal/blog/2017/11/17/the-emperor-of-all-maladies-a-biography-of-cancer/<p>Siddhartha Mukherjee, an oncologist gets his readers up and personal with
Cancer through a voluminous history of all the major types of cancer. He
scours historical texts, medical journals and all public sources to document
the earliest cases, various variants of the disease, treatment procedures,
research methodologies and how and …</p><p>Siddhartha Mukherjee, an oncologist gets his readers up and personal with
Cancer through a voluminous history of all the major types of cancer. He
scours historical texts, medical journals and all public sources to document
the earliest cases, various variants of the disease, treatment procedures,
research methodologies and how and why some forms of cancer have a better
recovery rate than others.</p>
<p>This is not a book for the faint hearted. Not in the least because of the
terminology or technicalities but for the length and the emotional upheaval
it causes as you read the various stories of cancer victims. If you want to
learn more about the disease and how the current state of treatments were
developed, no other book may come close.</p>
The Grand Rebel2017-10-22T00:00:00+00:002017-10-22T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-10-22:/personal/blog/2017/10/22/the-grand-rebel/<p>"The Grand Rebel: An impression of Shivaji, the founder of the Maratha Empire" is
Dennis Kincaid's love story for his personal hero. He pieced this book from
compilations of folk tales, Marathi books, songs and poems. While most of the book
is accurate, he seems to exaggerate Shivaji's political influence …</p><p>"The Grand Rebel: An impression of Shivaji, the founder of the Maratha Empire" is
Dennis Kincaid's love story for his personal hero. He pieced this book from
compilations of folk tales, Marathi books, songs and poems. While most of the book
is accurate, he seems to exaggerate Shivaji's political influence and resorts to
referring to him as India's first Hindu king (a tagline also used for other kings
like Prithviraj Chauhan). In the book, Dennis Kincaid portrays the traders of the
East India company as righteous and ever helping whose sole purpose in India was
to trade. Not sure if the irony dawned on him as a civil servant administering the
Indian colony some 300 years later.</p>
Why I killed Gandhi?2017-10-02T00:00:00+00:002017-10-02T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-10-02:/personal/blog/2017/10/02/why-i-killed-gandhi/<p>It was a coincidence that I started reading this book on the birth anniversary of
Gandhi. "Why I killed Gandhi" is a transcript of the defence put up by Nathuram
Godse in court. The foreword to this short book quotes a judge who claims that
if the Indian legal system …</p><p>It was a coincidence that I started reading this book on the birth anniversary of
Gandhi. "Why I killed Gandhi" is a transcript of the defence put up by Nathuram
Godse in court. The foreword to this short book quotes a judge who claims that
if the Indian legal system allowed for a jury, Godse would've been exonerated by
the force of his arguments.</p>
<p>If you've heard some of the later politicians disparaging Gandhi, most of them
would be passing off Godse's reasons for the assassination. So there's nothing new
that you might not be aware of. Godse held Gandhi the primary reason for the
partition, the subsequent massacre of Hindus and the appeasement of Muslims. He
claimed to have freed the Congress party from being held hostage to the whims
of an irrational old man.</p>
Animal Farm2017-09-16T00:00:00+00:002017-09-16T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-09-16:/personal/blog/2017/09/16/animal-farm/<p>How can you write political satire that can be hard-hitting even when not very
direct? You piggy back (pun intended) upon allegory. "Animal Farm" by George
Orwell is a satire on Soviet Russia (under Stalin, I guess) drawing upon
animals from a barn.</p>
<p>The animals in a barn rise in …</p><p>How can you write political satire that can be hard-hitting even when not very
direct? You piggy back (pun intended) upon allegory. "Animal Farm" by George
Orwell is a satire on Soviet Russia (under Stalin, I guess) drawing upon
animals from a barn.</p>
<p>The animals in a barn rise in revolt against mistreatment by human owners. The
owners flee and the pigs take it upon themselves to organize the barn and set
the regulations to ensure it's smooth working. The animals pour the heart and
sweat into building the ideal barn based upon socialist principles of equity.
Over a period of time, some animals realise they are worse off than before
and the rules of the barn seem to be changing to favour the 'new' rulers who
claim to be sacrificing their lives for the revolution.</p>
<p>Do the animals revolt again or do they curse their fate and carry on with the
status quo? Read this short book to learn the answer.</p>
Sapiens2017-09-04T00:00:00+00:002017-09-04T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-09-04:/personal/blog/2017/09/04/sapiens/<p>When Yuval Noah Harari had to teach history at university, he made notes and
"Sapiens" was born from those. But don't let any of this guide your decision
to read the book.</p>
<p>The book starts with the question, are we humans different? Does race, religion,
gender etc define us? Or …</p><p>When Yuval Noah Harari had to teach history at university, he made notes and
"Sapiens" was born from those. But don't let any of this guide your decision
to read the book.</p>
<p>The book starts with the question, are we humans different? Does race, religion,
gender etc define us? Or are these differences superficial? Sapiens answers
these questions by outlining our history. This book is a breezy read and you
don't feel bored even for an instance.</p>
Small is Beautiful2017-08-11T00:00:00+00:002017-08-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-08-11:/personal/blog/2017/08/11/small-is-beautiful/<p>EF Schumacher was a famous economist with the British government. "Small is
Beautiful" is his collection of speeches. He covers a lot of topics like the
energy crisis, pollution, capitalism, socialism etc. It is in this book that
he first makes use of the term "Buddhist economics" which refers to …</p><p>EF Schumacher was a famous economist with the British government. "Small is
Beautiful" is his collection of speeches. He covers a lot of topics like the
energy crisis, pollution, capitalism, socialism etc. It is in this book that
he first makes use of the term "Buddhist economics" which refers to a minimalist
mode of economy where we move back from automation back to humanisation to
provide jobs and well-being to a large population. He also proposes (in the late
1970s just before the energy crisis) to setup a capital fund where taxes from
non-renewable resources will be diverted to non-renewable energy research. Sadly,
we didn't pay heed to such sane advice until quite late.</p>
The Razor's Edge2017-07-28T00:00:00+00:002017-07-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-07-28:/personal/blog/2017/07/28/the-razors-edge/<p>Can an incident in life affect you so much that you are willing to sacrifice
your career and your love? Larry returns from the first world war as a different
person. His lover, Isabel is anxious about their future together. Larry breaks
the engagement because he wants answers to some …</p><p>Can an incident in life affect you so much that you are willing to sacrifice
your career and your love? Larry returns from the first world war as a different
person. His lover, Isabel is anxious about their future together. Larry breaks
the engagement because he wants answers to some questions about life.</p>
<p>Somerset Maugham, the author, plays a small role in this novel. He plays a
writer constantly moving to and fro between America and Europe and bumping
into the various characters. During one such instance, he runs into Larry
who narrates his story of travel to India where he attains spiritual knowledge
from the spiritual gurus.</p>
<p>Isabel gets married in the meantime into a rich family and she learns of
Larry's story from Somerset Maugham. She cannot forget him and starts
worrying about his life.</p>
<p>Will Isabel be able to seduce Larry back into the materialistic society or
will he be able to convince her to an austere lifestyle?</p>
Ashoka: The Search for India's Lost Emperor2017-07-16T00:00:00+00:002017-07-16T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-07-16:/personal/blog/2017/07/16/ashoka-the-search-for-indias-lost-emperor/<p>Ashoka is a king we idolize, one who gave up violence to take up the path of
the Buddha, one who spread Buddhism the world over. We learn about him as
children and admire his greatness. But that's only now! Just 100 years ago,
we weren't even aware of him …</p><p>Ashoka is a king we idolize, one who gave up violence to take up the path of
the Buddha, one who spread Buddhism the world over. We learn about him as
children and admire his greatness. But that's only now! Just 100 years ago,
we weren't even aware of him.</p>
<p>"Ashoka - The Search for India's Lost Emperor" is Charles Allen's book that
recollects the pain-staking research and investigation mostly by our colonial
rulers that helped India rediscover it's first emperor. If you plan to learn
more about Ashoka through this book, you are better picking a different one.
This book primarily focuses on the various archaeologists and historians and
how they pieced together Ashoka's life, which had been deliberately erased by
the powers that he upset.</p>
<p>I enjoyed reading this book because it almost feels more like a whodunnit than
a history. Gripping unto the last word.</p>
We the living2017-06-30T00:00:00+00:002017-06-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-06-30:/personal/blog/2017/06/30/we-the-living/<p>After having been underwhelmed by Ayn Rand's "The Fountainhead", I was reluctant
to read another of her hyped books. "We the living" is set in the Soviet after
the Czar was overthrown in a revolution.</p>
<p>Kira's family returns to Petrograd after being exiled by the revolutionaries.
All family members struggle …</p><p>After having been underwhelmed by Ayn Rand's "The Fountainhead", I was reluctant
to read another of her hyped books. "We the living" is set in the Soviet after
the Czar was overthrown in a revolution.</p>
<p>Kira's family returns to Petrograd after being exiled by the revolutionaries.
All family members struggle to fit into the 'new' society and shake off their
bourgeois roots. Kira is a tough nut and she refuses to be cowed down by the
hard life. She enrols into a polytechnic institute and hopes to become an
engineer.</p>
<p>She runs into Leo, a man with a similar attitude and love blooms. A revolutionary,
Andrei harbours feelings for Kira and both these tracks get more involved until
Leo contracts tuberculosis and he has to be sent off to a sanatorium for treatment.</p>
<p>Leo comes back from his treatment only in body and is a totally changed person.
He starts living brashly and opens up a black marketing trade. An investigation
by Andrei lands Leo in jail. Upon hearing of Kira's love for Leo, Andrei has
Leo released. But now he is torn apart by his party ideal and his love for Kira.
How Kira, Leo and Andrei handle their internal conflicts is covered in the rest
of the book.</p>
<p>The depiction of the post-Czar Soviet and the hardships faced by commoners (when
the party members lavished) was an eye-opener.</p>
Al Jazeera2017-06-08T00:00:00+00:002017-06-08T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-06-08:/personal/blog/2017/06/08/al-jazeera/<p>"Al Jazeera: How Arab TV News Challenged the World" by Hugh Miles is a biography
of a TV network hated in the west as a mouthpiece of the terrorists and in the
middle east as a mouthpiece of the west. If they are hated by everyone and yet
have a …</p><p>"Al Jazeera: How Arab TV News Challenged the World" by Hugh Miles is a biography
of a TV network hated in the west as a mouthpiece of the terrorists and in the
middle east as a mouthpiece of the west. If they are hated by everyone and yet
have a tremendous impact by becoming one of the largest networks in the world,
don't you think they must be doing something right?</p>
<p>Hugh Miles traces the journey of Al Jazeera birthing out of a grant in Qatar by
the Emir until the end of the Iraq war in 2005. Sometimes the book reads like
a fan tribute and sometimes raises some serious questions about the editorial
policy, financial autonomy etc. But mostly it feels like the former.</p>
<p>While narrating the story of Al Jazeera, the author holds a mirror to the western
world and it's spineless media that abdicated it's duty under the garb of patriotism
in the run up to the Iraq war. He exposes the hypocrisy of the western world that
talks of freedom of speech while curtailing it in the middle east by supporting
authoritarian regimes and despots.</p>
<p>This is a great book not only to learn more about the Al Jazeera but also the
geopolitical dynamics of the Gulf.</p>
<p>In the book, there is an instance where Qatar is boycotted by it's neighbours
over Al Jazeera and something similar is playing out currently. I thought this
would be the best period to judge the objectivity of the news channel. I have to
admit that the coverage so far has been quite balanced and sober (unlike majority
of the English news channels in India).</p>
Rome: The biography of a city2017-05-24T00:00:00+00:002017-05-24T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-05-24:/personal/blog/2017/05/24/rome-the-biography-of-a-city/<p>What's the first thing one picks up when intending to go sightseeing? Most likely
a guide book? The popular guide books (like Lonely Planet) cater to more than
sights ie food, experiences etc. Christopher Hibbert's "Rome: The biography of a
city" is an unconventional guidebook that intertwines history of the …</p><p>What's the first thing one picks up when intending to go sightseeing? Most likely
a guide book? The popular guide books (like Lonely Planet) cater to more than
sights ie food, experiences etc. Christopher Hibbert's "Rome: The biography of a
city" is an unconventional guidebook that intertwines history of the city. It
covers most of the monuments from the time of the city's genesis until the demise
of the Fascist party in the second World War. An extensive guidebook from the
point-of-view of sightseeing and a brisk summary from a historical perspective.</p>
The History of Rome2017-04-30T00:00:00+00:002017-04-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-04-30:/personal/blog/2017/04/30/the-history-of-rome/<p>How did Rome end up becoming such an important city? How did it's story start?
Michael Grant, tries to compress nearly 1500 years of history into 300 pages.
The book's language is simple but condensing so much into a single book is
quite overwhelming. Nevertheless, this book is a great …</p><p>How did Rome end up becoming such an important city? How did it's story start?
Michael Grant, tries to compress nearly 1500 years of history into 300 pages.
The book's language is simple but condensing so much into a single book is
quite overwhelming. Nevertheless, this book is a great way to learn the story
of Rome from 800BC until the end of the Roman Empire in 400AD.</p>
The Big Short2017-04-17T00:00:00+00:002017-04-17T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-04-17:/personal/blog/2017/04/17/the-big-short/<p>How would you feel if you made millions of dollars through trading? In seventh
heaven, I guess?</p>
<p>How would you feel if you made millions of dollars betting against the herd?
When the herd's collapse could shutter some of the biggest financial
institutions and push thousands of home owners on …</p><p>How would you feel if you made millions of dollars through trading? In seventh
heaven, I guess?</p>
<p>How would you feel if you made millions of dollars betting against the herd?
When the herd's collapse could shutter some of the biggest financial
institutions and push thousands of home owners on to the streets? Definitely
not a great feeling!</p>
<p>This book documents the stories of 4 traders who go against the 'conventional'
Wall Street thinking (during the early 2000s until 2007) by betting against
Credit Default Swaps on Collateralized Debt Obligations (built on sub-prime
mortgages) and ended up making billions of dollars during the financial
crisis of 2007-08 which saw investment banks like Lehman Brothers, AIG
etc collapse.</p>
<p>What disappoints them the most is despite the huge losses on Wall Street,
there is no let up in the greed, ignorance and unethical dealings. The
business goes on an usual until a next crisis!</p>
Seabiscuit: An American Legend2017-03-29T00:00:00+00:002017-03-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-03-29:/personal/blog/2017/03/29/seabiscuit-an-american-legend/<p>Seabiscuit was the horse that held up the spirits of not just it's owner but
thousands of Americans during the Great Depression. The horse had gone
unnoticed until it came into the stable of Charles Howard, a successful
America car dealer. Charles Howard appointed Tom Smith to train the horse …</p><p>Seabiscuit was the horse that held up the spirits of not just it's owner but
thousands of Americans during the Great Depression. The horse had gone
unnoticed until it came into the stable of Charles Howard, a successful
America car dealer. Charles Howard appointed Tom Smith to train the horse and his
first task was to reduce the horse's weight and get him fit. Red Pollard was
picked as the horse's jockey and they participated in a few races. Tom Smith
quickly recognized it's potential and relied on his unorthodox techniques to
improve the horse's performance.</p>
<p>Within an year, the horse started winning almost every competition on the
West coast. Word spread and Charles Howard had the horse sent by train to conquer
the East coast. Here too the horse won quite a few races and had only to win
against the East coast's favourite, War Admiral. Despite public demand and eagerness
of fans and owners, a head to head between the two horses didn't materialize.
Charles Howard pins his hopes on such an race to settle the debate on the better
of the two horses.</p>
<p>In one of the regular races, Seabiscuit was injured and the media speculated the
end of the horse's career. But Tom Smith nursed the horse and Seabiscuit makes
a spectacular comeback. It not only shatters quite a few records but goes on
to win the coveted "The Hundred Grander".</p>
Somanatha: The Many Voices of a History2017-03-02T00:00:00+00:002017-03-02T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-03-02:/personal/blog/2017/03/02/somanatha-the-many-voices-of-history/<p>The plunder of Somanatha by Mahmud of Ghazni was supposed to be a watershed
moment in Indian history. It is usually summed up as the start of Islamic
rule in India and the oppression of majority Hindus.</p>
<p>Romila Thapar investigates if that is the case. She concludes that is not …</p><p>The plunder of Somanatha by Mahmud of Ghazni was supposed to be a watershed
moment in Indian history. It is usually summed up as the start of Islamic
rule in India and the oppression of majority Hindus.</p>
<p>Romila Thapar investigates if that is the case. She concludes that is not
the case and to do so she uses sources from both sides ie the Ghaznavid and
local sources like from the Rashtrakutas, the priest family of Somanatha etc.
Some of the reasons provided by her include that Islam was already
co-existing with Hinduism for quite some time. The attack of Somanatha by the
Mahmud of Ghazni was a one-off event and he had no plans of establishing a
caliphate in India as claimed. One of the reasons he attacked Somanatha was
to destroy the port (the temple being an afterthought) to protect horse
export from his kingdom. A host of other reasons are provided and she exhorts
the reader to view these events in the context of that particular age and
not extrapolate them with later or current events.</p>
Early India From the Origins to 1300AD2017-02-27T00:00:00+00:002017-02-27T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-02-27:/personal/blog/2017/02/27/early-india-from-origins-to-1300/<p>When one generally talks of Indian history, we immediately assume the
story of Kings, wars, their golden administration and vilification of
the other neighbouring kingdoms. But Romila Thapar's "Early India from
the Origins to 1300AD" is a different kind of a history book.</p>
<p>It emphasises little on kings and stories …</p><p>When one generally talks of Indian history, we immediately assume the
story of Kings, wars, their golden administration and vilification of
the other neighbouring kingdoms. But Romila Thapar's "Early India from
the Origins to 1300AD" is a different kind of a history book.</p>
<p>It emphasises little on kings and stories but covers people, their lives,
art and literature, administration and economy in great detail. Because
of this unusual (but necessary) focus, the book can feel boring quite a
few times.</p>
Annihilation of Caste2017-01-28T00:00:00+00:002017-01-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-01-28:/personal/blog/2017/01/28/annihilation-of-caste/<p>Annihilation of Caste was supposed to be the last speech to have been delivered
by Dr. B.R Ambedkar before he gave up Hinduism and converted to Buddhism. The
speech was to have been delivered before an anti-caste organization in Lahore
in the 1930s. But the anti-caste group found Ambedkar's …</p><p>Annihilation of Caste was supposed to be the last speech to have been delivered
by Dr. B.R Ambedkar before he gave up Hinduism and converted to Buddhism. The
speech was to have been delivered before an anti-caste organization in Lahore
in the 1930s. But the anti-caste group found Ambedkar's speech hard-hitting and
uncomfortable. They requested him to tone down the speech to make it appeal to
a larger audience. Ambedkar refused to budge down and called off his participation.
This undelivered speech was printed by him and sold as a book.</p>
<p>The main contents of the book are Ambedkar's arguments against the caste system,
it's irrelevance in modern India and the lack of legal sanctity of the Dharamashastras.</p>
<p>A speech that was called off because an anti-caste organization found it radical!
Need I say more about this book?</p>
Nature's Spokesman2017-01-21T00:00:00+00:002017-01-21T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-01-21:/personal/blog/2017/01/21/natures-spokesman/<p>M.Krishnan was amongst India's earliest nature conservationist and policy expert.
This book is a collection of short stories on his tryst with nature's creations.</p>
<p>Some of the stories are everyday stories like the author's encounter with a snake
in his backyard or with common birds like crows. Others being …</p><p>M.Krishnan was amongst India's earliest nature conservationist and policy expert.
This book is a collection of short stories on his tryst with nature's creations.</p>
<p>Some of the stories are everyday stories like the author's encounter with a snake
in his backyard or with common birds like crows. Others being less commonplace
like his careful observations of the elephants at a wildlife sanctuary.</p>
<p>Not one story is dull or esoteric. They are interspersed with a lot of humour
and often reveal nature's grandeur.</p>
The Price of Inequality2017-01-16T00:00:00+00:002017-01-16T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2017-01-16:/personal/blog/2017/01/16/the-price-of-inequality/<p>One of the reasons for the Arab Spring protests in 2010 and the subsequent
Occupy movement in the 2012 was the symptom of globalization, rampant inequality.</p>
<p>Joseph Stiglitz, a Nobel Prize awarded economist and the author of this book
discusses the causes of inequality and the ways to fix it …</p><p>One of the reasons for the Arab Spring protests in 2010 and the subsequent
Occupy movement in the 2012 was the symptom of globalization, rampant inequality.</p>
<p>Joseph Stiglitz, a Nobel Prize awarded economist and the author of this book
discusses the causes of inequality and the ways to fix it.</p>
<dl class="docutils">
<dt>The reasons for the causes of inequality he lists are</dt>
<dd><ul class="first last simple">
<li>Concentration of political power into the wealthy and how policies end up benefitting them</li>
<li>Rent-seeking and capital controls by the wealthy results in them having an unfair advantage</li>
<li>Monopolies in various sectors of businesses</li>
<li>Unfair taxation where the wealthy don't pay their fair share of taxes</li>
</ul>
</dd>
<dt>A few of his suggestions to reduce inequality</dt>
<dd><ul class="first last simple">
<li>Cracking down on the speculators by increasing capital gains tax</li>
<li>Reducing the information assymetry to make markets more open and competitive</li>
<li>Reduce rent-seeking by making incentivizing deployment of capital</li>
<li>Government regulations to prevent monopolies</li>
</ul>
</dd>
</dl>
<p>On the whole, it's an eye-opener though I doubt any government in the world will
heed to the advice and try to reduce inequality.</p>
Alexander the Great2016-12-29T00:00:00+00:002016-12-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-12-29:/personal/blog/2016/12/29/alexander-the-great/<p>Alexander built one of the largest empires in the shortest time and at a young
age. But how did he manage this? Was he blessed with unmatchable valour or did
he rule through an iron fist? There were a lot of such questions in my mind
before I started reading …</p><p>Alexander built one of the largest empires in the shortest time and at a young
age. But how did he manage this? Was he blessed with unmatchable valour or did
he rule through an iron fist? There were a lot of such questions in my mind
before I started reading the book.</p>
<p>Robin Lane Fox, the author, sifts through the various historical accounts to
detail Alexander's life. The book starts with a disclaimer that it is based on
multiple sources like Alexander's personal historians, army generals,
contemporaries and subsequent historians. Robin Lane Fox takes a lot of care to
weed out fiction while providing explanation. By not relying on a single
source and providing disclaimers, this book is transparent and doesn't read
like a one-sided hero-worship.</p>
<p>Alexander is pushed into limelight with the assassination of his father, Philip-II.
The assassins expect a full-blown succession battle but Alexander, aged 20,
displays clear-headedness and takes over the throne with little resistance. After
consolidating his hold in Macedonia and the north, he marches to Greece. At Greece,
he displays his first glimpse of a master strategist by proclaiming himself as one
among them and his purpose in life is to avenge the Darius' attack on Greece a few
years ago. One by one the Greek cities fall to him and he builds up a huge army.</p>
<p>With this army, he proceeds to Persia but moves along the coast to neutralize the
Persian navy's impact. He is confronted by Darius at Issus. The battle is decisively
won by Alexander but Darius escapes.</p>
<p>Alexander then went on to liberate Egypt and the people pronounced him the son of
Amun. Henceforth, Alexander referred to Zeus-Amun as his father.</p>
<p>He proceeded to Mesopotamia and met Darius at the battle of Gaugamela. Again,
Alexander handed Persians the defeat but Darius escaped. Alexander captured
Babylon after this battle and marched towards Susa, one of Persia's capitals.
After a small battle, he enters Persepolis and let's his troops free who resort
to looting and vandalism.</p>
<p>Alexander went after Darius from here only to find him stabbed by his own men.
At the start of his campaign in Greece, Alexander rallied his army by invoking
revenge against Darius for his attack on Greece. But now, Alexander changed his
tact and proclaimed justice for the fallen king as his new motto. To buy the
loyalty of his forces, he paid a handsome price in gold, silver and coveted posts.</p>
<p>In pursuit of Bessus, the killer of Darius, Alexander captured a lot of Central
Asia. Finally, Besus was betrayed by his host and executed by Alexander.</p>
<p>Once again changing the tact, Alexander proclaims he wants to conquer the edge
of the world (India was supposedly known as the edge of the world then). He
motivates his forces to march with him into greatness.</p>
<p>Ambhi, the king of Taxila submits to Alexander who restores him to his kingdom.
With the addition of Taxila's army, Alexander targets Porus. After a few weeks
of mind-games, the two forces come face to face and Porus is captured in the
battlefield. Impressed with his valour, Alexander invites Porus into his inner
circle.</p>
<p>With his eyes set on the Magadha kingdom, Alexander started stirring his troops.
But having been on the road for so many years, they were homesick and longed to
get back home. They soon revolted and Alexander was forced to withdraw.</p>
<p>Alexander moved south to the mouth of Indus and then to Multan before crossing
the great desert to reach Susa. The desert crossing was to be Alexander's
biggest mistake resulting in the loss of half his army.</p>
<p>While recovering from his disastrous desert journey, Alexander loses his best
friend Hephaestion and goes into prolonged grieving. A couple of months later,
he plans an expedition to capture Arabia. But a week before they set sail,
Alexander mysteriously falls ill and dies 12 days later.</p>
<p>His death is controversial as there are two versions of it. One being that he
was probably poisoned and the other being that he died from an unknown fever.</p>
<p>After his death at the age of 32, his generals sparred amongst themselves and
divided the vast kingdom that stretched from the Danube in the west to the Indus
in the east into their satrapies.</p>
Waves2016-11-27T00:00:00+00:002016-11-27T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-11-27:/personal/blog/2016/11/27/waves/<p>"Waves" is a collection of short-stories written in Tamil by Sundara Ramaswamy
(Su.Ra) and translated by Lakshmi Holmstrom.</p>
<p>These breezy stories are mostly set in a middle-class Tamil Brahmin households
some time in the 1960-70s.</p>
No Logo2016-11-22T00:00:00+00:002016-11-22T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-11-22:/personal/blog/2016/11/22/no-logo/<p>A study asked kids under the age of 12 from an impoverished African country
to name their favourite logo. McDonald's ended up very high on that list. This
in a country that didn't have a single McDonald store! That's branding for you.</p>
<p>"No Logo" dissects brands for you but not …</p><p>A study asked kids under the age of 12 from an impoverished African country
to name their favourite logo. McDonald's ended up very high on that list. This
in a country that didn't have a single McDonald store! That's branding for you.</p>
<p>"No Logo" dissects brands for you but not in the way of marketing books but in
exactly the opposite way. It talks about brands in the context of how they are
projecting themselves as champions of globalization while resorting to unfair
and unethical practices like employing sweatshops, paying sub-par wages, hiring
perma-temps (contract workers for long tenures) and abusing the legal process
to silence competitors and activists.</p>
<p>In the book, space is also allocated to how grass root movements are slowly
taking on these huge corporations and making them accountable.</p>
Tinker Tailor Soldier Spy2016-10-28T00:00:00+00:002016-10-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-10-28:/personal/blog/2016/10/28/tinker-tailor-soldier-spy/<p>George Smiley has retired but the events that brought about his abrupt retirement
still plague him. He runs into a former colleague with information that he suspected
for long, the existence of a mole amongst the intelligence sleuths. Smiley is
requested to investigate this discreetly and expose the spy.</p>
<p>After …</p><p>George Smiley has retired but the events that brought about his abrupt retirement
still plague him. He runs into a former colleague with information that he suspected
for long, the existence of a mole amongst the intelligence sleuths. Smiley is
requested to investigate this discreetly and expose the spy.</p>
<p>After making some progress, Smiley settles down on four probable suspects and
code-names them:</p>
<blockquote>
Tinker, Tailor, Soldier and Spy</blockquote>
<p>How George Smiley traps the spy forms the rest of the story. This is a gripping
story by John Le Carre. I found it agitating to pause reading because the suspense
is kept up until the last page.</p>
The End of Food2016-10-03T00:00:00+00:002016-10-03T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-10-03:/personal/blog/2016/10/03/the-end-of-food/<p>What's the first thing that comes to your mind when you think of food? Maybe
well garnished food at a fancy restaurant or maybe something yum cooked by you
mom or spouse? But food has a history and a story to tell. Paul Roberts documents
it's story in "The End …</p><p>What's the first thing that comes to your mind when you think of food? Maybe
well garnished food at a fancy restaurant or maybe something yum cooked by you
mom or spouse? But food has a history and a story to tell. Paul Roberts documents
it's story in "The End of Food".</p>
<p>The story begins with mankind's first interaction with food ie as a
hunterer-gatherer. Then man invented agriculture, an invention that changed our
lifestyle. For centuries, he produced what he and maybe his community consumed.</p>
<p>Now, food is an industry just like any other, characterized by large scale,
value-addition and ruthless efficiency. It has pushed food a wide variety of
food into the plates of people. But this commodification of food has downsides.
Quality control has become a huge issue. The scale of food demand has also
moved out production to cheaper countries crowding out the traditional produce.
Unlike earlier, food is consumed where it is not produced.</p>
<p>This is a mind-blowing book documenting our current state of production and
consumption of food. Please do read it - it's "food for your thoughts".</p>
Emperors of the Peacock Throne2016-09-07T00:00:00+00:002016-09-07T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-09-07:/personal/blog/2016/09/07/emperors-of-the-peacock-throne/<p>Babur invades India after he is chased out of his homeland. His arrival in
India triggers a war with the Lodhis who are routed in the first war of
Panipat. With this, Babur plants the seed to the Mughal dynasty in India.</p>
<p>"Emperors of the Peacock Throne: The saga of …</p><p>Babur invades India after he is chased out of his homeland. His arrival in
India triggers a war with the Lodhis who are routed in the first war of
Panipat. With this, Babur plants the seed to the Mughal dynasty in India.</p>
<p>"Emperors of the Peacock Throne: The saga of the great Mughals" written by
Abraham Eraly is the story of the Mughal kings from Babur until Aurangzeb.
It is based on research from the court historians as well as other
contemporary players. The stories of Sher Shah Suri and Shivaji are an
added bonus in the book.</p>
<p>Whether you've read these stories in your history text books or not, you
must definitely read this book to get a better understanding into the
medieval psyche and clear a lot of misconceptions that surround most of
these characters.</p>
Not without my daughter2016-09-05T00:00:00+00:002016-09-05T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-09-05:/personal/blog/2016/09/05/not-without-my-daughter/<p>Betty Mahmoody, an American citizen is tricked by her husband, an Iranian national
into accompanying him along with their little daughter for a vacation to Iran. A
few days into her stay, she realizes that this is a one-way trip and her husband
has no plans of returning. She frantically …</p><p>Betty Mahmoody, an American citizen is tricked by her husband, an Iranian national
into accompanying him along with their little daughter for a vacation to Iran. A
few days into her stay, she realizes that this is a one-way trip and her husband
has no plans of returning. She frantically tries to get his family to intervene
but none supports her.</p>
<p>She tries to contact the American embassy but her husband learns of her plans and
threatens to kill their daughter if she goes ahead. The embassy requests her to
leave her daughter behind and make her escape. But Betty is adamant that she will
leave the country only with her daughter.</p>
<p>In due course of time, she makes some friends who are sympathetic to her cause and
who try to help her make plans to escape but most of them don't account for the little
girl. One of her friend introduces her to Hossein, an Iranian businessman who has
Betty and her daughter smuggled across the border into Turkey to the American
embassy.</p>
<p>The book is the recollection of real-life events and is riveting. There is a lot
of emphasis on Iranian culture and how Iran's stand-off with the US in the late 70s
fomented troubles for Betty. But one has to tip their hats to Betty's presence of
mind and her dogged determination to get out of Iran with her daughter.</p>
The Magician2016-09-03T00:00:00+00:002016-09-03T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-09-03:/personal/blog/2016/09/03/the-magician/<p>Have you ever been uncontrollably in love with a person even after learning of
their flaws? "The Magician" by Somerset Maugham is the story of Margaret who
breaks off her engagement with Arthur, a successful doctor a few days ahead
of the engagement. She falls in love with an ugly …</p><p>Have you ever been uncontrollably in love with a person even after learning of
their flaws? "The Magician" by Somerset Maugham is the story of Margaret who
breaks off her engagement with Arthur, a successful doctor a few days ahead
of the engagement. She falls in love with an ugly looking Haddo who claims to
be an occult magician.</p>
<p>Margaret is torn between her former lover and her new and becomes frail and
mysteriously passes away. Arthur, a rational person until that point has a
feeling that magic may be the cause of her demise, sets out to investigate.</p>
<p>Does Arthur find out the cause of his lover's death or is his suspicion
misplaced? "The magician" is a fine book with a damp squib ending.</p>
The city of djinns2016-09-01T00:00:00+00:002016-09-01T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-09-01:/personal/blog/2016/09/01/the-city-of-djinns/<p>William Dalrymple and his wife are on a long visit to Delhi, the city of djinns.
The book is a tribute to the city and is filled with stories of interesting
characters he meets here like his Sikh landlady, the loud-mouthed taxi
driver, house keeping staff etc.</p>
<p>While the back …</p><p>William Dalrymple and his wife are on a long visit to Delhi, the city of djinns.
The book is a tribute to the city and is filled with stories of interesting
characters he meets here like his Sikh landlady, the loud-mouthed taxi
driver, house keeping staff etc.</p>
<p>While the back cover of the book claims it's a travelogue, I think it is a well
compiled collection of short stories that describes Delhi, it's beautiful people
and it's fascinating past.</p>
Self-signed TLS Certificate in Linux2016-08-21T00:00:00+00:002016-08-21T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-08-21:/tech/blog/2016/08/21/self-signed-certificate-linux/<p>Today, I had the necessity to embed an iframe on an HTTPS web page and most
browsers now won't allow you to embed an HTTP resource on an HTTPS page raising
the mixed content warning. Since the code was quite experimental, I didn't want
to deploy it out of localhost …</p><p>Today, I had the necessity to embed an iframe on an HTTPS web page and most
browsers now won't allow you to embed an HTTP resource on an HTTPS page raising
the mixed content warning. Since the code was quite experimental, I didn't want
to deploy it out of localhost. So I setup a self-signed TLS certificate for
localhost that was accepted by Google Chrome browser.</p>
<p>Create a <cite>config.cnf</cite> file pre-filled with parameters (replacing <cite>example.com</cite> with
whatever hostname you wish):</p>
<pre class="literal-block">
[ req ]
default_bits = 2048
distinguished_name = req_distinguished_name
req_extensions = san
extensions = san
[ req_distinguished_name ]
countryName = US
stateOrProvinceName = NY
localityName = NYC
organizationName = OrgName
commonName = example.com
[ san ]
subjectAltName = DNS:example.com
</pre>
<p>First, we need to create a key that will be used to sign our certificate. You
will be prompted for a password, which you can enter for now:</p>
<pre class="literal-block">
sudo openssl req \
-x509 \
-nodes \
-days 3650 \
-newkey rsa:2048 \
-keyout /etc/ssl/private/self-signed.key \
-out /etc/ssl/certs/self-signed.crt \
-subj /CN=example.com \
-reqexts san \
-extensions san \
-config config.cnf \
-sha256
</pre>
<p>Create a single file with the certificate and private key to be added
into the store:</p>
<pre class="literal-block">
cat self-signed.key self-signed.crt > localhost.pem
</pre>
<p>Finally, add this certificate into our trusted store so that Chrome doesn't
complain:</p>
<pre class="literal-block">
certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n "localhost" -i localhost.pem
</pre>
<p>Your browser shouldn't complain any more with your self-signed certificate successfully
added into the store.</p>
Elasticsearch autocomplete on related keywords2016-04-21T00:00:00+00:002016-04-21T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-04-21:/tech/blog/2016/04/21/elasticsearch-autocomplete-related-keywords/<p>Recently, I had to work on a client request to add autocomplete to their
site's search based not just on a specific list but on related keywords.</p>
<p>For example, suppose you had a list of TV series like Simpsons, Futurama,
Tom and Jerry etc. The autosearch had to suggest the …</p><p>Recently, I had to work on a client request to add autocomplete to their
site's search based not just on a specific list but on related keywords.</p>
<p>For example, suppose you had a list of TV series like Simpsons, Futurama,
Tom and Jerry etc. The autosearch had to suggest the series based on character
names like Homer, Thomas etc as well.</p>
<p>The project piggy-backed on the <a class="reference external" href="https://pypi.python.org/pypi/elasticsearch-dsl">elasticsearch-dsl</a> python library.</p>
<p>The list of objects that had to be displayed in the autocomplete were saved
in a django model and the related keywords in a column (as JSON) in the same
db table.</p>
<p>So every time the django model was saved, the autocomplete index would be
built afresh.</p>
<p>Here's a snippet of this:</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">elasticsearch_dsl</span> <span class="kn">import</span> <span class="n">Index</span>
<span class="kn">from</span> <span class="nn">elasticsearch_dsl.connections</span> <span class="kn">import</span> <span class="n">connections</span>
<span class="kn">from</span> <span class="nn">elasticsearch_dsl.mapping</span> <span class="kn">import</span> <span class="n">Mapping</span>
<span class="kn">from</span> <span class="nn">.models</span> <span class="kn">import</span> <span class="n">TVSeries</span>
<span class="nd">@receiver</span><span class="p">(</span><span class="n">post_save</span><span class="p">,</span> <span class="n">sender</span><span class="o">=</span><span class="n">TVSeries</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">update_category_autosuggest</span><span class="p">(</span><span class="n">sender</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">es</span> <span class="o">=</span> <span class="n">connections</span><span class="o">.</span><span class="n">get_connection</span><span class="p">(</span><span class="s1">'default'</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
<span class="n">es</span> <span class="o">=</span> <span class="n">connections</span><span class="o">.</span><span class="n">create_connection</span><span class="p">(</span>
<span class="s1">'default'</span><span class="p">,</span>
<span class="n">hosts</span><span class="o">=</span><span class="n">settings</span><span class="o">.</span><span class="n">ELASTICSEARCH_HOSTS</span>
<span class="p">)</span>
<span class="c1"># settings.AUTOSUGGEST_INDEX is the name of the index</span>
<span class="n">index</span> <span class="o">=</span> <span class="n">Index</span><span class="p">(</span><span class="n">settings</span><span class="o">.</span><span class="n">AUTOSUGGEST_INDEX</span><span class="p">)</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">ignore</span><span class="o">=</span><span class="mi">404</span><span class="p">)</span>
<span class="n">mm</span> <span class="o">=</span> <span class="n">Mapping</span><span class="p">(</span><span class="s1">'some_mapping_name'</span><span class="p">)</span>
<span class="c1"># Creating an Elasticsearch schema with the fields and data types</span>
<span class="n">mm</span><span class="o">.</span><span class="n">field</span><span class="p">(</span><span class="s2">"series"</span><span class="p">,</span> <span class="s2">"string"</span><span class="p">)</span>
<span class="n">mm</span><span class="o">.</span><span class="n">field</span><span class="p">(</span><span class="s2">"keywords"</span><span class="p">,</span> <span class="s2">"string"</span><span class="p">,</span> <span class="n">multi</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">mm</span><span class="o">.</span><span class="n">field</span><span class="p">(</span>
<span class="s2">"autosuggest"</span><span class="p">,</span>
<span class="s2">"completion"</span><span class="p">,</span>
<span class="n">index_analyzer</span><span class="o">=</span><span class="s2">"simple"</span><span class="p">,</span>
<span class="n">search_analyzer</span><span class="o">=</span><span class="s2">"simple"</span><span class="p">,</span>
<span class="n">payloads</span><span class="o">=</span><span class="kc">True</span>
<span class="p">)</span>
<span class="n">index</span> <span class="o">=</span> <span class="n">settings</span><span class="o">.</span><span class="n">AUTOSUGGEST_INDEX</span>
<span class="n">mm</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">index</span><span class="p">)</span>
<span class="k">for</span> <span class="n">series</span> <span class="ow">in</span> <span class="n">TVSeries</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">is_active</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
<span class="c1"># Example: {"keywords": ["homer simpson", "thomas", "tom", "bart simpson"]}</span>
<span class="n">keywords</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">series</span><span class="o">.</span><span class="n">json_data</span><span class="p">)</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"keywords"</span><span class="p">,</span> <span class="p">[])</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">keywords</span><span class="p">:</span>
<span class="k">continue</span>
<span class="n">new_kwargs</span> <span class="o">=</span> <span class="n">keywords</span>
<span class="c1"># Add the name of the TV series as well along</span>
<span class="c1"># with the keywords</span>
<span class="k">for</span> <span class="n">cat</span> <span class="ow">in</span> <span class="n">series</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">):</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">cat</span><span class="p">)</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span>
<span class="k">continue</span>
<span class="n">new_kwargs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cat</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">"series"</span><span class="p">:</span> <span class="n">series</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
<span class="s2">"keywords"</span><span class="p">:</span> <span class="n">keywords</span><span class="p">,</span>
<span class="s2">"autosuggest"</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">"input"</span><span class="p">:</span> <span class="n">new_kwargs</span><span class="p">,</span>
<span class="s2">"output"</span><span class="p">:</span> <span class="n">series</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
<span class="c1"># There's a slug field for the TV Series which</span>
<span class="c1"># references the correct URL of the series</span>
<span class="s2">"payload"</span><span class="p">:</span> <span class="n">series</span><span class="o">.</span><span class="n">slug</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="n">meta</span> <span class="o">=</span> <span class="n">es</span><span class="o">.</span><span class="n">index</span><span class="p">(</span>
<span class="n">index</span><span class="o">=</span><span class="n">index</span><span class="p">,</span>
<span class="n">doc_type</span><span class="o">=</span><span class="n">mm</span><span class="o">.</span><span class="n">doc_type</span><span class="p">,</span>
<span class="n">body</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
</pre></div>
<p>After the index is built, the search query needs to be handled. In the view:</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">elasticsearch_dsl.connections</span> <span class="kn">import</span> <span class="n">connections</span>
<span class="kn">from</span> <span class="nn">elasticsearch_dsl</span> <span class="kn">import</span> <span class="n">Search</span>
<span class="k">def</span> <span class="nf">series_autocomplete</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="n">query</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">GET</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"q"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">CONNECTION</span> <span class="o">=</span> <span class="n">connections</span><span class="o">.</span><span class="n">get_connection</span><span class="p">(</span><span class="s2">"default"</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
<span class="n">CONNECTION</span> <span class="o">=</span> <span class="n">connections</span><span class="o">.</span><span class="n">create_connection</span><span class="p">(</span>
<span class="s2">"default"</span><span class="p">,</span>
<span class="n">hosts</span><span class="o">=</span><span class="n">settings</span><span class="o">.</span><span class="n">ELASTICSEARCH_HOSTS</span>
<span class="p">)</span>
<span class="n">ss</span> <span class="o">=</span> <span class="n">Search</span><span class="p">(</span><span class="n">CONNECTION</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="n">settings</span><span class="o">.</span><span class="n">AUTOSUGGEST_INDEX</span><span class="p">)</span>
<span class="n">results</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">qq</span> <span class="ow">in</span> <span class="n">query</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">" "</span><span class="p">):</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">ss</span><span class="o">.</span><span class="n">suggest</span><span class="p">(</span>
<span class="s2">"suggestions"</span><span class="p">,</span>
<span class="n">qq</span><span class="p">,</span>
<span class="n">completion</span><span class="o">=</span><span class="p">{</span>
<span class="s2">"field"</span><span class="p">:</span> <span class="s2">"autosuggest"</span><span class="p">,</span>
<span class="s2">"fuzzy"</span><span class="p">:</span> <span class="kc">True</span>
<span class="p">}</span>
<span class="p">)</span><span class="o">.</span><span class="n">execute</span><span class="p">()</span><span class="o">.</span><span class="n">to_dict</span><span class="p">()</span>
<span class="n">results</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">response</span><span class="p">[</span><span class="s2">"suggest"</span><span class="p">][</span><span class="s2">"suggestions"</span><span class="p">])</span>
<span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span>
<span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">results</span><span class="p">),</span>
<span class="n">content_type</span><span class="o">=</span><span class="s2">"application/json"</span><span class="p">)</span>
</pre></div>
Simple Command Line Dropbox Uploader in Python2016-04-10T00:00:00+00:002016-04-10T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-04-10:/tech/blog/2016/04/10/simple-cli-dropbox-uploader-python/<p>I don't use Dropbox frequently. In fact, I would prefer not to use it but work
requires me to use it from time to time. My only use case was to upload files
onto a shared folder. So for my usage, it makes no sense to run the desktop
client …</p><p>I don't use Dropbox frequently. In fact, I would prefer not to use it but work
requires me to use it from time to time. My only use case was to upload files
onto a shared folder. So for my usage, it makes no sense to run the desktop
client and is quite painful to login to dropbox and get it done. So I wrote up
a very simple dropbox uploader in python that can be used to upload files to
a specific folder onto it.</p>
<p>Here's how you would use it to upload a <cite>local_file_to_upload.extension</cite> to a
dropbox folder named <cite>db_folder</cite>:</p>
<pre class="literal-block">
$ python simple_db_uploader.py /db_folder local_file_to_upload.extension
</pre>
<p>Here is the script available (released in the public domain):</p>
<div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">requests</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="k">def</span> <span class="nf">exit_on_error</span><span class="p">(</span><span class="n">response</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"Status Code: </span><span class="si">{0}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">status_code</span><span class="p">))</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"Response: </span><span class="si">{0}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">(),</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">)))</span>
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
<span class="n">access_token</span> <span class="o">=</span> <span class="s2">"<access_token>"</span>
<span class="n">upload_file</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="s1">'rb'</span><span class="p">)</span>
<span class="n">offset</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">file_size</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">getsize</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
<span class="n">chunk_size</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">*</span> <span class="mi">10</span><span class="o">**</span><span class="mi">6</span>
<span class="n">session_id</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">contents</span> <span class="o">=</span> <span class="n">upload_file</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">chunk_size</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">post</span><span class="p">(</span>
<span class="s2">"https://content.dropboxapi.com/2/files/upload_session/start"</span><span class="p">,</span>
<span class="n">headers</span><span class="o">=</span><span class="p">{</span>
<span class="s2">"Authorization"</span><span class="p">:</span> <span class="s2">"Bearer </span><span class="si">{0}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">access_token</span><span class="p">),</span>
<span class="s2">"Content-Type"</span><span class="p">:</span> <span class="s2">"application/octet-stream"</span>
<span class="p">},</span>
<span class="n">data</span><span class="o">=</span><span class="n">contents</span>
<span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="o">.</span><span class="n">ok</span><span class="p">:</span>
<span class="n">exit_on_error</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
<span class="n">session_id</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()[</span><span class="s2">"session_id"</span><span class="p">]</span>
<span class="n">offset</span> <span class="o">=</span> <span class="n">chunk_size</span>
<span class="k">while</span> <span class="n">offset</span> <span class="o"><=</span> <span class="n">file_size</span><span class="p">:</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">post</span><span class="p">(</span>
<span class="s2">"https://content.dropboxapi.com/2/files/upload_session/append"</span><span class="p">,</span>
<span class="n">headers</span><span class="o">=</span><span class="p">{</span>
<span class="s2">"Authorization"</span><span class="p">:</span> <span class="s2">"Bearer </span><span class="si">{0}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">access_token</span><span class="p">),</span>
<span class="s2">"Dropbox-API-Arg"</span><span class="p">:</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">({</span>
<span class="s2">"session_id"</span><span class="p">:</span> <span class="n">session_id</span><span class="p">,</span>
<span class="s2">"offset"</span><span class="p">:</span> <span class="n">offset</span>
<span class="p">}),</span>
<span class="s2">"Content-Type"</span><span class="p">:</span> <span class="s2">"application/octet-stream"</span>
<span class="p">},</span>
<span class="n">data</span><span class="o">=</span><span class="n">upload_file</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">chunk_size</span><span class="p">)</span>
<span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="o">.</span><span class="n">ok</span><span class="p">:</span>
<span class="n">exit_on_error</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
<span class="n">offset</span> <span class="o">=</span> <span class="n">offset</span> <span class="o">+</span> <span class="n">chunk_size</span>
<span class="k">if</span> <span class="n">offset</span> <span class="o">!=</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">session_id</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">path_args</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">"cursor"</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">"session_id"</span><span class="p">:</span> <span class="n">session_id</span><span class="p">,</span>
<span class="s2">"offset"</span><span class="p">:</span> <span class="n">file_size</span>
<span class="p">},</span>
<span class="s2">"commit"</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">"path"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">upload_file</span><span class="o">.</span><span class="n">name</span><span class="p">),</span>
<span class="s2">"mode"</span><span class="p">:</span> <span class="s2">"overwrite"</span><span class="p">,</span>
<span class="s2">"autorename"</span><span class="p">:</span> <span class="kc">False</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">post</span><span class="p">(</span>
<span class="s2">"https://content.dropboxapi.com/2/files/upload_session/finish"</span><span class="p">,</span>
<span class="n">headers</span><span class="o">=</span><span class="p">{</span>
<span class="s2">"Authorization"</span><span class="p">:</span> <span class="s2">"Bearer </span><span class="si">{0}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">access_token</span><span class="p">),</span>
<span class="s2">"Dropbox-API-Arg"</span><span class="p">:</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">path_args</span><span class="p">),</span>
<span class="s2">"Content-Type"</span><span class="p">:</span> <span class="s2">"application/octet-stream"</span>
<span class="p">}</span>
<span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="o">.</span><span class="n">ok</span><span class="p">:</span>
<span class="n">exit_on_error</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">'__main__'</span><span class="p">:</span>
<span class="n">main</span><span class="p">()</span>
</pre></div>
<p>The only thing missing from this script is the access token on line 14. You need
to create a <a class="reference external" href="https://www.dropbox.com/developers/apps">dropbox app</a> and assign the various permissions and create a test
access token that has to be replaced in the above code and you are ready to go.</p>
<p>This script can be made zingy with <a class="reference external" href="https://github.com/tqdm/tqdm">tqdm</a> to display a progress bar.</p>
<div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">requests</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">from</span> <span class="nn">tqdm</span> <span class="kn">import</span> <span class="n">tqdm</span>
<span class="k">def</span> <span class="nf">exit_on_error</span><span class="p">(</span><span class="n">response</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"Status Code: </span><span class="si">{0}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">status_code</span><span class="p">))</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"Response: </span><span class="si">{0}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">(),</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">)))</span>
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
<span class="n">access_token</span> <span class="o">=</span> <span class="s2">"<access_token>"</span>
<span class="n">upload_file</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="s1">'rb'</span><span class="p">)</span>
<span class="n">offset</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">file_size</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">getsize</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
<span class="n">chunk_size</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">*</span> <span class="mi">10</span><span class="o">**</span><span class="mi">6</span>
<span class="n">session_id</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">contents</span> <span class="o">=</span> <span class="n">upload_file</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">chunk_size</span><span class="p">)</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">post</span><span class="p">(</span>
<span class="s2">"https://content.dropboxapi.com/2/files/upload_session/start"</span><span class="p">,</span>
<span class="n">headers</span><span class="o">=</span><span class="p">{</span>
<span class="s2">"Authorization"</span><span class="p">:</span> <span class="s2">"Bearer </span><span class="si">{0}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">access_token</span><span class="p">),</span>
<span class="s2">"Content-Type"</span><span class="p">:</span> <span class="s2">"application/octet-stream"</span>
<span class="p">},</span>
<span class="n">data</span><span class="o">=</span><span class="n">contents</span>
<span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="o">.</span><span class="n">ok</span><span class="p">:</span>
<span class="n">exit_on_error</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
<span class="n">session_id</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">json</span><span class="p">()[</span><span class="s2">"session_id"</span><span class="p">]</span>
<span class="n">num_chunks</span> <span class="o">=</span> <span class="p">(</span><span class="n">file_size</span> <span class="o">/</span> <span class="n">chunk_size</span><span class="p">)</span>
<span class="n">offset</span> <span class="o">=</span> <span class="n">chunk_size</span>
<span class="k">for</span> <span class="n">chunk</span> <span class="ow">in</span> <span class="n">tqdm</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="n">num_chunks</span><span class="p">)):</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">post</span><span class="p">(</span>
<span class="s2">"https://content.dropboxapi.com/2/files/upload_session/append"</span><span class="p">,</span>
<span class="n">headers</span><span class="o">=</span><span class="p">{</span>
<span class="s2">"Authorization"</span><span class="p">:</span> <span class="s2">"Bearer </span><span class="si">{0}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">access_token</span><span class="p">),</span>
<span class="s2">"Dropbox-API-Arg"</span><span class="p">:</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">({</span>
<span class="s2">"session_id"</span><span class="p">:</span> <span class="n">session_id</span><span class="p">,</span>
<span class="s2">"offset"</span><span class="p">:</span> <span class="n">offset</span>
<span class="p">}),</span>
<span class="s2">"Content-Type"</span><span class="p">:</span> <span class="s2">"application/octet-stream"</span>
<span class="p">},</span>
<span class="n">data</span><span class="o">=</span><span class="n">upload_file</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">chunk_size</span><span class="p">)</span>
<span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="o">.</span><span class="n">ok</span><span class="p">:</span>
<span class="n">exit_on_error</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
<span class="n">offset</span> <span class="o">=</span> <span class="n">offset</span> <span class="o">+</span> <span class="n">chunk_size</span>
<span class="k">if</span> <span class="n">offset</span> <span class="o">!=</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">session_id</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">path_args</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">"cursor"</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">"session_id"</span><span class="p">:</span> <span class="n">session_id</span><span class="p">,</span>
<span class="s2">"offset"</span><span class="p">:</span> <span class="n">file_size</span>
<span class="p">},</span>
<span class="s2">"commit"</span><span class="p">:</span> <span class="p">{</span>
<span class="s2">"path"</span><span class="p">:</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">upload_file</span><span class="o">.</span><span class="n">name</span><span class="p">),</span>
<span class="s2">"mode"</span><span class="p">:</span> <span class="s2">"overwrite"</span><span class="p">,</span>
<span class="s2">"autorename"</span><span class="p">:</span> <span class="kc">False</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">post</span><span class="p">(</span>
<span class="s2">"https://content.dropboxapi.com/2/files/upload_session/finish"</span><span class="p">,</span>
<span class="n">headers</span><span class="o">=</span><span class="p">{</span>
<span class="s2">"Authorization"</span><span class="p">:</span> <span class="s2">"Bearer </span><span class="si">{0}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">access_token</span><span class="p">),</span>
<span class="s2">"Dropbox-API-Arg"</span><span class="p">:</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">path_args</span><span class="p">),</span>
<span class="s2">"Content-Type"</span><span class="p">:</span> <span class="s2">"application/octet-stream"</span>
<span class="p">}</span>
<span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">response</span><span class="o">.</span><span class="n">ok</span><span class="p">:</span>
<span class="n">exit_on_error</span><span class="p">(</span><span class="n">response</span><span class="p">)</span>
<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">'__main__'</span><span class="p">:</span>
<span class="n">main</span><span class="p">()</span>
</pre></div>
Micro2016-03-21T00:00:00+00:002016-03-21T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-03-21:/personal/blog/2016/03/21/micro/<p>"Micro" by Michael Crichton (author of "Jurassic Park") is the story of a group
of research students who get miniaturized by a company when they get interested
in a murder's leads. Does the team survive the world where even insects appear
like giants and against time when their bodies succumb …</p><p>"Micro" by Michael Crichton (author of "Jurassic Park") is the story of a group
of research students who get miniaturized by a company when they get interested
in a murder's leads. Does the team survive the world where even insects appear
like giants and against time when their bodies succumb to the side-effects of
miniaturization?</p>
<p>The plot moves fast and has all the elements from other Crichton's novels. But
just the imagination that goes into his novel makes it a worthwhile read.</p>
Heart of Darkness2016-02-23T00:00:00+00:002016-02-23T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-02-23:/personal/blog/2016/02/23/heart-of-darkness/<p>What image would the word 'sailor' invoke for you? For me it would be Haddock
from Tintin, an alcoholic captain who mouths expletives when sober but a damn
good seafarer. But after reading the "Heart of Darkness" by Joseph Conrad, it
has changed to Charles Marlow.</p>
<p>Set in the early …</p><p>What image would the word 'sailor' invoke for you? For me it would be Haddock
from Tintin, an alcoholic captain who mouths expletives when sober but a damn
good seafarer. But after reading the "Heart of Darkness" by Joseph Conrad, it
has changed to Charles Marlow.</p>
<p>Set in the early 1900s, Marlow is recruited in London to undertake a journey
to Central Africa to bring back a consignment of ivory for his company. During
the journey, he hears of a company man called Kurtz. Kurtz is a legend in the
company as he brings in more ivory than other agents in Africa. He is fed with
lots of stories on the 'savage' natives but on his first contact with them he
realizes they are just a diseased lot that aren't capable of savagery. His
next mission is to retrieve Kurtz from an inner station and escort him back
to London. What he sees here is more disturbing and affects him emotionally
as well as physically. He makes it back to the company office after an
arduous trip but is disgusted by everything he sees in the 'civilized' world.</p>
<p>The book is just over 120 pages and has a great style.</p>
Don't make me think!2016-02-15T00:00:00+00:002016-02-15T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-02-15:/personal/blog/2016/02/15/dont-make-me-think/<p>Steve Krug is renowned user experience professional and is the author of
several popular books in this area. "Don't make me think!" is his most
widely read book. I was recommended this book by a designer in response
to my query on designing better online experiences.</p>
<p>I picked up the …</p><p>Steve Krug is renowned user experience professional and is the author of
several popular books in this area. "Don't make me think!" is his most
widely read book. I was recommended this book by a designer in response
to my query on designing better online experiences.</p>
<p>I picked up the 2nd edition of the book and though it is dated, quite a
few problems outlined are still prevalent. Steve Krug's first law states
that the "Raison d'être" of every designer should be to not make their
users think. The cognitive load of using a website should be low and the
design should lead the user into solving their own problems.</p>
<p>Quite a few design patterns and best practices are discussed in the book
with the help of examples but some of these are not recommended any more.</p>
<p>It's a very good book to get you started into asking the right questions
for building good user experiences. Hopefully, I will get a chance to
apply what I have learnt soon.</p>
Walden2016-01-22T00:00:00+00:002016-01-22T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2016-01-22:/personal/blog/2016/01/22/walden/<p>If you've ever harboured thoughts of retiring to the country side and living off
your own small farm, Walden is a book for you. Henry Thoreau, an American
philosopher documents his experiences of living in solitude at the Walden lake.</p>
<p>The book lacks a structure but generally discusses a lot …</p><p>If you've ever harboured thoughts of retiring to the country side and living off
your own small farm, Walden is a book for you. Henry Thoreau, an American
philosopher documents his experiences of living in solitude at the Walden lake.</p>
<p>The book lacks a structure but generally discusses a lot of topics like economy,
neighbours, literature, self-sufficient life. Even within these topics, the chain
of thoughts is not very coherent and makes the book very hard to read. Nevertheless,
a very interesting book documenting experiences of life by the shores a beautiful lake.</p>
The Element2015-11-24T00:00:00+00:002015-11-24T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2015-11-24:/personal/blog/2015/11/24/the-element/<p>What does being in one's 'element' mean? How does one get to that state of mind?
Before answering these questions, I saw Ken Robinson's <a class="reference external" href="http://www.ted.com/talks/ken_robinson_says_schools_kill_creativity">TED talk</a> on "Do schools
kill creativity?" and resolved to read atleast one book by him to learn more about
his ideas.</p>
<p>Now to the question …</p><p>What does being in one's 'element' mean? How does one get to that state of mind?
Before answering these questions, I saw Ken Robinson's <a class="reference external" href="http://www.ted.com/talks/ken_robinson_says_schools_kill_creativity">TED talk</a> on "Do schools
kill creativity?" and resolved to read atleast one book by him to learn more about
his ideas.</p>
<p>Now to the question of "What does being in one's element mean?". As per the book,
when there is a confluence of drive and talent, the person is in their element.
Even the most mundane tasks feel like a cakewalk.</p>
<p>The second question is answered through a series of stories of high profile
people like Ariana Huffington, Matt Groening, Richard Feynman etc. Too many similar
themed stories blows away the charm of the book and makes reading it mundane.</p>
The suffrage of Elvira2015-09-17T00:00:00+00:002015-09-17T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2015-09-17:/personal/blog/2015/09/17/the-suffrage-of-elvira/<p>This was my first VS Naipaul novel and I picked it up with a lot of reluctance
especially over his chauvinistic views. But boy, this book lived up to it's
expectations as a super comedy.</p>
<p>This book describes the first election at Trinidad. The electorate is multi-cultural
with Hindus, Muslims …</p><p>This was my first VS Naipaul novel and I picked it up with a lot of reluctance
especially over his chauvinistic views. But boy, this book lived up to it's
expectations as a super comedy.</p>
<p>This book describes the first election at Trinidad. The electorate is multi-cultural
with Hindus, Muslims and Christians. The candidates go to great lengths to appease
them and some even scheme to hurt their rival's chances. Does the candidate who has
the largest mass appeal or the one with the biggest money chest win?</p>
<p>What currently happens in elections in India is not very different from that written
in this book.</p>
The Little Black book of Innovation2015-06-28T00:00:00+00:002015-06-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2015-06-28:/personal/blog/2015/06/28/the-little-black-book-of-innovation/<p>Can innovation be successfully instilled and nurtured within a company? Scott
Anthony pulls out quite a few case studies from his career as an "Innovation
Expert" and analyzes them for the reader.</p>
<p>This is a book from the HBR stable and is a passable read. The main reason
for this …</p><p>Can innovation be successfully instilled and nurtured within a company? Scott
Anthony pulls out quite a few case studies from his career as an "Innovation
Expert" and analyzes them for the reader.</p>
<p>This is a book from the HBR stable and is a passable read. The main reason
for this recommendation is that at some points the book trivializes the
aspects of innovation.</p>
The Fist of God2015-06-24T00:00:00+00:002015-06-24T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2015-06-24:/personal/blog/2015/06/24/the-fist-of-god/<p>Another classic Frederick Forsyth novel that is set during the First Persian
Gulf war. A British secret agent is sent into Iraq to locate and destroy a
nuclear weapon codenamed "The Fist of God".</p>
<p>He needs to contact an Iraqi insider who is willing to provide this top-secret
information for …</p><p>Another classic Frederick Forsyth novel that is set during the First Persian
Gulf war. A British secret agent is sent into Iraq to locate and destroy a
nuclear weapon codenamed "The Fist of God".</p>
<p>He needs to contact an Iraqi insider who is willing to provide this top-secret
information for a price. How he evades detection and if he is successful in
destroying the nuclear weapon is handled by the rest of the story? Does the
Iraqi asset turn out to be a reliable source or does the coalition reward him
for his efforts is another sub-plot.</p>
Siddhartha2015-04-04T00:00:00+00:002015-04-04T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2015-04-04:/personal/blog/2015/04/04/siddhartha/<p>Siddhartha is a contemporary of Gautama Buddha and the protagonist of the German
novel by the same name written by Herman Hess. Siddhartha renounces familial life
to achieve enlightenment. He is accompanied on this journey by his friend, Govinda.
They hear of Buddha's teachings and approach him with answers to …</p><p>Siddhartha is a contemporary of Gautama Buddha and the protagonist of the German
novel by the same name written by Herman Hess. Siddhartha renounces familial life
to achieve enlightenment. He is accompanied on this journey by his friend, Govinda.
They hear of Buddha's teachings and approach him with answers to their questions.
Siddhartha is still not satisfied and moves on to find the answers to his questions
while his friend, Govinda becomes a disciple of Buddha.</p>
<p>As a part of his journey, Siddhartha reaches a city across the river and here is
smitten by Kamala, a courtesan. While he detested material possessions until now,
he goes after them to get her love. After a few years, he finds himself hating
himself and that his goal in life was to seek the answers to his questions. He
abandons Kamala and reaches the other end of the river and takes refuge under the
boatman who helps him cross the river. Here he decides his goal is to only serve
the river and all those people who wish to cross it.</p>
<p>One day, he glances upon Kamala, now a Buddhist convert crossing the river with
their son. She dies after being bitten by a snake across the river and Siddhartha
resolves to bring up his son without leaving any stone unturned. The pampered
teenager finds it difficult to adjust at the poor boatman's house and flees.
Siddhartha is enraged but consoled by the boatman that just like him the boy will
return to the river very much like Siddhartha in his earlier years. Soon, Siddhartha
recognizes the power of the river and finds all the answers he had been seeking all
these years. This brings about peace to him and his life fulfilled.</p>
<p>As Siddhartha grows old, he is visited by his friend Govinda. Not recognizing his
friend, Govinda seeks the help of Siddhartha. Siddhartha takes him by the river and
explains his philosophy. As Govinda gets ready to leave, Siddhartha requests him to
kiss his forehead and bid him good bye. When Govinda complies, he sees visions of
Vasudeva and Siddhartha by the river and experiences the same feeling when Siddhartha's
gained enlightenment.</p>
<p>Siddhartha's character has a few similarities with Buddha's life but diverges
on quite a few aspects including his teachings.</p>
The Prince2015-03-13T00:00:00+00:002015-03-13T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2015-03-13:/personal/blog/2015/03/13/the-prince/<p>I picked up this novel thinking it would be in the same genre as "Don Quixote" but
boy was I mistaken! <a class="reference external" href="https://en.wikipedia.org/wiki/The_Prince">The Prince</a> by Machiavelli is analogous to Chanakya's Arthashastra.
Machiavelli documents the political situation in Italy in the 1600s and writes about
the various initiatives that a prince must …</p><p>I picked up this novel thinking it would be in the same genre as "Don Quixote" but
boy was I mistaken! <a class="reference external" href="https://en.wikipedia.org/wiki/The_Prince">The Prince</a> by Machiavelli is analogous to Chanakya's Arthashastra.
Machiavelli documents the political situation in Italy in the 1600s and writes about
the various initiatives that a prince must undertake to consolidate his position and
build an empire.</p>
<p>Though written in the 1600s, the book is anachronistic and still applies to contemporary
politics. Hopefully the Prince in waiting will read this book.</p>
No Comebacks2015-02-07T00:00:00+00:002015-02-07T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2015-02-07:/personal/blog/2015/02/07/no-comebacks/<p>I have read a few novels of Frederick Forsyth and love them but writing short
stories is a different ball game altogether. With "No Comebacks", Frederick
Forsyth has delivered 10 amazing short stories. Most stories concerning crime
and they will blow away your mind. If you are a fan of …</p><p>I have read a few novels of Frederick Forsyth and love them but writing short
stories is a different ball game altogether. With "No Comebacks", Frederick
Forsyth has delivered 10 amazing short stories. Most stories concerning crime
and they will blow away your mind. If you are a fan of Jeffrey Archer, you
will find like this one.</p>
<p>The best story is the title story "No Comebacks". A rich businessman who
womanizes a lot falls in love with a woman who is on a short trip to London.
He wants to marry her but she rebuffs his advances as she is committed. He
decides to knock off her husband and take precaution that there are "No
Comebacks".</p>
Metamorphosis and other stories2015-01-28T00:00:00+00:002015-01-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2015-01-28:/personal/blog/2015/01/28/metamorphosis-and-other-stories/<p>Kafkaesque is the term used to describe something irrational. Metamorphosis
does full justice to that word. Gregor Samsa, a hard working and on the road
salesman, wakes up one day to find out that he has turned into a "monstrous
verminous bug". His parents and sister are horrified by his …</p><p>Kafkaesque is the term used to describe something irrational. Metamorphosis
does full justice to that word. Gregor Samsa, a hard working and on the road
salesman, wakes up one day to find out that he has turned into a "monstrous
verminous bug". His parents and sister are horrified by his appearance and
can't stomach him being around. Gregor senses this and restricts himself to
his room. Here, he crawls on to the window every morning until evening just
peering out. His parents and sister slowly get tired of looking after him
and Gregor decides to starve himself to death to relieve them of the burden.
More than the story, the imagery and language is fantastic. This is that one
story that makes the whole book worth it.</p>
<p>The rest of the stories cover some expedition or describe a situation which
the author has experienced.</p>
The Hitchhikers Guide to the Galaxy2015-01-07T00:00:00+00:002015-01-07T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2015-01-07:/personal/blog/2015/01/07/the-hitchhikers-guide-to-the-galaxy/<p>"Don't Panic" reads the sticker on the cover of the book. Earth gets destroyed by
an alien race and Arthur Dent, a human has lost his home and planet and is now
travelling in space with Ford, an alien. Arthur is in a state of panic and doesn't
have an …</p><p>"Don't Panic" reads the sticker on the cover of the book. Earth gets destroyed by
an alien race and Arthur Dent, a human has lost his home and planet and is now
travelling in space with Ford, an alien. Arthur is in a state of panic and doesn't
have an idea where they are, what to do when they catch up with Ford's cousin, Zaphod
and travel to Magrathea, a planet that is just getting out of a hibernation after
the planet real estate industry crashed. On this planet they meet a planet designer,
who narrates the story of "The Deep Thought" computer and it's "Answer to the Question
of Life" (the one whose answer is 42!).</p>
<p>This is a damn hilarious book but with a very thin story. It makes for a great reading
when one is down and doesn't want to spend any grey cells.</p>
Sunset at Blandings2014-12-12T00:00:00+00:002014-12-12T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-12-12:/personal/blog/2014/12/12/sunset-at-blandings/<p>You sneak into a house under an assumed identity to meet your lover but the
problem is that many occupants of the house know your identity. How to extricate
oneself from such a situation? Generally, a PG Wodehouse book would reveal the
answer to the question but not in this …</p><p>You sneak into a house under an assumed identity to meet your lover but the
problem is that many occupants of the house know your identity. How to extricate
oneself from such a situation? Generally, a PG Wodehouse book would reveal the
answer to the question but not in this one. This book happens to be the last
and incomplete book from the maestro. The book terminates midway but has the
notes and research reproduced leaving the rest to the reader's imagination.</p>
The Blowback2014-12-11T00:00:00+00:002014-12-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-12-11:/personal/blog/2014/12/11/the-blowback/<p>Impressed by Mukul Deva's earlier books (<a class="reference external" href="http://thejaswi.info/personal/blog/2013/05/30/salim-must-die/">Salim Must Die</a> and <a class="reference external" href="http://thejaswi.info/personal/blog/2012/12/30/lashkar/">Lashkar</a>), I
picked this book. After the death of Salim, Iqbal is on the way back to India
but injured in a skirmish. After a long recovery, he slips through to India to
be assigned onto a new operation. The …</p><p>Impressed by Mukul Deva's earlier books (<a class="reference external" href="http://thejaswi.info/personal/blog/2013/05/30/salim-must-die/">Salim Must Die</a> and <a class="reference external" href="http://thejaswi.info/personal/blog/2012/12/30/lashkar/">Lashkar</a>), I
picked this book. After the death of Salim, Iqbal is on the way back to India
but injured in a skirmish. After a long recovery, he slips through to India to
be assigned onto a new operation. The ISI has changed tactics and is now waging
a new type of war, one from within. Iqbal's task is to infiltrate the group and
pass on as much information as possible.</p>
<p>Though the book is well edited and the story line is tight, it feels like the
author has written this book with his eyes set on movie rights because some
sequences are formulaic.</p>
The Argumentative Indian2014-12-09T00:00:00+00:002014-12-09T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-12-09:/personal/blog/2014/12/09/the-argumentative-indian/<p>The Argumentative Indian is a collection of essays by Nobel Laureate and
economist Amartya Sen. The essays discuss Indian history, democracy, culture
and secularism.</p>
<p>Probably, there is a time and place to read this book and that time (atleast
for me) was not now. India is currently seeing a kindling …</p><p>The Argumentative Indian is a collection of essays by Nobel Laureate and
economist Amartya Sen. The essays discuss Indian history, democracy, culture
and secularism.</p>
<p>Probably, there is a time and place to read this book and that time (atleast
for me) was not now. India is currently seeing a kindling of intolerance on
many levels and the essays especially the ones on secularism are drab and
sometimes sound political.</p>
<p>The book is a disappointment, however, the essay that compared and contrasted
Tagore and Gandhi's personalities is interesting. Despite not seeing eye to eye
on many topics, the two great men expressed their dissent civilly (something
that we should learn) and stuck together for the common goal of liberation
from the colonial forces.</p>
Night of January 16th2014-11-11T00:00:00+00:002014-11-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-11-11:/personal/blog/2014/11/11/night-of-january-16th/<p>This is a play written by Ayn Rand that documents the trial of Karen Andre for
the murder of her employer and lover, Bjorn Faulkner on the "Night of January 16th".</p>
<p>The play is fully set in the court and no actual depiction of the murder is
shown. The whole …</p><p>This is a play written by Ayn Rand that documents the trial of Karen Andre for
the murder of her employer and lover, Bjorn Faulkner on the "Night of January 16th".</p>
<p>The play is fully set in the court and no actual depiction of the murder is
shown. The whole incident is recollected through the statements of the witnesses
and the defendant. A jury which is picked from the audience (a novelty) at the
start of the play is pleaded to come to a decision. Since this isn't scripted,
the jury could go either ways and the ending has been tailored for the two
outcomes (another novelty). To make life difficult for the jury, the evidences
are evenly balanced and Ayn Rand hopes that before pronouncing the verdict, we
will bring out the mirror with which we judge ourselves and the society.</p>
<p>This is a thin book spanning around 100 pages and can easily be read in one
sitting.</p>
Nginx Basic Auth without htpasswd-tools2014-11-10T00:00:00+00:002014-11-10T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-11-10:/tech/blog/2014/11/10/nginx-basic-auth-no-htpasswd-tools/<p>Sometimes you may want to hide your staging server or project under development
from search engines and prying eyes but you don't want to take a lot of pain.
<a class="reference external" href="https://en.wikipedia.org/wiki/Basic_access_authentication">HTTP Basic Auth</a> is one solution (can be used as a proper authentication
mechanism for web-apps as well) to allow only …</p><p>Sometimes you may want to hide your staging server or project under development
from search engines and prying eyes but you don't want to take a lot of pain.
<a class="reference external" href="https://en.wikipedia.org/wiki/Basic_access_authentication">HTTP Basic Auth</a> is one solution (can be used as a proper authentication
mechanism for web-apps as well) to allow only authorized people from visiting
the site under wraps. On visiting the site, the user will be prompted for a
username and password before displaying the site.</p>
<p>It's fairly easy to setup HTTP basic auth on nginx. You need to specify which
<cite>location</cite> will use the authentication and what the authentication details are.</p>
<p>First, on the nginx config:</p>
<pre class="literal-block">
location / {
auth_basic "Restricted Access";
auth_basic_user_file /path/to/basic_auth_file/.htpasswd;
...
}
</pre>
<p>The .htpasswd file (can have any name but apache seems to have started this trend
so let's play on for now) that you create will have the username separated by
a colon (:) followed by the encrypted password hash per line. For example:</p>
<pre class="literal-block">
username1:<encrypted_password_hash1>
username2:<encrypted_password_hash2>
...
</pre>
<p>To create the encrypted password hash, the <cite>htpasswd-tools</cite> package is recommended
but it is possible to create the encrypted hashes without the package. All you need
is the openssl package (which comes bundled by default on most linux distributions):</p>
<pre class="literal-block">
$ openssl passwd -crypt
Password:
Verifying - Password:
ZET0ZiC0DqcF2
</pre>
<p>On running the above command, it prompts you for the password and to confirm
it and then will output a hash. Copy the hash and enter it in your htpasswd
file and you are good to go after restarting nginx.</p>
Lee Iacocca: An autobiography2014-10-31T00:00:00+00:002014-10-31T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-10-31:/personal/blog/2014/10/31/lee-iacocca-an-autobiography/<p>Lee Iacocca was the poster child at Ford, having started from the bottom
and worked his way through (being credited with the Ford Mustang) to become the
President of the company. Things seemed to be going well until he was fired
after sweating it out for more than thirty years …</p><p>Lee Iacocca was the poster child at Ford, having started from the bottom
and worked his way through (being credited with the Ford Mustang) to become the
President of the company. Things seemed to be going well until he was fired
after sweating it out for more than thirty years at the company.</p>
<p>He was angry at Henry Ford for this but wanted to take a swipe at Henry.
Luckily, Chrysler was hunting for a new head and the marriage seemed to be a
great fit. Lee was aware that Chrysler wasn't doing well but no sooner than
a few months into the job, he realized that the iceberg had hit the ship
long back and now the ship was precariously positioned hull up ready to suck
all those around it as it went down. Left with few options, he urged the
government to agree for a bailout to keep the company and it's employees
afloat. He documented all the difficulties he had in getting the politicians
to see eye to eye on such a deal.</p>
<p>With the help of a new team he put in, Chrysler turned around and paid
off the billions it owed the government. In this process, he also got the
opportunity to beat Henry on the sales chart and drive the point that he
wasn't a one time wonder and how much Ford lost out by letting him go.</p>
<p>I generally don't read autobiographies because they are fairly narcissistic
but this was different. Lee exposes his human side, the mistakes, the
gullibility, the hypocrisy between his free-market philosophy and when
Chrysler had to go begging around at Capitol Hill.</p>
The Rozabal Line2014-09-30T00:00:00+00:002014-09-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-09-30:/personal/blog/2014/09/30/the-rozabal-line/<p>It all starts at the shrine of a mysterious figure in Kashmir. A Hindu astrologer
notices a weird star formation and predicts the end of the world and a woman finds
a severed head in a library shelf in London. What on earth is happening?</p>
<p>Ashwin Sanghi, the author, builds …</p><p>It all starts at the shrine of a mysterious figure in Kashmir. A Hindu astrologer
notices a weird star formation and predicts the end of the world and a woman finds
a severed head in a library shelf in London. What on earth is happening?</p>
<p>Ashwin Sanghi, the author, builds up the story slowly through it's numerous sub-plots
most of which intertwine with the Abrahamic religion histories. After you are done
with the book, you wonder if the author hastened the ending (probably some word
or page limit?).</p>
<p>An engrossing story on the lines of Dan Brown's works but the ending is disappointing.</p>
HBR on Leadership2014-09-24T00:00:00+00:002014-09-24T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-09-24:/personal/blog/2014/09/24/hbr-on-leadership/<p>This book is touted to be one of "HBR's 10 MUST reads" and also boasts of an
article by Peter Drucker, the father of "modern management".</p>
<p>The book is compiled from their repository of articles and most of them use
case-studies to drive the point. Each chapter discusses one facet …</p><p>This book is touted to be one of "HBR's 10 MUST reads" and also boasts of an
article by Peter Drucker, the father of "modern management".</p>
<p>The book is compiled from their repository of articles and most of them use
case-studies to drive the point. Each chapter discusses one facet of leadership
and how leaders can be identified and groomed.</p>
<p>If you read management books regularly then this book offers nothing new.</p>
Stay Hungry Stay Foolish2014-09-18T00:00:00+00:002014-09-18T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-09-18:/personal/blog/2014/09/18/stay-hungry-stay-foolish/<p>"Stay Hungry. Stay Foolish" was the legendary parting quote from Steve Jobs
during a Stanford commencement. Rashmi Bansal picks up on that quote to
narrate the entrepreneurial travails of 25 alumnii from IIM Ahmedabad.</p>
<p>I am not sure if it was intended to be a marketing message for a management …</p><p>"Stay Hungry. Stay Foolish" was the legendary parting quote from Steve Jobs
during a Stanford commencement. Rashmi Bansal picks up on that quote to
narrate the entrepreneurial travails of 25 alumnii from IIM Ahmedabad.</p>
<p>I am not sure if it was intended to be a marketing message for a management
school that needs no marketing but the book wound up being cheesy and
mostly uninspiring save a couple of stories (one being the story of the
GiveIndia founder).</p>
The Racketeer2014-09-16T00:00:00+00:002014-09-16T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-09-16:/personal/blog/2014/09/16/the-racketeer/<p>An upcoming black lawyer finds himself behind bars for money-laundering. He
hardly gets an opportunity to defend himself during the farcical proceedings.
After the sentencing, he is treated on par with criminals convicted of heinous
crimes and he seethes with anger at this and wants to get back at the …</p><p>An upcoming black lawyer finds himself behind bars for money-laundering. He
hardly gets an opportunity to defend himself during the farcical proceedings.
After the sentencing, he is treated on par with criminals convicted of heinous
crimes and he seethes with anger at this and wants to get back at the system.</p>
<p>He gets a break when a judge is murdered and the case hits a dead end. Learning
that the cops and judicial community are growing desperate every day, he devises
a plan to get out of prison and take the system for a ride. What follows is
not just hilarious but exposes the hypocrisy of the justice system.</p>
<p>From the author of path-breaking legal novels, John Grisham, this is a gripping
novel that keeps you glued until the last page.</p>
The Hungry Tide2014-08-29T00:00:00+00:002014-08-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-08-29:/personal/blog/2014/08/29/the-hungry-tide/<p>No one, and I repeat "no one" can describe the beauty of the Gangetic delta as
well as Amitav Ghosh. The inhabitants of the tiny islands in the delta have made
peace with the tide but they fear it when it is accompanied by the storm.</p>
<p>In this book, he …</p><p>No one, and I repeat "no one" can describe the beauty of the Gangetic delta as
well as Amitav Ghosh. The inhabitants of the tiny islands in the delta have made
peace with the tide but they fear it when it is accompanied by the storm.</p>
<p>In this book, he documents the story of a fisherman, a cretacean researcher and
an urbane translator and their experiences in the "tide country".</p>
<p>Amitav Ghosh's description of the delta makes one yearn for a visit and experience
the tidal phenomenon first hand.</p>
The Cobra2014-07-23T00:00:00+00:002014-07-23T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-07-23:/personal/blog/2014/07/23/the-cobra/<p>When the first citizen of the United States decides to put an end to the drug
menace, he calls in one of the most experienced hands to handle this job. "The
Cobra" had served "The Commander in Chief" in similar roles but was pushed
into retirement. Now with this herculean …</p><p>When the first citizen of the United States decides to put an end to the drug
menace, he calls in one of the most experienced hands to handle this job. "The
Cobra" had served "The Commander in Chief" in similar roles but was pushed
into retirement. Now with this herculean task he is dragged out of it but not
before getting an assurance to have overreaching powers.</p>
<p>He sets out to complete the task assigned to him but will he be successful or
will the global drug mafia snuff him out before he can wreck damage? This book
is a classic Frederick Forsyth, a mixture of facts interleaved with dollops of
fiction.</p>
Wise and Otherwise2014-06-21T00:00:00+00:002014-06-21T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-06-21:/personal/blog/2014/06/21/wise-and-otherwise/<p>"Wise and Otherwise" is yet another installment of short stories from Sudha Murthy.
She effortlessly describes most Indian middle class households through her stories.
Be it neglected seniors of the house, friends who change with money, orphans who
are still gratuitous even after decades, this book covers a wide range …</p><p>"Wise and Otherwise" is yet another installment of short stories from Sudha Murthy.
She effortlessly describes most Indian middle class households through her stories.
Be it neglected seniors of the house, friends who change with money, orphans who
are still gratuitous even after decades, this book covers a wide range of people.</p>
<p>Just like her earlier books, this is a heart warming read especially for the weekend.</p>
59 seconds2014-06-14T00:00:00+00:002014-06-14T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-06-14:/personal/blog/2014/06/14/59-seconds/<p>Richard Wiseman, is an English Psychology professor famous for his writings in
"Experimental Psychology". This book is his "scientically proven advice to
improving life in 59 seconds".</p>
<p>This book is a breezy read though I cannot vouch for it's efficacy. But since
he quotes lots of studies, I think we …</p><p>Richard Wiseman, is an English Psychology professor famous for his writings in
"Experimental Psychology". This book is his "scientically proven advice to
improving life in 59 seconds".</p>
<p>This book is a breezy read though I cannot vouch for it's efficacy. But since
he quotes lots of studies, I think we should give him the benefit of the doubt.</p>
The Fountainhead2014-02-27T00:00:00+00:002014-02-27T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-02-27:/personal/blog/2014/02/27/the-fountainhead/<p>After finishing a book, whenever I asked for recommendations for my next,
one book always figured in it, "The fountainhead". Many described it as a
cult book, one that changed lives. With such compulsive reviews, dare I
miss it?</p>
<p>Howard Roark is kicked out of architecture school because his ideas …</p><p>After finishing a book, whenever I asked for recommendations for my next,
one book always figured in it, "The fountainhead". Many described it as a
cult book, one that changed lives. With such compulsive reviews, dare I
miss it?</p>
<p>Howard Roark is kicked out of architecture school because his ideas are
bizarre and unconventional. He is unperturbed and moves on to make something
of his passion. He interns under Henry Cameron, an architect who is pushed
to obscurity due to the very ideas that Roark was expelled from school.
After Cameron's death, Roark joins Guy Francon's firm under Peter Keating,
a wily architect who gets his work done more through flattery than through
his talent. Unable to suppress his vision, Roark is fired for insubordination.</p>
<p>Roark starts his own firm but doesn't get enough traction and winds it up
to go and work on a granite quarry. Here he encounters Guy Francon's daughter
Dominique and their unusual love story begins. But before their love story
can make further progress, Roark is called back to resume his work at his own
firm.</p>
<p>Ellsworth Tahooey, a self styled expert on everything under the sun and a
news commentator connives with Peter Keating to get Roark a project only
to have him sued upon it's completion. The whole architectural community is
looking down upon Roark when Gail Wynad, a millionaire who made it from the
scratch commissions Roark to build a home for him. Wynad and Roark become
good friends in the process but their friendship is tested in a scandal
conjured up by Tahooey. Throughout the novel, we see Roark unflinchingly
driven by his conviction and vision and goes to any extent to defend them.</p>
<p>Most of the people who recommended this book read it during their undergrad
years and that's why this influenced them so heavily. Having seen a little
bit of corporate culture where one has to be pragmatic (not an idealist like
Roark), I found the book a very good read but not one which swayed me.</p>
The English Patient2014-01-25T00:00:00+00:002014-01-25T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2014-01-25:/personal/blog/2014/01/25/the-english-patient/<p>A patient burned beyond recognition, his devoted young nurse, an emotionally
confused military man and a retired thief come together under the roof of
war torn villa.</p>
<p>This Michael Ondaatje novel is set during the North African conquest of
World War II where Almasy gets burned beyond recognition during an …</p><p>A patient burned beyond recognition, his devoted young nurse, an emotionally
confused military man and a retired thief come together under the roof of
war torn villa.</p>
<p>This Michael Ondaatje novel is set during the North African conquest of
World War II where Almasy gets burned beyond recognition during an aerial
recce. He is transferred to a villa which has been converted into a makeshift
hospital in Italy under the care of Hana, a young Canadian nurse. Here she
meets Kip, a Sikh bomb defusing specialist employed by the Allied forces and
David Carvaggio, a thief on the payrolls of the allied forces entrusted with
the task of picking up axis' documents. Hana gets emotionally attached to this
English patient even though she knows that it is against her profession.</p>
<p>The English Patient is a very slow story that painlessly shifts between the
deserts of North Africa to the beautiful countryside of Italy and wonderfully
captures the emotional conflict of each character in the novel.</p>
The Painter of Signs2013-12-31T00:00:00+00:002013-12-31T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-12-31:/personal/blog/2013/12/31/the-painter-of-signs/<p>I like to alternate heavy reads with easier books and after Dawkin's
"Selfish Gene", I picked up R.K Narayan's "The Painter of Signs".</p>
<p>Raman is a painter of signs at Malgudi who lives with his aunt and
is well read. One day, he receives a visit from Daisy, a …</p><p>I like to alternate heavy reads with easier books and after Dawkin's
"Selfish Gene", I picked up R.K Narayan's "The Painter of Signs".</p>
<p>Raman is a painter of signs at Malgudi who lives with his aunt and
is well read. One day, he receives a visit from Daisy, a spirited
woman working for the family planning scheme of the government. She
contracts Raman to paint signs for the scheme.</p>
<p>Daisy only cares for improving the lives of women and controlling
the rampant population growth. During his contract, he travels with
Daisy to several villages and is impressed with her professionalism
and her independent way of life. He falls for her and wishes to marry
her. His aunt, who has been looking after him since childhood is aghast
at his decision and to avoid neighbourhood gossip leaves for a pilgrimage.
Whether Raman manages to convince his aunt and get married to Daisy forms
the rest of the story.</p>
<p>Unlike other R.K Narayan books, the humour is very subtle. As Raman's
aunt prepares for her pilgrimage, Raman reminisces how she made innumrable
sacrifices to bring him up and this recollection is touching and probably
the high point of this novel.</p>
The Selfish Gene2013-12-24T00:00:00+00:002013-12-24T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-12-24:/personal/blog/2013/12/24/the-selfish-gene/<p>This book begins with a justification for the title because people
misunderstood it and maligned 'evolution'. Richard Dawkins, the
author, bases majority of the book on how the 'gene' is the focal
point of all evolution (and not a group of species).</p>
<p>This book is probably the best guide on …</p><p>This book begins with a justification for the title because people
misunderstood it and maligned 'evolution'. Richard Dawkins, the
author, bases majority of the book on how the 'gene' is the focal
point of all evolution (and not a group of species).</p>
<p>This book is probably the best guide on evolution. Like his other
books and most books in this genre, it gets straight to the point
and hence may be a hard read. But if you labour through this book,
it will be totally worth it.</p>
The Black Swan2013-11-30T00:00:00+00:002013-11-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-11-30:/personal/blog/2013/11/30/the-black-swan/<p>A "Black Swan" event is one that brings about a major upset to existing facts.
Until the late 18th century, people always assumed "white" swans but were shell
shocked to discover "black" swans in Australia. Nassim Nicholas Taleb coined
this term to explain such high impact events.</p>
<p>Through past events …</p><p>A "Black Swan" event is one that brings about a major upset to existing facts.
Until the late 18th century, people always assumed "white" swans but were shell
shocked to discover "black" swans in Australia. Nassim Nicholas Taleb coined
this term to explain such high impact events.</p>
<p>Through past events in the financial markets and the narrative around them, he
exposes loopholes in our prediction abilities and how "one" black swan caused
irreperable damage. He also quotes examples out of the finance to show how badly
we are equipped at making predictions.</p>
<p>It's an interesting book with a little bit of subtle humour in the examples but
towards the end it spirals into a name calling exercise. Don't expect style or
finesse in the book, read it if you want to see how "experts" can get things
wrong and how you can hedge yourself against life's "black swans".</p>
Resize Qemu Image2013-10-30T00:00:00+00:002013-10-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-10-30:/tech/blog/2013/10/30/resize-qemu-image/<p>The default cloud image on <a class="reference external" href="http://cloud-images.ubuntu.com/">Ubuntu</a> has a root partition size of 2GB.
I wanted a way to resize the root without going through the hassle
of setting up LVM.</p>
<p>To be able to resize the qemu images, we need the <a class="reference external" href="http://libguestfs.org/guestfish.1.html">Guestfish</a> package.</p>
<div class="highlight"><pre><span></span>qemu-img create -f qcow2 -b base_disk.img …</pre></div><p>The default cloud image on <a class="reference external" href="http://cloud-images.ubuntu.com/">Ubuntu</a> has a root partition size of 2GB.
I wanted a way to resize the root without going through the hassle
of setting up LVM.</p>
<p>To be able to resize the qemu images, we need the <a class="reference external" href="http://libguestfs.org/guestfish.1.html">Guestfish</a> package.</p>
<div class="highlight"><pre><span></span>qemu-img create -f qcow2 -b base_disk.img tmp.img
truncate -r tmp.img resized.img
truncate -s 10250M resized.img
virt-resize --resize /dev/vda1<span class="o">=</span>10G tmp.img resized.img
</pre></div>
<p>First create a new image (<cite>tmp.img</cite>) with the base image (use the
Ubuntu cloud image) and use that as a base reference for the resized
image. Then set the size of the resized (in this case <cite>10G ~ 10205M</cite>)
image you want to create. After that use the <a class="reference external" href="http://libguestfs.org/virt-resize.1.html">virt-resize</a> tool available
in the Guestfish package to resize the disk. Finally, use the resized
image in a VM of your choice.</p>
The Small Bachelor2013-10-28T00:00:00+00:002013-10-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-10-28:/personal/blog/2013/10/28/the-small-bachelor/<p>So far, I have not enjoyed any non Jeeves story. But "The Small Bachelor" broke
that jinx for me. The book opens with George Finch, a small time artist getting
swept off his feet by Miss Waddington. But Mrs Waddington has got other plans
for her daughter. George finds a …</p><p>So far, I have not enjoyed any non Jeeves story. But "The Small Bachelor" broke
that jinx for me. The book opens with George Finch, a small time artist getting
swept off his feet by Miss Waddington. But Mrs Waddington has got other plans
for her daughter. George finds a friend in Hamilton Beamish who takes upon himself
the task of uniting the two.</p>
<p>But no Wodehouse story is complete without it's share of twists. The marriage of
George Finch and Miss Waddington is arranged but then called off at the last minute.
Then it is up to Beamish Hamilton and George's butler, Mullett to save the day.</p>
<p>A typical Wodehouse fare that you will enjoy thoroughly.</p>
Think again2013-10-14T00:00:00+00:002013-10-14T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-10-14:/personal/blog/2013/10/14/think-again/<p>There are a lot of books stereotyping Indians in the US but "Think again" is
slightly different. For one, it isn't as much an exaggeration and it offers
a native twang. The Hyderabadi lingo is what makes this novel lively but
kills part of the fun because it is abused …</p><p>There are a lot of books stereotyping Indians in the US but "Think again" is
slightly different. For one, it isn't as much an exaggeration and it offers
a native twang. The Hyderabadi lingo is what makes this novel lively but
kills part of the fun because it is abused a little too much.</p>
<p>Nayan, an American born Indian falls for Lavanya, the central character of
the novel. While it is obvious for everyone around that he is trying to flirt
and gain her attention, Lavanya is shocked when the proposal comes directly!
Lavanya has got a past and tries to explain her situation to Nayan but he is
adamant. How Lavanya and Nayan make their relationship work forms the rest of
the story.</p>
<p>The book could have been edited tightly to keep the length in check. With a
shallow storyline, you can't expect to stay glued even if it brings out a
few laughs through the Hyderabadi language.</p>
The Heart of India2013-09-29T00:00:00+00:002013-09-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-09-29:/personal/blog/2013/09/29/the-heart-of-india/<p>Mark Tully is a fantastic story teller and "The Heart of India" is a collection
of humourous short stories from eastern Uttar Pradesh. I couldn't resist drawing
parallels between RK Narayan and Jeffrey Archer in the stories. The stories
exhibit a deep understanding of the rural Indian society and the …</p><p>Mark Tully is a fantastic story teller and "The Heart of India" is a collection
of humourous short stories from eastern Uttar Pradesh. I couldn't resist drawing
parallels between RK Narayan and Jeffrey Archer in the stories. The stories
exhibit a deep understanding of the rural Indian society and the obnoxious caste
system.</p>
Man and Boy2013-09-25T00:00:00+00:002013-09-25T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-09-25:/personal/blog/2013/09/25/man-and-boy/<p>When was the last time 'a' book moistened your eyes and brought a smile
that stretched from ear to ear? "Man and Boy" by Tony Parsons is definitely
one such book.</p>
<p>A man grows up to become a father and take charge of his son. In the
process, he draws …</p><p>When was the last time 'a' book moistened your eyes and brought a smile
that stretched from ear to ear? "Man and Boy" by Tony Parsons is definitely
one such book.</p>
<p>A man grows up to become a father and take charge of his son. In the
process, he draws parallels with his childhood and how he underestimated
his wife's sacrifices in bringing up their son.</p>
<p>He loses the love of his life to find another but only to lose it again.
At one point, he loses everything worth living but perseveres in the hope
that his son will look up to him someday.</p>
<p>This is a poignant story but the author spoilt it partly with the ending.</p>
If God was a Banker2013-09-15T00:00:00+00:002013-09-15T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-09-15:/personal/blog/2013/09/15/if-god-was-a-banker/<p>Two fresh graduates join a foreign bank planning to disrupt banking in India.
One is ambitious, willing to play the bad ball and trample everyone in his
path while the other's hallmark is integrity and won't stand corruption.</p>
<p>No prizes for guessing the rest of the story. This non-linear story …</p><p>Two fresh graduates join a foreign bank planning to disrupt banking in India.
One is ambitious, willing to play the bad ball and trample everyone in his
path while the other's hallmark is integrity and won't stand corruption.</p>
<p>No prizes for guessing the rest of the story. This non-linear story is fast
paced and exaggerates a few incidents but it's the ending that is disappointing.</p>
<p>If you have no interesting book to read, pick this one up and I assure you
can go through it one sitting.</p>
The God of Small Things2013-09-13T00:00:00+00:002013-09-13T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-09-13:/personal/blog/2013/09/13/the-god-of-small-things/<p><a class="reference external" href="https://en.wikipedia.org/wiki/The_God_of_Small_Things">The God of Small Things</a> is the debut and Booker prize winner novel by Arundhati
Roy. The book is set in Ayemenem, a village in Kerala in a Syrian Catholic family.
Rahel, the narrator, recounts the story of her family starting from her grandfather
until the day she "returns".</p>
<p>While …</p><p><a class="reference external" href="https://en.wikipedia.org/wiki/The_God_of_Small_Things">The God of Small Things</a> is the debut and Booker prize winner novel by Arundhati
Roy. The book is set in Ayemenem, a village in Kerala in a Syrian Catholic family.
Rahel, the narrator, recounts the story of her family starting from her grandfather
until the day she "returns".</p>
<p>While Rahel recounts her childhood, you start admiring the childish tone that Arundhati
Roy employs and it matures with age. Velutha, though not covered as heavily as other
characters is the protagonist.</p>
<p>A lot of ink is spent on the characterization and imagery and this adds value to
the story. This book will transport you effortlessly to Kerala, give you a primer
of Communism and expose the pervasive caste system.</p>
Freakonomics2013-09-03T00:00:00+00:002013-09-03T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-09-03:/personal/blog/2013/09/03/freakonomics/<p><a class="reference external" href="https://en.wikipedia.org/wiki/Freakonomics">Freakonomics</a> is an economist's take on some non-traditional "economic" topics.
Steven Levitt and Stephen Dubner use economic theory to explain why crime rates
decreased after an abortion ban, what teachers and sumo wrestlers have in common,
how information de-control led to the downfall of Ku Klux Klan etc.</p>
<p>The use …</p><p><a class="reference external" href="https://en.wikipedia.org/wiki/Freakonomics">Freakonomics</a> is an economist's take on some non-traditional "economic" topics.
Steven Levitt and Stephen Dubner use economic theory to explain why crime rates
decreased after an abortion ban, what teachers and sumo wrestlers have in common,
how information de-control led to the downfall of Ku Klux Klan etc.</p>
<p>The use of economic theory for attempting to answer these questions is interesting
but the writing style is dry and can get boring despite humour being interspersed.</p>
<p>Read this book to learn a new way of looking at problems but not for it's literary
skills.</p>
The Old Man and his God2013-09-01T00:00:00+00:002013-09-01T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-09-01:/personal/blog/2013/09/01/the-old-man-and-his-god/<p>"The old man and his God" is a collection of short stories by Sudha Murthy, a
well known philantrophist and wife of Infosys Chairman, N R Murthy. The book is
a collection of about 20 short stories. She claims that all the stories in this
book are based on true …</p><p>"The old man and his God" is a collection of short stories by Sudha Murthy, a
well known philantrophist and wife of Infosys Chairman, N R Murthy. The book is
a collection of about 20 short stories. She claims that all the stories in this
book are based on true incidents. A few stories are poginant which almost
everyone may have experienced and a few others need to be taken with a grain og
salt.</p>
<p>You will not regret reading this book because it will finish almost as soon as
it starts.</p>
Chanakya's Chant2013-08-05T00:00:00+00:002013-08-05T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-08-05:/personal/blog/2013/08/05/chanakyas-chant/<p>Chanakya is possibly the first documented king maker of Indian history and is
well known for his masterpiece, Artha Shastra (the knowledge of wealth). As a
child, I heard numerous stories of how he schemed and employed unconventional
techniques to achieve his goals.</p>
<p>My expectations were pegged higher when I …</p><p>Chanakya is possibly the first documented king maker of Indian history and is
well known for his masterpiece, Artha Shastra (the knowledge of wealth). As a
child, I heard numerous stories of how he schemed and employed unconventional
techniques to achieve his goals.</p>
<p>My expectations were pegged higher when I learnt that this wily character was
the protagonist. Ashwin Sanghi has masterfully handled narrating two different
yet similar stories set in different periods.</p>
<p>Gangadhar Mishra, is an unassuming professor whose 'sole' aim is to install a
national ruler much like Chanakya's aim of having Chandragupta Maurya ascend
the throne of Magadha. The novel narrates their path to the goal.</p>
<p>This book is riveting but for the ending where the interlinking of the stories
falls flat.</p>
The Class2013-07-23T00:00:00+00:002013-07-23T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-07-23:/personal/blog/2013/07/23/the-class/<p>What memories from college would resurface on your class' 25th reunion? Would you
still harbour animosity from college or let bygones be bygones? "The Class" by
Erich Segal narrates the story of Harvard batch of 1958 until their 25th reunion.</p>
<p>Andrew Eliot joins Harvard, with a huge burden on his …</p><p>What memories from college would resurface on your class' 25th reunion? Would you
still harbour animosity from college or let bygones be bygones? "The Class" by
Erich Segal narrates the story of Harvard batch of 1958 until their 25th reunion.</p>
<p>Andrew Eliot joins Harvard, with a huge burden on his shoulders, his family's
legacy. Through his diary entries he tracks colourful characters like Ted
Lambros, Jason Gilbert, George Keller and Daniel Rossi. Ted Lambros' ambition is
to become a scholar in classical Greek and head the department at Harvard. Jason,
a champion sportsman faces an identity crisis and wants to connect with his roots.
George Keller on the other hand wants to get far away from his roots and excel in
politics. Daniel Rossi wants to become a world class pianist.</p>
<p>The first half of the book covers their college life and is entertaining but the
second half covering their matrimonies is slightly depressing. Nonetheless, this
book is a fine read for it's style and characterization.</p>
God delusion2013-06-16T00:00:00+00:002013-06-16T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-06-16:/personal/blog/2013/06/16/god-delusion/<p>Richard Dawkins is a famous English atheist and staunch believer of "evolution".
In "God delusion", he challenges the existence of God with evolutionary principles.</p>
<p>Up front, he categorizes people into 7 classes based on their belief and states
that this book should be read (and warns that it may outrage …</p><p>Richard Dawkins is a famous English atheist and staunch believer of "evolution".
In "God delusion", he challenges the existence of God with evolutionary principles.</p>
<p>Up front, he categorizes people into 7 classes based on their belief and states
that this book should be read (and warns that it may outrage the senses) by those
with the slightest belief in a God.</p>
<p>I have never found creationist arguments convincing and have always looked up to
evolution, so this book didn't awe me but you can't help lauding the logical
reasoning and boldness of Richard Dawkins.</p>
<p>If you are a theist, please read this book with an open mind and then take a call
if the book makes valid observations or is outrageous!</p>
Salim must die2013-05-30T00:00:00+00:002013-05-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-05-30:/personal/blog/2013/05/30/salim-must-die/<p>"Salim must die", is the sequel to <a class="reference external" href="http://thejaswi.info/personal/blog/2012/12/30/lashkar/">Lashkar</a>. Mukul Deva has scripted a racy
thriller in "Salim must die". The story resumes with Iqbal infiltrating
back to India after an ambush in PoK. He is apprehended but no one trusts
the valuable information he voluntarily discloses. Soon the world wakes …</p><p>"Salim must die", is the sequel to <a class="reference external" href="http://thejaswi.info/personal/blog/2012/12/30/lashkar/">Lashkar</a>. Mukul Deva has scripted a racy
thriller in "Salim must die". The story resumes with Iqbal infiltrating
back to India after an ambush in PoK. He is apprehended but no one trusts
the valuable information he voluntarily discloses. Soon the world wakes up
to a series of terrorist attacks. With Iqbal's assistance and quick
investigation, the Indian intelligence organizations trace the mastermind,
Salim.</p>
<p>Anbu, the leader of the special forces requests the Indian PM for orders to
infiltrate Pakistan and neutralize Salim. Will the crack team assembled by
Anbu make quick work of Salim or will he give the slip once again?</p>
The world of Nagaraj2013-05-24T00:00:00+00:002013-05-24T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-05-24:/personal/blog/2013/05/24/the-world-of-nagaraj/<p>Having inherited well, Nagaraj has no need to earn for a living and so his day
is very leisurely spent. His begins his day early with a prayer, a relaxed coffee
followed by charitable accounting at for his friend Coomar at the Boeing saree shop.</p>
<p>One fine day, Tim leaves …</p><p>Having inherited well, Nagaraj has no need to earn for a living and so his day
is very leisurely spent. His begins his day early with a prayer, a relaxed coffee
followed by charitable accounting at for his friend Coomar at the Boeing saree shop.</p>
<p>One fine day, Tim leaves home after a disagreement with his father (Nagaraj's elder
brother) and lands at Nagaraj's. Tim's father has a low opinion of his brother and
this adds an additional burden on Nagaraj to ensure Tim's comfort. Tim misuses this
liberty and comes home late in the nights stinking of liquor. Nagaraj does not want
to displease Tim and get an earful from his brother and so maintains the status quo.</p>
<p>With every midnight encounter, Nagaraj's peace of mind slips away and he has to
figure out a way to guide Tim back while balancing the fragile relationship with
his brother. Will Nagaraj succeed in his plan or will all hell break loose?</p>
<p>This story is the handiwork of <a class="reference external" href="https://en.wikipedia.org/wiki/R._K._Narayan">R K Narayan</a>, need I say more?</p>
A brave new world2013-04-18T00:00:00+00:002013-04-18T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-04-18:/personal/blog/2013/04/18/a-brave-new-world/<p>In <a class="reference external" href="/personal/blog/2013/04/15/1984/">1984</a>, the government of the future keeps it's citizens under constant
surveillance and uses coercive measures to keep them under check. "A brave new
world" shows us a different point of view of how future governments may administer.</p>
<p>In this book, Aldous Huxley writes that future governments will keep …</p><p>In <a class="reference external" href="/personal/blog/2013/04/15/1984/">1984</a>, the government of the future keeps it's citizens under constant
surveillance and uses coercive measures to keep them under check. "A brave new
world" shows us a different point of view of how future governments may administer.</p>
<p>In this book, Aldous Huxley writes that future governments will keep their
citizens distracted with pleasure and comforts. They will isolate and shun
those who don't believe in it's approach much like animals in a zoo.</p>
<p>The book starts off in a fertilization factory where children are manufactured
to specifications. A caste system is ingrained in them during birth and then
they are indoctrinated through a scientific process. Lenina is an outgoing girl
seeing Bernard, a semi recluse psychologist. Bernard doesn't believe in the
system while Lenina finds nothing wrong with it. They go on a holiday to a
"savage" safari where they see outcasts living by themselves. Bernard manages
to get two savages into the new world. One savage, John falls in love with
Lenina but has issues settling down in this strange new world.</p>
<p>Unlike 1984, this book has a fascinating philosophical debate at the end
that makes up for it's sluggish pace.</p>
Lord of the Flies2013-04-17T00:00:00+00:002013-04-17T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-04-17:/personal/blog/2013/04/17/lord-of-the-flies/<p>A group of pre-teen boys are marooned on an uninhabited island after their plane
crashes. The boys decide to get together and look after themselves until someone
comes to their rescue. Intriguing enough to read it? "Lord of the flies" is an
award winning book by William Golding.</p>
<p>This book …</p><p>A group of pre-teen boys are marooned on an uninhabited island after their plane
crashes. The boys decide to get together and look after themselves until someone
comes to their rescue. Intriguing enough to read it? "Lord of the flies" is an
award winning book by William Golding.</p>
<p>This book is a delight to read because it shows how humans react under stress.
The story is crisp, style is fantastic and the ending is gripping. This book
is a classic that everyone must read.</p>
The vendor of sweets2013-04-16T00:00:00+00:002013-04-16T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-04-16:/personal/blog/2013/04/16/the-vendor-of-sweets/<p>What happens when your children don't believe in the values you live by?
"The vendor of sweets" is a classic story that narrates this. Jagan is
a sweet vendor at R K Narayan's Magludi who believes in everything organic
and Gandhiji's way of life.</p>
<p>His son Mali grows up to …</p><p>What happens when your children don't believe in the values you live by?
"The vendor of sweets" is a classic story that narrates this. Jagan is
a sweet vendor at R K Narayan's Magludi who believes in everything organic
and Gandhiji's way of life.</p>
<p>His son Mali grows up to like literature and goes abroad to become a writer.
Grudgingly, Jagan let's his son have his way. Two years later, Mali returns
with Grace, a foreign bride and a grand business plan! Mali tries to convince
Jagan to invest in his business but Jagan is adamant. Will Mali be able to
kick start his business or will Jagan manage to turn around his 'foreign' son?</p>
<p>While the story may not be gripping, the characterizations like that of the
'cousin' and treatment is super. The story exposes the generation gap between
the father and the son and the hypocrisy of Jagan.</p>
19842013-04-15T00:00:00+00:002013-04-15T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-04-15:/personal/blog/2013/04/15/1984/<p>I had heard of the phrases "Orwellian Future" and "Big Brother is watching you"
many times but never appreciated the seriousness they conveyed until I read this
book.</p>
<p>In 1984, Oceania (a fictitious country) is controlled by a totalitarian regime
headed by "The Party" symbolized by "Big Brother". Every member …</p><p>I had heard of the phrases "Orwellian Future" and "Big Brother is watching you"
many times but never appreciated the seriousness they conveyed until I read this
book.</p>
<p>In 1984, Oceania (a fictitious country) is controlled by a totalitarian regime
headed by "The Party" symbolized by "Big Brother". Every member of the society
is under pervasive surveillance and under thought control. Despite such
restrictions, Winston Smith an intellectual and a worker for the party begins
questioning the methods of the party. He sets off on a search for like-minded
people and bumps into Julia. He feels assured to hear that Julia, whom he starts
loving isn't the only one to share his ideology but his happiness is short
lived after he is betrayed.</p>
<p>While reading the book, you can't stop drawing parallels to China or North Korea
where a single party governs and makes heavy use of propaganda and surveillance
to control and monitor it's citizens. Though the book was written in 1949, it's
timeless and a breezy read.</p>
Steal like an Artist2013-01-30T00:00:00+00:002013-01-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-01-30:/personal/blog/2013/01/30/steal-like-an-artist/<p><a class="reference external" href="http://www.austinkleon.com/">Austin Kleon</a>, is a US based writer and artist and "Steal like an artist: 10 Things Nobody Told You About Being Creative" is his second book. I found this book in a doctor's waiting room and started paging through because it sounded exciting.</p>
<p>The book comprises 170 pages with half …</p><p><a class="reference external" href="http://www.austinkleon.com/">Austin Kleon</a>, is a US based writer and artist and "Steal like an artist: 10 Things Nobody Told You About Being Creative" is his second book. I found this book in a doctor's waiting room and started paging through because it sounded exciting.</p>
<p>The book comprises 170 pages with half of them being awesome doodles. I finished the book in 30 minutes and was scratching my head on what new the book had to offer and why it is branded a "NYTimes Best Seller"? The book is mostly a collection of quotes and fairly common advice. Next time you head out to a book store, leaf through this book and replace it at the rack.</p>
Leadership Wisdom2013-01-29T00:00:00+00:002013-01-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-01-29:/personal/blog/2013/01/29/leadership-wisdom/<p>I am a big fan of Robin Sharma's "The Monk who sold his Ferrari". The story telling technique to communicate personal improvement goals stands out among books of Dale Carnegie, Stephen Covey etc.</p>
<p>"Leadership Wisdom by the monk who sold his Ferrari" adopts the same story telling technique to convey …</p><p>I am a big fan of Robin Sharma's "The Monk who sold his Ferrari". The story telling technique to communicate personal improvement goals stands out among books of Dale Carnegie, Stephen Covey etc.</p>
<p>"Leadership Wisdom by the monk who sold his Ferrari" adopts the same story telling technique to convey leadership values. Julian, a hotshot lawyer reaches Sivana to introspect and learn the secrets of life after recovering from a massive heart attack. At Sivana, set in the peaks of the Himalayas, he learns leadership values from the great sages. The sages instruct him to spread these values far and wide.</p>
<p>Back in America, Julian learns of a friend's company's nose diving fortunes and picks him to pass on the wisdom learnt at Sivana.</p>
<p>If you've read "The Monk who sold his Ferrari", this book can be a bit boring because the story is literally the same and differs in trying to inculcate leadership traits.</p>
The War Ministry2013-01-28T00:00:00+00:002013-01-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-01-28:/personal/blog/2013/01/28/the-war-ministry/<p>The War Ministry is the concluding book of the Raisina Series by Krishan Partap Singh (after <a class="reference external" href="http://thejaswi.info/personal/blog/2013/01/02/young-turks/">Young Turks</a> and <a class="reference external" href="http://thejaswi.info/personal/blog/2013/01/27/delhi-durbar/">Delhi Durbar</a>).</p>
<p>Azim Khan and Karan Nehru make a comeback in this book and the story resumes from where it left off in the Young Turks. Azim Khan is elevated to …</p><p>The War Ministry is the concluding book of the Raisina Series by Krishan Partap Singh (after <a class="reference external" href="http://thejaswi.info/personal/blog/2013/01/02/young-turks/">Young Turks</a> and <a class="reference external" href="http://thejaswi.info/personal/blog/2013/01/27/delhi-durbar/">Delhi Durbar</a>).</p>
<p>Azim Khan and Karan Nehru make a comeback in this book and the story resumes from where it left off in the Young Turks. Azim Khan is elevated to the post of the PM after the death of his predecessor and in the backdrop of a victory in a war over Pakistan. Karan Nehru, the deputy PM still nurses the wounds of betrayal by Azim. The country is faced with yet another war with China and a sagging economy. Karan Nehru takes advantage of this situation to make Azim Khan's life miserable.</p>
<p>Will Azim Khan survive these antics and come out stronger? That's the question one has on their minds while reading "The War Ministry".</p>
<p>This book has multiple yet interesting sub-plots interleaved with flashbacks and a lot of pain is taken to sketch out the characters of Azim Khan and Karan Nehru. While reading the book, you automatically try to relate the characters with our real-life politicians but you will be disappointed.</p>
<p>The "Raisina Series" is an engrossing read for political thriller lovers but just remember to read "The Delhi Durbar" first before you catch up on "The Young Turks" and "The War Ministry".</p>
Delhi Durbar2013-01-27T00:00:00+00:002013-01-27T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2013-01-27:/personal/blog/2013/01/27/delhi-durbar/<p>Delhi Durbar is the second book (first being <a class="reference external" href="http://thejaswi.info/personal/blog/2013/01/02/young-turks/">Young Turks</a>) in the Raisina Series by Krishan Partap Singh. In this book, Jasjit Sidhu inherits his father's power brokering business after his death and forced to return to India leaving his cushy investment banker job abroad. Here, he finds himself falling …</p><p>Delhi Durbar is the second book (first being <a class="reference external" href="http://thejaswi.info/personal/blog/2013/01/02/young-turks/">Young Turks</a>) in the Raisina Series by Krishan Partap Singh. In this book, Jasjit Sidhu inherits his father's power brokering business after his death and forced to return to India leaving his cushy investment banker job abroad. Here, he finds himself falling all over again for his ex-wife, now the daughter of the President of India while working for the Prime Minister, a betenoire of the President.</p>
<p>This President, a retired Army chief refuses to be bracketed as the constitutional rubber stamp and gets proactive in creating trouble for the PM camp. Sidhu finds himself torn between the love of his life and his job. How he balances the two and prevents his father-in-law from becoming the first dictator of India forms the crux of the story.</p>
<p>Azim Khan and Karan Nehru, the protagonists from the Young Turks play a minor role in this book. Sidhu who is physically tortured by army commandos to leak his camp's secret is willing to die than divulge them but meekly offers them to Azim Khan later in the story because he realizes his patriotic duty is very unconvincing. After reading the book, I was left wondering the connection with the first book and probably this book should've been the first book of the series. If you plan to read the Raisina Series, my recommendation is that you start with the Delhi Durbar before you move on to the rest.</p>
Upload a directory to Rackspace Cloud Files from command line2013-01-02T22:42:56+00:002013-01-02T22:42:56+00:00Thejaswi Puthrayatag:thejaswi.info,2013-01-02:/tech/blog/2013/01/02/upload-a-directory-to-rackspace-cloud-files-from-command-line/<p>Here's a simple bash script that uploads a directory to Rackspace Cloud Files and may later on be served as a static website.</p>
<p>First we have to authenticate to get the authentication token that has to be passed for every request:</p>
<div class="highlight"><pre><span></span>$ curl -v -X GET -H <span class="s2">"X-Auth-User: <username>"</span> -H <span class="s2">"X-Auth-Key …</span></pre></div><p>Here's a simple bash script that uploads a directory to Rackspace Cloud Files and may later on be served as a static website.</p>
<p>First we have to authenticate to get the authentication token that has to be passed for every request:</p>
<div class="highlight"><pre><span></span>$ curl -v -X GET -H <span class="s2">"X-Auth-User: <username>"</span> -H <span class="s2">"X-Auth-Key: <api_key>"</span> <span class="s2">"https://identity.api.rackspacecloud.com/v1.0"</span>
</pre></div>
<p>Copy the <cite>X-Auth-Token</cite> and <cite>X-Storage-Url</cite> from the response.</p>
<p>Change into a directory that you want to upload and run the following command:</p>
<div class="highlight"><pre><span></span><span class="k">for</span> ii in <span class="sb">`</span>find ./ -name <span class="s1">'*'</span><span class="p">|</span>cut -b <span class="m">3</span>-<span class="p">|</span>grep -v -P <span class="s1">'^$'</span><span class="sb">`</span><span class="p">;</span> <span class="k">do</span>
curl -X PUT -T <span class="nv">$ii</span> -H <span class="s2">"X-Auth-Token: <auth_token>"</span> <span class="s2">"<storage_url>/<container_name>/</span><span class="nv">$ii</span><span class="s2">"</span><span class="p">;</span>
<span class="k">done</span>
</pre></div>
Young Turks2013-01-02T19:56:41+00:002013-01-02T19:56:41+00:00Thejaswi Puthrayatag:thejaswi.info,2013-01-02:/personal/blog/2013/01/02/young-turks/<p>It's our perception that it takes ages to rise in politics and hence it is dominated by the 'old'. The "Young Turks" by Krishan Partap Singh debunks that perception (how I wish it were true in real life). It captures the rise of two friends with contrasting personalities who have …</p><p>It's our perception that it takes ages to rise in politics and hence it is dominated by the 'old'. The "Young Turks" by Krishan Partap Singh debunks that perception (how I wish it were true in real life). It captures the rise of two friends with contrasting personalities who have found their way into politics through accident.</p>
<p>After school, Karan Nehru and Azim Khan go their separate ways to a career of their choice. But fate reunites them as coalition partners in Delhi as cabinet ministers. They have reached this stage after a lot of manipulation and overcoming political hurdles. When the PM's post is within striking distance, their egos clash and they stop seeing eye to eye. But through mediation, they reach a deal for the post of the PM. Who gains in the deal is the suspense and you have to read it to unravel it.</p>
<p>Though the book is fictional, quite a lot of effort has gone into making it feel authentic like in the references to protocols, parliamentary procedures and locations. The highlight of the book for me was that the politicians are depicted as 'ordinary' humans with their share of vulnerabilities and strengths.</p>
Getting Real2013-01-01T19:21:03+00:002013-01-01T19:21:03+00:00Thejaswi Puthrayatag:thejaswi.info,2013-01-01:/personal/blog/2013/01/01/getting-real/<p><a class="reference external" href="http://gettingreal.37signals.com/">Getting Real</a> is a best-selling book from 37Signals (the authors of <a class="reference external" href="http://thejaswi.info/personal/blog/2012/01/21/rework/">Rework</a>) with the tagline "The smarter, faster, easier way to build a successful web application".</p>
<p>The book discusses the practices followed and observations of 37Signals in building <a class="reference external" href="https://en.wikipedia.org/wiki/Software_as_a_service">SaaS</a> (restricted to webapps). It commences by emphasizing that "Less is the …</p><p><a class="reference external" href="http://gettingreal.37signals.com/">Getting Real</a> is a best-selling book from 37Signals (the authors of <a class="reference external" href="http://thejaswi.info/personal/blog/2012/01/21/rework/">Rework</a>) with the tagline "The smarter, faster, easier way to build a successful web application".</p>
<p>The book discusses the practices followed and observations of 37Signals in building <a class="reference external" href="https://en.wikipedia.org/wiki/Software_as_a_service">SaaS</a> (restricted to webapps). It commences by emphasizing that "Less is the new More!". Less software, Less complexity, Less features resulting in "More Peace" for the developers and "More Value" for the customer. There is sufficient coverage of the other aspects like fund-raising, hiring, prioritization, customer support etc.</p>
<p>Each facet of building a web app receives a couple of pages of coverage and at 177 pages it is very breezy but you may have to ignore a few contradictions in the book. When the book is available for free, what's your excuse for not reading it especially when it offers the experience of building software from one of the best web development companies?</p>
Lashkar2012-12-30T18:39:29+00:002012-12-30T18:39:29+00:00Thejaswi Puthrayatag:thejaswi.info,2012-12-30:/personal/blog/2012/12/30/lashkar/<p>Robert Ludlum is a very famous author in the spy and war genre. Mukul Deva may be considered his Indian counterpart with best sellers like Lashkar and Salim Must Die.</p>
<p>Lashkar is the story of India's response to a terrorist attack in Delhi by LeT. The story intersperses some real …</p><p>Robert Ludlum is a very famous author in the spy and war genre. Mukul Deva may be considered his Indian counterpart with best sellers like Lashkar and Salim Must Die.</p>
<p>Lashkar is the story of India's response to a terrorist attack in Delhi by LeT. The story intersperses some real events with fiction and by the end of the book you only wish that the fictional portions were true. The story starts off with serial blasts in Delhi and how some of the perpetrators of the attack give the law enforcement agencies a miss. The Indian government which is tired of exposing Pakistan's proxy war decides enough is enough and goes after the masterminds and the terrorists involved (this is is part which you wish was non-fiction, but alas!). There is a parallel story of Iqbal, a terrorist who is seeking redemption for the grave crimes he committed.</p>
<p>Unlike a Ludlum, this book is light on details but the fast pace and the non-linear narration more than make up for it and you are gripped on to the book till the last page.</p>
Gently falls the Bakula2012-12-25T20:11:23+00:002012-12-25T20:11:23+00:00Thejaswi Puthrayatag:thejaswi.info,2012-12-25:/personal/blog/2012/12/25/gently-falls-the-bakula/<p>Sudha Murthy is the chairperson of the Infosys Foundation and a partner at Catmaran ventures. She is the better half of Infosys founder Narayan Murthy. More importantly she is a very successful author having written about half a dozen books.</p>
<p>"Gently falls the Bakula" is the story of a girl …</p><p>Sudha Murthy is the chairperson of the Infosys Foundation and a partner at Catmaran ventures. She is the better half of Infosys founder Narayan Murthy. More importantly she is a very successful author having written about half a dozen books.</p>
<p>"Gently falls the Bakula" is the story of a girl who sacrifices her education and aspirations for her husband whom she loves very dearly. She makes tremendous sacrifices to alleviate the obstacles in his career only to get growing loneliness with his success. Throughout, she is optimistic that her husband will notice her and her in-laws will give her due but finally moves on to pursue history, her first love.</p>
<p>The narration is brisk and does not tend to be objective. Though written about 30 years ago (in Kannada), it feels like an oft-heard story now.</p>
The Wisdom of Kahlil Gibran2012-12-24T19:47:21+00:002012-12-24T19:47:21+00:00Thejaswi Puthrayatag:thejaswi.info,2012-12-24:/personal/blog/2012/12/24/the-wisdom-of-kahlil-gibran/<p>Kahlil Gibran was an American poet and author of Lebanese descent. His famous works include <a class="reference external" href="http://thejaswi.info/personal/blog/2011/07/08/the-wanderer-and-the-prophet/">The Prophet</a> and <a class="reference external" href="http://thejaswi.info/personal/blog/2011/07/08/the-wanderer-and-the-prophet/">The Wanderer</a>. When you like an author's books, the probability of picking another is very high and this is how I ended reading this book.</p>
<p>The book is a collection of couplets …</p><p>Kahlil Gibran was an American poet and author of Lebanese descent. His famous works include <a class="reference external" href="http://thejaswi.info/personal/blog/2011/07/08/the-wanderer-and-the-prophet/">The Prophet</a> and <a class="reference external" href="http://thejaswi.info/personal/blog/2011/07/08/the-wanderer-and-the-prophet/">The Wanderer</a>. When you like an author's books, the probability of picking another is very high and this is how I ended reading this book.</p>
<p>The book is a collection of couplets and short poems from his various books. Most of them are timeless and we can relate them even today. Here are a couple that I really loved:</p>
<p>"For a criminal who is weak and poor the narrow cell of death awaits but honour and glory await the rich who conceal their crimes behind their gold and silver and inherited glory."</p>
<p>"In the mouth of society are many diseased teeth, decayed to the bones of the jaws. But society makes no efforts to have them extracted and be rid of the affliction. It contents itself with gold fillings. Many are the dentists who treat the decayed teeth of society with glittering gold."</p>
Thank you Jeeves2012-12-23T00:00:00+00:002012-12-23T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2012-12-23:/personal/blog/2012/12/23/thank-you-jeeves/<p>Can Jeeves be loyal to Bertram Wooster even when not not under his employment? This is the premise of P.G Wodehouse's "Thank you Jeeves". Bertram Wooster is evicted from his apartment and Jeeves resigns unable to bear his master's new found love for the Banjo. Wooster takes refuge at …</p><p>Can Jeeves be loyal to Bertram Wooster even when not not under his employment? This is the premise of P.G Wodehouse's "Thank you Jeeves". Bertram Wooster is evicted from his apartment and Jeeves resigns unable to bear his master's new found love for the Banjo. Wooster takes refuge at his childhood friend's cottage only to bump into one of his exes and her volatile father. His ex-girlfriend is engaged to his host and despite his efforts to stay away from them, a series of mishaps turn the plot around and his childhood friend suspects he is here to break his engagement and woo his fiance. How Jeeves, now under the employment of Wooster's host and childhood friend extricates him from this delicate situation makes a very interesting story.</p>
<p>It's a trademark Wodehouse with the little twist of Jeeves not being on Wooster's side for most of the story.</p>
The Code of the Woosters2012-11-17T17:43:18+00:002012-11-17T17:43:18+00:00Thejaswi Puthrayatag:thejaswi.info,2012-11-17:/personal/blog/2012/11/17/the-code-of-the-woosters/<p>What exactly is "The Code of the Woosters"? If you've read about Bertie Wooster, you may imagine it refers to the drinking binges or getting engaged every other morning but breaking up by evening.</p>
<p>Bertie is recovering from a bachelor party hosted for his friend Gussie engaged to Madeline (no …</p><p>What exactly is "The Code of the Woosters"? If you've read about Bertie Wooster, you may imagine it refers to the drinking binges or getting engaged every other morning but breaking up by evening.</p>
<p>Bertie is recovering from a bachelor party hosted for his friend Gussie engaged to Madeline (no prizes for guessing that Bertie was engaged to her previously) when his Aunt Dahlia dispatches him to depress the price of a cow creamer for her husband. On the job, Bertie bumps into Sir Bassett, his uncle's rival cow cream collector and a judge who had convicted Bertie for a petty theft earlier. Bertie fumbles at the task and is mistaken for a 'pincher' but escapes the wrath of the judge by fleeing the scene. Circumstances compel him to visit the Bassett's residence to reconcile Madeline (daughter of Sir Bassett) with Gussie but his visit rouses suspicions of his intentions as Sir Bassett has purchased the cow creamer. As always, Bertie ends up in a thicker soup and Jeeves brings his life ashore.</p>
<p>As in Jeeves' series, the ending is a happy one with Bertie accomplishing his primary task of mending the broken engagement of his best friend Gussie and Madeline and living up to "The Code of the Woosters" of "Never letting a pal down".</p>
<p>Despite the plot being predictable, the sheer number of times Bertie finds himself in the dock yet manages to wriggle out from each of them makes the book a delight to read.</p>
To kill a mocking bird2012-11-01T18:07:21+00:002012-11-01T18:07:21+00:00Thejaswi Puthrayatag:thejaswi.info,2012-11-01:/personal/blog/2012/11/01/to-kill-a-mocking-bird/<p>The movie with the same name has been recommended by scores of friends and I haven't been able to watch it. At the library that I recently joined, they had the book by Harper Lee and I thought why not read the book than watch the movie.</p>
<p>Atticus Finch, is …</p><p>The movie with the same name has been recommended by scores of friends and I haven't been able to watch it. At the library that I recently joined, they had the book by Harper Lee and I thought why not read the book than watch the movie.</p>
<p>Atticus Finch, is a widower with two children and a lawyer by profession. His nine year old daughter is the narrator of the story and it is based on the trial of a black who is falsely accused of rape and how Atticus breaks all social norms to defend the victim while maintaining the highest moral standards for himself and his children to imbibe.</p>
<p>The book is brilliant and should be on everyone's reading list. It has some gem of dialogues, one of which has got imprinted in my mind. When Atticus is snubbed by his own race for defending the black at court and his daughter gets agitated, he urges her not to react and adds that "They are certainly entitled to think that (they are right), and they're entitled to full respect for their opinions...before I can live with other folks I've got to live with myself. The one thing that doesn't abide by majority rule is a person's conscience".</p>
<p>I hoped that I would not have to watch the movie after I was done with the book but now I am even more keen to watch it to see how they have adapted the story for the screen.</p>
The missing documentation for django.utils.datastructures2012-11-01T17:47:07+00:002012-11-01T17:47:07+00:00Thejaswi Puthrayatag:thejaswi.info,2012-11-01:/tech/blog/2012/11/01/the-missing-documentation-for-djangoutilsdatastructures/<p>Cross posted from my work <a class="reference external" href="http://agiliq.com/blog/2012/11/the-missing-documentation-for-djangoutilsdatastruc/">blog</a>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><tt class="docutils literal">django.utils.datastructures</tt> is intentionally not documented by the django
core devs because it is an internal API and is liable to change without any
notice. This file is not governed by django's lenient backwards-compatible
policy. You have been sufficiently warned!</p>
</div>
<p>With the …</p><p>Cross posted from my work <a class="reference external" href="http://agiliq.com/blog/2012/11/the-missing-documentation-for-djangoutilsdatastruc/">blog</a>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><tt class="docutils literal">django.utils.datastructures</tt> is intentionally not documented by the django
core devs because it is an internal API and is liable to change without any
notice. This file is not governed by django's lenient backwards-compatible
policy. You have been sufficiently warned!</p>
</div>
<p>With the note out of the way, let's look at the interesting <a class="reference external" href="https://en.wikipedia.org/wiki/Data_structure">datastructures</a> in
this file. You may ask why we should learn about those when we shouldn't be
using them? Reading code is the best way of learning and this file has some
beautiful code.</p>
<p><tt class="docutils literal">MergeDict</tt> is the first of the datastructures in the file. It provides a
dictionary like interface but can look up from multiple dictionaries provided
during the initialization.</p>
<p>Here's an example:</p>
<div class="highlight"><pre><span></span><span class="o">>>></span> <span class="n">md</span> <span class="o">=</span> <span class="n">MergeDict</span><span class="p">({</span><span class="s2">"foo"</span><span class="p">:</span> <span class="s2">"bar"</span><span class="p">,</span> <span class="s2">"moo"</span><span class="p">:</span> <span class="s2">"cow"</span><span class="p">},</span> <span class="p">{</span><span class="s2">"abc"</span><span class="p">:</span> <span class="s2">"def"</span><span class="p">})</span>
<span class="o">>>></span> <span class="n">md</span><span class="p">[</span><span class="s2">"foo"</span><span class="p">]</span>
<span class="s1">'bar'</span>
<span class="o">>>></span> <span class="n">md</span><span class="p">[</span><span class="s2">"abc"</span><span class="p">]</span>
<span class="s1">'def'</span>
<span class="o">>>></span> <span class="n">md</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"abc"</span><span class="p">)</span>
<span class="s1">'def'</span>
<span class="o">>>></span> <span class="n">md</span><span class="p">[</span><span class="s2">"xyz"</span><span class="p">]</span>
<span class="ne">KeyError</span><span class="p">:</span>
<span class="o">>>></span> <span class="n">md</span><span class="o">.</span><span class="n">items</span><span class="p">()</span>
<span class="p">[(</span><span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'bar'</span><span class="p">),</span> <span class="p">(</span><span class="s1">'moo'</span><span class="p">,</span> <span class="s1">'cow'</span><span class="p">),</span> <span class="p">(</span><span class="s1">'abc'</span><span class="p">,</span> <span class="s1">'def'</span><span class="p">)]</span>
<span class="o">>>></span> <span class="n">md</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
<span class="p">[</span><span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'moo'</span><span class="p">,</span> <span class="s1">'abc'</span><span class="p">]</span>
<span class="o">>>></span> <span class="n">md</span><span class="o">.</span><span class="n">values</span><span class="p">()</span>
<span class="p">[</span><span class="s1">'bar'</span><span class="p">,</span> <span class="s1">'cow'</span><span class="p">,</span> <span class="s1">'def'</span><span class="p">]</span>
</pre></div>
<p>The MergeDict is used within django in attaching values with a form widget and in
<tt class="docutils literal">request.REQUEST</tt>.</p>
<p>The built-in dictionary does not maintain the order of the items but the
<tt class="docutils literal">SortedDict</tt> is a subclass of the built-in dictionary that maintains the keys
in exactly the same order they were inserted.</p>
<p>Here's an example:</p>
<div class="highlight"><pre><span></span><span class="o">>>></span> <span class="n">dd</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"foo"</span><span class="p">:</span> <span class="s2">"bar"</span><span class="p">,</span> <span class="s2">"moo"</span><span class="p">:</span> <span class="s2">"cow"</span><span class="p">,</span> <span class="s2">"abc"</span><span class="p">:</span> <span class="s2">"def"</span><span class="p">}</span>
<span class="p">{</span><span class="s2">"abc"</span><span class="p">:</span> <span class="s2">"def"</span><span class="p">,</span> <span class="s2">"foo"</span><span class="p">:</span> <span class="s2">"bar"</span><span class="p">,</span> <span class="s2">"moo"</span><span class="p">:</span> <span class="s2">"cow"</span><span class="p">}</span>
<span class="o">>>></span> <span class="n">sd</span> <span class="o">=</span> <span class="n">SortedDict</span><span class="p">(((</span><span class="s2">"foo"</span><span class="p">,</span> <span class="s2">"bar"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"moo"</span><span class="p">,</span> <span class="s2">"cow"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"abc"</span><span class="p">,</span> <span class="s2">"def"</span><span class="p">)))</span>
<span class="p">{</span><span class="s2">"foo"</span><span class="p">:</span> <span class="s2">"bar"</span><span class="p">,</span> <span class="s2">"moo"</span><span class="p">:</span> <span class="s2">"cow"</span><span class="p">,</span> <span class="s2">"abc"</span><span class="p">:</span> <span class="s2">"def"</span><span class="p">}</span>
<span class="o">>>></span> <span class="n">dd</span><span class="p">[</span><span class="s2">"xyz"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"pqr"</span>
<span class="o">>>></span> <span class="n">dd</span>
<span class="p">{</span><span class="s1">'abc'</span><span class="p">:</span> <span class="s1">'def'</span><span class="p">,</span> <span class="s1">'foo'</span><span class="p">:</span> <span class="s1">'bar'</span><span class="p">,</span> <span class="s1">'moo'</span><span class="p">:</span> <span class="s1">'cow'</span><span class="p">,</span> <span class="s1">'xyz'</span><span class="p">:</span> <span class="s1">'pqr'</span><span class="p">}</span>
<span class="o">>>></span> <span class="n">dd</span><span class="p">[</span><span class="s2">"lmn"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"ghi"</span>
<span class="o">>>></span> <span class="n">dd</span>
<span class="p">{</span><span class="s1">'abc'</span><span class="p">:</span> <span class="s1">'def'</span><span class="p">,</span> <span class="s1">'foo'</span><span class="p">:</span> <span class="s1">'bar'</span><span class="p">,</span> <span class="s1">'lmn'</span><span class="p">:</span> <span class="s1">'ghi'</span><span class="p">,</span> <span class="s1">'moo'</span><span class="p">:</span> <span class="s1">'cow'</span><span class="p">,</span> <span class="s1">'xyz'</span><span class="p">:</span> <span class="s1">'pqr'</span><span class="p">}</span>
<span class="o">>>></span> <span class="n">sd</span><span class="p">[</span><span class="s2">"xyz"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"pqr"</span>
<span class="o">>>></span> <span class="n">sd</span>
<span class="p">{</span><span class="s1">'foo'</span><span class="p">:</span> <span class="s1">'bar'</span><span class="p">,</span> <span class="s1">'moo'</span><span class="p">:</span> <span class="s1">'cow'</span><span class="p">,</span> <span class="s1">'abc'</span><span class="p">:</span> <span class="s1">'def'</span><span class="p">,</span> <span class="s1">'xyz'</span><span class="p">:</span> <span class="s1">'pqr'</span><span class="p">}</span>
<span class="o">>>></span> <span class="n">sd</span><span class="p">[</span><span class="s2">"lmn"</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"ghi"</span>
<span class="p">{</span><span class="s1">'foo'</span><span class="p">:</span> <span class="s1">'bar'</span><span class="p">,</span> <span class="s1">'moo'</span><span class="p">:</span> <span class="s1">'cow'</span><span class="p">,</span> <span class="s1">'abc'</span><span class="p">:</span> <span class="s1">'def'</span><span class="p">,</span> <span class="s1">'xyz'</span><span class="p">:</span> <span class="s1">'pqr'</span><span class="p">,</span> <span class="s1">'lmn'</span><span class="p">:</span> <span class="s1">'ghi'</span><span class="p">}</span>
</pre></div>
<p>The <tt class="docutils literal">SortedDict</tt> is fairly widely used inside of django generally to build a
hierarchy (like models and it's parents), maintaining the order of the form fields while iterating etc.</p>
<p>In python 2.7, a new datastructure was introduced that mimics the SortedDict in
the <a class="reference external" href="http://docs.python.org/2/library/collections.html">collections</a> module and is called <a class="reference external" href="http://docs.python.org/2/library/collections.html#collections.OrderedDict">OrderedDict</a>.</p>
<p><tt class="docutils literal">MultiValueDict</tt> is a dictionary subclass that can handle multiple values
assigned to a key.</p>
<p>Here's an example:</p>
<div class="highlight"><pre><span></span><span class="o">>>></span> <span class="n">dd</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"abc"</span><span class="p">:</span> <span class="s2">"def"</span><span class="p">,</span> <span class="s2">"foo"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"bar1"</span><span class="p">,</span> <span class="s2">"bar2"</span><span class="p">]}</span>
<span class="o">>>></span> <span class="n">dd</span><span class="p">[</span><span class="s2">"foo"</span><span class="p">]</span>
<span class="p">[</span><span class="s1">'bar1'</span><span class="p">,</span> <span class="s1">'bar2'</span><span class="p">]</span>
<span class="o">>>></span> <span class="n">mvd</span> <span class="o">=</span> <span class="n">MultiValueDict</span><span class="p">({</span><span class="s2">"abc"</span><span class="p">:</span> <span class="s2">"def"</span><span class="p">,</span> <span class="s2">"foo"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"bar1"</span><span class="p">,</span> <span class="s2">"bar2"</span><span class="p">]})</span>
<span class="o">>>></span> <span class="n">mvd</span><span class="p">[</span><span class="s2">"foo"</span><span class="p">]</span>
<span class="s1">'bar2'</span>
<span class="o">>>></span> <span class="n">mvd</span><span class="o">.</span><span class="n">getlist</span><span class="p">(</span><span class="s2">"foo"</span><span class="p">)</span>
<span class="p">[</span><span class="s1">'bar1'</span><span class="p">,</span> <span class="s1">'bar2'</span><span class="p">]</span>
<span class="o">>>></span> <span class="n">mvd</span><span class="o">.</span><span class="n">getlist</span><span class="p">(</span><span class="s1">'blah'</span><span class="p">)</span>
<span class="p">[]</span>
<span class="o">>>></span> <span class="n">mvd</span><span class="o">.</span><span class="n">getlist</span><span class="p">(</span><span class="s1">'abc'</span><span class="p">)</span>
<span class="s1">'def'</span>
<span class="o">>>></span> <span class="n">mvd</span><span class="o">.</span><span class="n">setlist</span><span class="p">(</span><span class="s1">'xyz'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'pqr'</span><span class="p">,</span> <span class="s1">'ghi'</span><span class="p">])</span>
<span class="o">>>></span> <span class="n">mvd</span>
<span class="o"><</span><span class="n">MultiValueDict</span><span class="p">:</span> <span class="p">{</span><span class="s1">'xyz'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'pqr'</span><span class="p">,</span> <span class="s1">'ghi'</span><span class="p">],</span> <span class="s1">'abc'</span><span class="p">:</span> <span class="s1">'def'</span><span class="p">,</span> <span class="s1">'foo'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'foo1'</span><span class="p">,</span> <span class="s1">'foo2'</span><span class="p">]}</span><span class="o">></span>
<span class="o">>>></span> <span class="n">mvd</span><span class="o">.</span><span class="n">appendlist</span><span class="p">(</span><span class="s1">'xyz'</span><span class="p">,</span> <span class="s1">'ijk'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">mvd</span>
<span class="o"><</span><span class="n">MultiValueDict</span><span class="p">:</span> <span class="p">{</span><span class="s1">'xyz'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'pqr'</span><span class="p">,</span> <span class="s1">'ghi'</span><span class="p">,</span> <span class="s1">'ijk'</span><span class="p">],</span> <span class="s1">'abc'</span><span class="p">:</span> <span class="s1">'def'</span><span class="p">,</span> <span class="s1">'foo'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'foo1'</span><span class="p">,</span> <span class="s1">'foo2'</span><span class="p">]}</span><span class="o">></span>
<span class="o">>>></span> <span class="n">mvd</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s1">'xyz'</span><span class="p">:</span> <span class="s1">'lmn'</span><span class="p">})</span>
<span class="o">>>></span> <span class="n">mvd</span>
<span class="o"><</span><span class="n">MultiValueDict</span><span class="p">:</span> <span class="p">{</span><span class="s1">'xyz'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'pqr'</span><span class="p">,</span> <span class="s1">'ghi'</span><span class="p">,</span> <span class="s1">'ijk'</span><span class="p">,</span> <span class="s1">'lmn'</span><span class="p">],</span> <span class="s1">'abc'</span><span class="p">:</span> <span class="s1">'def'</span><span class="p">,</span> <span class="s1">'foo'</span><span class="p">:</span> <span class="p">[</span><span class="s1">'foo1'</span><span class="p">,</span> <span class="s1">'foo2'</span><span class="p">]}</span><span class="o">></span>
</pre></div>
<p>The <tt class="docutils literal">MultiValueDict</tt> is used in binding data to <tt class="docutils literal">request.POST</tt>, the files to <tt class="docutils literal">request.FILES</tt>
and in the get parameter parsing.</p>
<p>The <tt class="docutils literal">ImmutableList</tt> is an immutable datastructure that raises errors when it is
attempted to be mutated.</p>
<p>Here's an example:</p>
<div class="highlight"><pre><span></span><span class="o">>>></span> <span class="n">il</span> <span class="o">=</span> <span class="n">ImmutableList</span><span class="p">([</span><span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'bar'</span><span class="p">,</span> <span class="s1">'abc'</span><span class="p">])</span>
<span class="o">>>></span> <span class="n">il</span> <span class="o">+=</span> <span class="s1">'lmn'</span>
<span class="ne">AttributeError</span><span class="p">:</span> <span class="n">ImmutableList</span> <span class="nb">object</span> <span class="ow">is</span> <span class="n">immutable</span><span class="o">.</span>
<span class="o">>>></span> <span class="n">il</span> <span class="o">=</span> <span class="n">ImmutableList</span><span class="p">([</span><span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'bar'</span><span class="p">,</span> <span class="s1">'abc'</span><span class="p">],</span> <span class="n">warning</span><span class="o">=</span><span class="s1">'Custom warning'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">il</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="mi">123</span>
<span class="ne">AttributeError</span><span class="p">:</span> <span class="n">Custom</span> <span class="n">warning</span>
</pre></div>
<p>The <tt class="docutils literal">ImmutableList</tt> is used in <tt class="docutils literal">request.upload_handlers</tt> to prevent
modification after the <tt class="docutils literal">request.POST</tt> or <tt class="docutils literal">request.FILES</tt> have been accessed.</p>
<p>The <tt class="docutils literal">DictWrapper</tt> is a subclass of the built-in dictionary that prefixes the keys.
It takes a dictionary, a function and a prefix as arguments. If a specific key lookup
begins with the prefix then the value is passed through the function before it is
returned.</p>
<p>Here's an example:</p>
<div class="highlight"><pre><span></span><span class="o">>>></span> <span class="n">dw</span> <span class="o">=</span> <span class="n">DictWrapper</span><span class="p">({</span><span class="s1">'foo'</span><span class="p">:</span> <span class="s1">'bar'</span><span class="p">,</span> <span class="s1">'moo'</span><span class="p">:</span> <span class="s1">'cow'</span><span class="p">},</span> <span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">,</span> <span class="s1">'abc_'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">dw</span><span class="p">[</span><span class="s1">'foo'</span><span class="p">]</span>
<span class="s1">'bar'</span>
<span class="o">>>></span> <span class="n">dw</span><span class="p">[</span><span class="s1">'abc_foo'</span><span class="p">]</span>
<span class="s1">'bar'</span>
<span class="o">>>></span> <span class="n">dw</span><span class="p">[</span><span class="s1">'xyz_foo'</span><span class="p">]</span>
<span class="ne">KeyError</span><span class="p">:</span> <span class="s1">'xyz_foo'</span>
<span class="o">>>></span> <span class="k">def</span> <span class="nf">post_process_value</span><span class="p">(</span><span class="n">value</span><span class="p">):</span>
<span class="o">...</span> <span class="k">return</span> <span class="s2">"The value is "</span> <span class="o">+</span> <span class="n">value</span>
<span class="o">>>></span> <span class="n">dw</span> <span class="o">=</span> <span class="n">DictWrapper</span><span class="p">({</span><span class="s1">'foo'</span><span class="p">:</span> <span class="s1">'bar'</span><span class="p">,</span> <span class="s1">'moo'</span><span class="p">:</span> <span class="s1">'cow'</span><span class="p">},</span> <span class="n">post_process_value</span><span class="p">,</span> <span class="s1">'abc_'</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">dw</span><span class="p">[</span><span class="s1">'foo'</span><span class="p">]</span>
<span class="s1">'bar'</span>
<span class="o">>>></span> <span class="n">dw</span><span class="p">[</span><span class="s1">'abc_foo'</span><span class="p">]</span>
<span class="s1">'The value is bar'</span>
</pre></div>
<p>The <tt class="docutils literal">DictWrapper</tt> is used in quoting names for SQL queries with the key prefix.</p>
<p>Hope you enjoyed learning about these hidden gems and how django works under the hood but
take the note on the top into consideration.</p>
The Alchemist2012-10-24T14:56:00+00:002012-10-24T14:56:00+00:00Thejaswi Puthrayatag:thejaswi.info,2012-10-24:/personal/blog/2012/10/24/the-alchemist/<p>I always knew Paulo Coelho's books dealt with a little bit of spiritualism and hence kept these books at bay but ever since he wrote <a class="reference external" href="http://paulocoelhoblog.com/2012/01/20/welcome-to-pirate-my-books/">this</a> blog post encouraging people to pirate his books I was finding an excuse to buy or read one of his books. That time came …</p><p>I always knew Paulo Coelho's books dealt with a little bit of spiritualism and hence kept these books at bay but ever since he wrote <a class="reference external" href="http://paulocoelhoblog.com/2012/01/20/welcome-to-pirate-my-books/">this</a> blog post encouraging people to pirate his books I was finding an excuse to buy or read one of his books. That time came last week when I borrowed "The Alchemist" from a local library.</p>
<p>The book describes the journey of Santiago, a shepherd from Spain to Egypt in pursuit of his dreams. Paulo Coelho very intelligently interleaves the need for one to pursue his dreams with the story and so it doesn't feel outright preachy. Towards the end, I felt the story drifting away when Santiago turns an alchemist but the last couple of pages were humorous. I am glad to have read "The Alchemist" and hopefully will buy one of his books. Any suggestions?</p>
To Cut a Long Story Short2012-10-23T12:30:47+00:002012-10-23T12:30:47+00:00Thejaswi Puthrayatag:thejaswi.info,2012-10-23:/personal/blog/2012/10/23/to-cut-a-long-story-short/<p>Jeffrey Archer is a master story teller. When my eyes fall on a book written by him, I pick it up without a second thought and this is exactly what happened when I saw "To Cut a Long Story Short" in our office library. Yes, <a class="reference external" href="http://agiliq.com/">agiliq</a> has an enviable collection …</p><p>Jeffrey Archer is a master story teller. When my eyes fall on a book written by him, I pick it up without a second thought and this is exactly what happened when I saw "To Cut a Long Story Short" in our office library. Yes, <a class="reference external" href="http://agiliq.com/">agiliq</a> has an enviable collection of PG Wodehouse, Terry Pratchett and Isaac Asimov apart from startup and technical books.</p>
<p>This book is a collection of 15 amazing short stories and like his other short stories largely based on true incidents. Some of the stories that I loved were: The Expert Witness, Crime Pays, Love at First Sight and a Weekend to remember.</p>
The Outsider2012-10-22T12:18:12+00:002012-10-22T12:18:12+00:00Thejaswi Puthrayatag:thejaswi.info,2012-10-22:/personal/blog/2012/10/22/the-outsider/<p>Meursault is informed about his mother's death and barely displays any grief at her funeral. This is how Albert Camus' "The Outsider" starts off. Inmates at the old age home where his mother breathed her last are shocked at his lack of emotions.</p>
<p>Back in the city, Meursault tries to …</p><p>Meursault is informed about his mother's death and barely displays any grief at her funeral. This is how Albert Camus' "The Outsider" starts off. Inmates at the old age home where his mother breathed her last are shocked at his lack of emotions.</p>
<p>Back in the city, Meursault tries to get back to life but gets embroiled in a quarrel between his neighbour and his mistress' Arab family and this quarrel culminates when he kills one of the Arabs in a freak accident. In the trial that follows, the incidents from his mother's funeral are revisited and he is branded as an unrepentant and cold blooded killer and sentenced to death by the guillotine.</p>
<p>While waiting for his execution, Meursault exposes the hypocrisy of the society and finally comes to accept that it is better to be dead than live in such a world.</p>
<p>I browsed through the Wikipedia page on this <a class="reference external" href="https://en.wikipedia.org/wiki/The_Stranger_(novel)">book</a> and wasn't surprised to see that it is an exemplary work in existentialism. This is a high quality translated work that finishes almost as soon as you start it (76 pages) and I would highly recommend it.</p>
Dissecting Phonegap's architecture2012-09-06T22:08:57+00:002012-09-06T22:08:57+00:00Thejaswi Puthrayatag:thejaswi.info,2012-09-06:/tech/blog/2012/09/06/dissecting-phonegaps-architecture/<p>Cross-posted from my <a class="reference external" href="http://agiliq.com/blog/2012/09/dissecting-phonegaps-architecture/">work blog</a>.</p>
<p><a class="reference external" href="http://incubator.apache.org/cordova/">Apache Cordova</a> is a open source cross-platform framework for building native
mobile applications using HTML, CSS and JavaScript. It started off as Phonegap,
a project of Nitobi Software before it was acquired by Adobe Systems. The code
for the platform was donated to the Apache …</p><p>Cross-posted from my <a class="reference external" href="http://agiliq.com/blog/2012/09/dissecting-phonegaps-architecture/">work blog</a>.</p>
<p><a class="reference external" href="http://incubator.apache.org/cordova/">Apache Cordova</a> is a open source cross-platform framework for building native
mobile applications using HTML, CSS and JavaScript. It started off as Phonegap,
a project of Nitobi Software before it was acquired by Adobe Systems. The code
for the platform was donated to the Apache Software foundation and is currently
being incubated as "Apache Cordova".</p>
<p><a class="reference external" href="http://phonegap.com/">Phonegap</a> is now a distribution of Apache Cordova (analogous to Ubuntu being a
Linux distribution) brought to you by Adobe. Since Apache Cordova is licensed
under the permissive Apache Software License, Adobe Phonegap may technically
be integrated with proprietary software (though there's no evidence for the
same yet).</p>
<p>This post is not going to discuss how to build a cross-platform mobile app using
Phonegap and if you are here expecting that, you are better off checking their
<a class="reference external" href="http://docs.phonegap.com/en/2.0.0/guide_getting-started_index.md.html">docs</a>. In this post, we are going to see how Phonegap apps work ie how the
javascript component is able to communicate with the native APIs and vice-versa.</p>
<p>The Cordova guys have taken a lot of pain keep a consistent JS interface on the
client side but underneath there is a large divergence between each platform.</p>
<p>We are going to discuss the architectures of android and iOS since these are
the most widely used platforms and restrict ourselves to version 2.0 of Cordova.</p>
<p>Every phonegap app has the following components:</p>
<ul class="simple">
<li>A chrome-less browser. On iOS and Android, it is WebKit (UIWebView on iOS and
WebView on android to be specific).</li>
<li>JS to Native bridge to allow for communication between the HTML application
and the native platform.</li>
<li>A native to JS bridge to allow the native platform to talk to the HTML
application.</li>
</ul>
<a class="reference external image-reference" href="http://agiliq.com/dumps/images/20120906/android_phonegap.png"><img alt="Android Phonegap architecture" class="align-center" src="http://agiliq.com/dumps/images/20120906/android_phonegap.png" style="width: 705px; height: 498px;" /></a>
<p>In android, by default the JS to Native Bridge is set to <cite>Prompt</cite> (yes, you saw
it right, the venerable JS prompt dialog box). The JS functions (like camera,
contacts etc) are converted to Prompt commands by the cordova javascript and
intercepted by the WebView <a class="reference external" href="http://developer.android.com/reference/android/webkit/WebChromeClient.html#onJsPrompt(android.webkit.WebView,java.lang.String,java.lang.String,java.lang.String,android.webkit.JsPromptResult)">onJsPrompt</a> and based on a specific signature calls
the respective native plugin (camera, contacts etc).</p>
<p>It is also possible to change the JS to Native bridge and another way of
communication is through the <cite>JS_Object</cite> bridge. When the WebView is loaded and
the JS bridge is set, the WebView adds a <a class="reference external" href="http://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface(java.lang.Object,java.lang.String)">Javascript Interface</a> which calls a
Java object (calling the respective native plugin based on the arguments of the
interface).</p>
<p>There is yet another JS to Native bridge (currently experimental) which calls
the native plugins by triggering changes in the location URL.</p>
<p>Now we come to the other end of the communication ie the Native to JS bridge.
By default, the bridge is set to <cite>polling</cite> and the javascript keeps polling the
native side for a response every 50 milliseconds. This is very suboptimal but
the solution works on the largest number of devices and in most setups.</p>
<p>Just like the JS to Native bridge, the Native to JS bridge can also be changed.
Another Native to JS bridge is the XHR bridge (called the <cite>HANGING_GET</cite> internally
as a reference to a long lived XHR connection). This bridge runs a callback server
locally and responds to the XHR requests.</p>
<p>There is yet another bridge that uses Java internal reflection on the webview to
call the methods but is available only on Android 3.2+. There are a couple of other
bridges but don't seem to be in use at this point in time.</p>
<p>Now let's look at how the iOS phonegap apps work.</p>
<a class="reference external image-reference" href="http://agiliq.com/dumps/images/20120906/ios_phonegap.png"><img alt="iOS Phonegap architecture" class="align-center" src="http://agiliq.com/dumps/images/20120906/ios_phonegap.png" style="width: 705px; height: 498px;" /></a>
<p>Compared to Android, iOS has fewer bridges. On iOS 4.2 and below, the JS and Native
bridge communicate with each other through an iframe. The JS calls are stored in a
JS queue which is read and executed by the native component.</p>
<p>The other bridge is an XHR bridge which makes calls to a fake URL with the commands
in the header. These commands are intercepted, serialized and then executed.</p>
<p>For the Native to JS bridge, the iOS phonegap apps have only one bridge and all the
communication happens through a UIWebView method called <a class="reference external" href="https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIWebView_Class/Reference/Reference.html">stringByEvaluatingJavaScriptFromString</a>.</p>
<p>Now that we know how Phonegap apps work, we can write better apps and
plugins and guess where we can improve our application's performance.</p>
Jeeves in the Offing2012-08-22T21:15:54+00:002012-08-22T21:15:54+00:00Thejaswi Puthrayatag:thejaswi.info,2012-08-22:/personal/blog/2012/08/22/jeeves-in-the-offing/<p>Jeeves gets a much needed holiday but Wooster, his master lands in trouble after he finds the 'out of the blue' announcement of his engagement to Bobbie, a girl he had broken up with ages ago. He visits Brinkley Court without his trusted lieutenant, Jeeves to set things right but …</p><p>Jeeves gets a much needed holiday but Wooster, his master lands in trouble after he finds the 'out of the blue' announcement of his engagement to Bobbie, a girl he had broken up with ages ago. He visits Brinkley Court without his trusted lieutenant, Jeeves to set things right but only gets pulled deeper into the other sub plots.</p>
<p>Giving up hope, he recalls Jeeves from his vacation and as always Jeeves works his magic and saves the day. Though it sounds quite predictable, the ending is hilarious. Jeeves bails out Wooster but this comes at a price. The book is worth it just for the ending.</p>
Ring for Jeeves2012-08-21T00:00:00+00:002012-08-21T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2012-08-21:/personal/blog/2012/08/21/ring-for-jeeves/<p>Bill Belfry, the Earl of Rowcester and his temporary valet, Jeeves con Captain Biggar at the derby and have a hard time getting away. Bill needs the money to stay afloat and also sell his leaky mansion.</p>
<p>Bill gets caught and in return for legal immunity is forced to steal …</p><p>Bill Belfry, the Earl of Rowcester and his temporary valet, Jeeves con Captain Biggar at the derby and have a hard time getting away. Bill needs the money to stay afloat and also sell his leaky mansion.</p>
<p>Bill gets caught and in return for legal immunity is forced to steal from one of his guests. Will he be caught once again and will he be able to sell his mansion off is the remaining part.</p>
<p>Having read so many Wodehouse's now, it has got very predictable but you may enjoy the book if you haven't read any of his books so far.</p>
Lawgoff2012-08-04T12:12:20+00:002012-08-04T12:12:20+00:00Thejaswi Puthrayatag:thejaswi.info,2012-08-04:/personal/blog/2012/08/04/lawgoff/<p>Yesterday, I heard the shocking news of the passing away of my mentor and India's prolific Python and django evangelist, Kenneth Gonsalves, KG to friends or <cite>lawgon</cite> by his IRC nick. I had the pleasure of knowing KG for 7 years and working with him on a variety of projects …</p><p>Yesterday, I heard the shocking news of the passing away of my mentor and India's prolific Python and django evangelist, Kenneth Gonsalves, KG to friends or <cite>lawgon</cite> by his IRC nick. I had the pleasure of knowing KG for 7 years and working with him on a variety of projects.</p>
<p>KG was a regular (until a couple of days back) on a host of free software mailing lists and IRC channels and always had an opinion on every topic. I contacted him as a naive undergrad student in my third year eliciting suggestions on how to become a better programmer. He asked me to apply for the Google Summer of Code 2007 through the django project. I was reluctant because I had just heard of this web framework and had no idea about Python. He reassured me that if I worked hard, was sincere and wouldn't expect any spoon feeding, I could succeed. It was with his idea that I applied to the Summer of Code and he kept following up throughout the summer on my progress. After the Summer of Code, I fell in love with django and python and today that's what earns my bread and butter. Not just that, KG was also very instrumental in me landing my first job and I will be forever indebted to him.</p>
<p>I met him in person for the first time in 2008 (in the less than half a dozen times I have met him) after having interacted with him for 2 years by email. He was a down to earth person with dry humour which contrasted his arrogant online persona. It was during this encounter that I learnt that he was a heavy smoker. I asked him if no one in his family objected but he curtly replied that "No one argues with a lawyer"!</p>
<p>KG and I worked on a couple of django projects (in my spare time) and he was the ideal project manager (apart from the programmer). He always took the pressure off me and negotiated with clients to practice the code-release-repeat (fancifully called 'agile' in corporate jargon) software development methodology. He also worked as a consultant for numerous companies, migrated them to python and django and also helped in recruiting for them.</p>
<p>But his biggest contribution was as a 'teacher'. He travelled all over India to colleges training thousands of students on free software, Python, Django, OSM and most importantly using IRC and mailing lists to request help.</p>
<p>During my last meeting with him in April, I asked him why he started using a new IRC nick. He answered that 'lawgon' (his famous nome de guerre) was his nick at work and 'lawgoff' at home. I didn't even expect that it would be my last meeting with him and he would 'lawgoff' from the world leaving thousands of free software enthusiasts and budding college students mourning.</p>
<p>My condolences are with the family and hope they take comfort in the fact that he made a huge difference to the causes he dedicated his life to. RIP KG, you will be missed.</p>
Dropbox file upload handler for django2012-07-17T17:11:43+00:002012-07-17T17:11:43+00:00Thejaswi Puthrayatag:thejaswi.info,2012-07-17:/tech/blog/2012/07/17/dropbox-file-upload-handler-for-django/<p>Cross posted from <a class="reference external" href="http://agiliq.com/blog/2012/07/dropbox-file-upload-handler-for-django/">work blog</a>.</p>
<p>Dropbox <a class="reference external" href="http://blog.dropbox.com/index.php/new-dropbox-pro-plans/">announced</a> new pro plans last week and some accounts have had their
storage size doubled. Wouldn't it be wonderful if we could upload all our
files to dropbox from our django webapp?</p>
<p>In this post, I write a custom file upload handler that will …</p><p>Cross posted from <a class="reference external" href="http://agiliq.com/blog/2012/07/dropbox-file-upload-handler-for-django/">work blog</a>.</p>
<p>Dropbox <a class="reference external" href="http://blog.dropbox.com/index.php/new-dropbox-pro-plans/">announced</a> new pro plans last week and some accounts have had their
storage size doubled. Wouldn't it be wonderful if we could upload all our
files to dropbox from our django webapp?</p>
<p>In this post, I write a custom file upload handler that will upload files
from our application to dropbox.</p>
<p>Let us see how to use the custom file upload handler.</p>
<p>Install the <a class="reference external" href="https://www.dropbox.com/developers/reference/sdk">Dropbox Python SDK</a> before you setup your django app to handle
the file uploads.</p>
<p>In your <cite>settings.py</cite>, add the following attributes (with the values filled):</p>
<div class="highlight"><pre><span></span><span class="n">DROPBOX_APP_KEY</span> <span class="o">=</span> <span class="s2">""</span>
<span class="n">DROPBOX_APP_SECRET_KEY</span> <span class="o">=</span> <span class="s2">""</span>
<span class="n">DROPBOX_APP_ACCESS_TOKEN</span> <span class="o">=</span> <span class="s2">""</span>
<span class="n">DROPBOX_APP_ACCESS_TOKEN_SECRET</span> <span class="o">=</span> <span class="s2">""</span>
<span class="c1"># Optional values below</span>
<span class="c1"># The folder where you want the files uploaded.</span>
<span class="c1"># Example: /Public or /</span>
<span class="n">DROPBOX_FILE_UPLOAD_FOLDER</span> <span class="o">=</span> <span class="s2">""</span>
<span class="c1"># The value below may be either 'app_folder' or 'dropbox'</span>
<span class="n">DROPBOX_ACCESS_TYPE</span> <span class="o">=</span> <span class="s2">""</span>
</pre></div>
<p>The <cite>DROPBOX_APP_KEY</cite> and <cite>DROPBOX_APP_SECRET_KEY</cite> are provided to you when you
<a class="reference external" href="https://www.dropbox.com/developers/apps">create a new dropbox app</a>. Fetching the access token and access token secret
is outside the scope of this blog post but you can follow the <a class="reference external" href="https://www.dropbox.com/developers/start/authentication#python">Getting Started
Guide</a> until the <cite>Get an access token section</cite> and then paste the access token
key and secret in the <cite>DROPBOX_APP_ACCESS_TOKEN</cite> and <cite>DROPBOX_APP_ACCESS_TOKEN_SECRET</cite>
attributes respectively.</p>
<p>Add the <a class="reference external" href="https://gist.github.com/3128835">DropboxFileUploadHandler</a> to any app (in my case <cite>testapp</cite>) and reference
it in the <cite>FILE_UPLOAD_HANDLERS</cite> in <cite>settings.py</cite>:</p>
<div class="highlight"><pre><span></span><span class="n">FILE_UPLOAD_HANDLERS</span> <span class="o">=</span> <span class="p">(</span>
<span class="s2">"testapp.dropbox_upload_handler.DropboxFileUploadHandler"</span><span class="p">,</span>
<span class="p">)</span>
</pre></div>
<p>That's it and you are done!</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Since dropbox doesn't support chunked uploads, the file is first uploaded
to the temporary file upload directory on the server and then onto dropbox.</p>
</div>
<p>Here's how you would handle the file post upload in your view:</p>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">file_upload_handler_view</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="k">if</span> <span class="n">request</span><span class="o">.</span><span class="n">method</span> <span class="o">==</span> <span class="s2">"POST"</span><span class="p">:</span>
<span class="n">file_uploaded</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">FILES</span><span class="p">[</span><span class="s2">"name_of_file_input"</span><span class="p">]</span>
<span class="nb">print</span> <span class="n">file_uploaded</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="c1"># Helpful attribute to get dropbox file metadata</span>
<span class="c1"># like path on the server, size, thumbnail etc</span>
<span class="n">file_uploaded</span><span class="o">.</span><span class="n">dropbox_metadata</span>
</pre></div>
<p>The <cite>DropboxFile</cite> returned is an instance of <a class="reference external" href="http://docs.python.org/library/httplib.html?highlight=httplib#httplib.HTTPResponse">httplib.HTTPResponse</a> and so all
file like methods are not defined but some basic methods like read are supported.
There is an attribute called <cite>dropbox_metadata</cite> on the uploaded file that holds
the <a class="reference external" href="https://www.dropbox.com/developers/reference/api#metadata-details">dropbox metadata</a>.</p>
Using Ubuntu cloud images in KVM2012-07-16T18:01:58+00:002012-07-16T18:01:58+00:00Thejaswi Puthrayatag:thejaswi.info,2012-07-16:/tech/blog/2012/07/16/using-ubuntu-cloud-images-in-kvm/<p>Cross posted from <a class="reference external" href="http://agiliq.com/blog/2012/07/using-ubuntu-cloud-images-in-kvm/">work blog</a>.</p>
<p>Quite a few of our clients are powered by Amazon EC2 or Rackspace and we use
Ubuntu LTS releases for our servers. Canonical <a class="reference external" href="http://cloud-images.ubuntu.com/">provides</a> EC2 AMIs and Openstack
images for all their releases. By using these <a class="reference external" href="https://en.wikipedia.org/wiki/Just_enough_operating_system">JeOS images</a> on the server as well
as on …</p><p>Cross posted from <a class="reference external" href="http://agiliq.com/blog/2012/07/using-ubuntu-cloud-images-in-kvm/">work blog</a>.</p>
<p>Quite a few of our clients are powered by Amazon EC2 or Rackspace and we use
Ubuntu LTS releases for our servers. Canonical <a class="reference external" href="http://cloud-images.ubuntu.com/">provides</a> EC2 AMIs and Openstack
images for all their releases. By using these <a class="reference external" href="https://en.wikipedia.org/wiki/Just_enough_operating_system">JeOS images</a> on the server as well
as on the development platform reduces the dev/prod parity which we discussed
in a <a class="reference external" href="http://agiliq.com/blog/2012/06/libvirt-and-kvm/">previous</a> post.</p>
<p>In this post, we'll see how to setup the Ubuntu cloud images in the local KVM
hypervisor. Unlike the previous post, we'll use only the virt-manager to do the
initial provisioning but you can be assured that there is a command line way
to do all of the same.</p>
<p>Head over to <a class="reference external" href="http://cloud-images.ubuntu.com/">Ubuntu cloud images</a> and select the appropriate release (or daily
build). At the time of writing the article, 12.04 is the latest LTS release and
can be downloaded from <a class="reference external" href="http://cloud-images.ubuntu.com/releases/precise/release/">here</a>. I have downloaded the 64-bit (or amd64) images
(<cite>ubuntu-12.04-server-cloudimg-amd64-root.tar.gz</cite>) since I use a 64-bit machine
for my development and the servers are all 64-bit file. This compressed file
contains a virtual hard disk, virtual floppy disk and a kernel.</p>
<p>Let us now use this virtual hard disk as a base for our images and create new
guest VM based on this disk.:</p>
<pre class="literal-block">
$ qemu-img create -b ubuntu-12.04-server-cloudimg-amd64.img -f qcow2 new_vm.img
</pre>
<p>The <a class="reference external" href="https://en.wikibooks.org/wiki/QEMU/Images">qemu-img</a> command creates a <cite>new_vm.img</cite> image with qcow2 format using the
<cite>ubuntu-12.04-server-cloudimg-amd64.img</cite> as the backing image.</p>
<p>Right click on the connection in virt-manager and select <cite>New</cite> and provide a name
for the new virtual machine and select the <cite>Import existing disk image</cite> option.
In the next step, provide the path of the image just created (ie <cite>new_vm.img</cite>)
and optionally select the OS type and version. In the third step, select the RAM
allocated to the VM and the number of cores and in the final step check the
<cite>Customize configuration before install</cite> before filling other options.</p>
<p>In the Customization screen, click on the section that says <cite>Disk 1</cite> and set the
storage format to qcow2 and apply the changes.</p>
<blockquote>
<a class="reference external image-reference" href="http://agiliq.com/static/dumps/images/20120716/disk_configuration.png"><img alt="Configuring the disk" class="align-center" src="http://agiliq.com/static/dumps/images/20120716/disk_configuration.png" style="width: 90%;" /></a>
</blockquote>
<p>Now all that is left is to set the boot order and there are two methods:</p>
<ul class="simple">
<li>Using the floppy disk image</li>
<li>Using cloud-init on the hard disk image</li>
</ul>
<div class="section" id="using-the-floppy-disk-for-booting">
<h2>Using the floppy disk for booting</h2>
<p>If you don't see a floppy disk in the list of devices in the customization screen,
click on <cite>Add Hardware</cite> and add a new Storage device of type <cite>Floppy disk</cite> and
check the <cite>Select managed or other existing storage</cite> and provide the path to
the floppy disk image from the download and set the <cite>Storage format</cite> to raw.</p>
<blockquote>
<a class="reference external image-reference" href="http://agiliq.com/static/dumps/images/20120716/floppy_disk_create.png"><img alt="Adding Floppy Disk" class="align-center" src="http://agiliq.com/static/dumps/images/20120716/floppy_disk_create.png" style="width: 90%;" /></a>
</blockquote>
<p>Select the <cite>Boot Options</cite> section in the customization screen after creating the
floppy disk and select the Floppy in the <cite>Boot device order</cite>. Start the
installation and after that run the VM and you are done!</p>
<p>After booting the new VM, you should see the GRUB screen in a few seconds as below.</p>
<blockquote>
<a class="reference external image-reference" href="http://agiliq.com/static/dumps/images/20120716/grub_screen.png"><img alt="Grub Screen" class="align-center" src="http://agiliq.com/static/dumps/images/20120716/grub_screen.png" style="width: 90%;" /></a>
</blockquote>
<p>Choose the option that you prefer and you will be redirected to the login prompt
after the bootup.</p>
<p>This method is useful if you have a provisioning or a metadata service like
<a class="reference external" href="https://help.ubuntu.com/community/Orchestra/Overview">Orchestra</a> or <a class="reference external" href="http://cobbler.github.com/">Cobbler</a> though not a compulsion.</p>
</div>
<div class="section" id="using-cloud-init-on-the-hard-disk">
<h2>Using cloud-init on the hard disk</h2>
<p><a class="reference external" href="https://help.ubuntu.com/community/CloudInit">CloudInit</a> is an init script that performs some basic configuration and house
keeping tasks on guest VMs like setting the hostname, generating SSH keys etc</p>
<p>Go to the <cite>Boot Options</cite> section and select the <cite>Hard disk</cite> from the
<cite>Boot device order</cite> and change the <cite>Direct kernel boot</cite> sub section.</p>
<p>Provide the kernel file (the file ending with vmlinuz-virtual) from the download
in the <cite>Kernel path</cite> and the following values in the <cite>Kernel arguments</cite>:</p>
<pre class="literal-block">
ro init=/usr/lib/cloud-init/uncloud-init root=/dev/vda ds=nocloud ubuntu-pass=initialpassword
</pre>
<a class="reference external image-reference" href="http://agiliq.com/static/dumps/images/20120716/hard_disk_boot.png"><img alt="Configuring the hard disk" class="align-center" src="http://agiliq.com/static/dumps/images/20120716/hard_disk_boot.png" style="width: 90%;" /></a>
<p>Start the installation and in a few moments you have a brand new guest VM.</p>
<p>You now have exactly the same packages as an official and freshAmazon AMI or
Rackspace image and so you don't have to break your head worrying about
the dependency hell and enjoy more time developing.</p>
</div>
Spring Fever2012-07-07T00:00:01+00:002012-07-07T00:00:01+00:00Thejaswi Puthrayatag:thejaswi.info,2012-07-07:/personal/blog/2012/07/07/spring-fever/<p>It's common knowledge in PG Wodehouse books that English aristocrats are rich and spend a lot of time socializing with their peers at clubs over lunches. But in "Spring Fever", Lord Shortlands, an Earl is hard pressed and has to depend financially on his eldest daughter. He dotes on his …</p><p>It's common knowledge in PG Wodehouse books that English aristocrats are rich and spend a lot of time socializing with their peers at clubs over lunches. But in "Spring Fever", Lord Shortlands, an Earl is hard pressed and has to depend financially on his eldest daughter. He dotes on his youngest daughter and wants to see her married and has plans of his own like marrying his cook but faces some competition in this regard.</p>
<p>So far this book diverges from the rest but gets into the usual track where a lover impersonates a guest to woo his lady love at a large castle in the countryside but then the real guest steps in and after a series of hilarious events the dust settles and concludes with a happy setting.</p>
<p>This book has nothing new for regular Wodehouse readers but you may love it if this is your first.</p>
The impact of Science on Society2012-07-06T00:00:01+00:002012-07-06T00:00:01+00:00Thejaswi Puthrayatag:thejaswi.info,2012-07-06:/personal/blog/2012/07/06/the-impact-of-science-on-society/<p>This book is a collection of essays by renowned author "<a class="reference external" href="https://en.wikipedia.org/wiki/Bertrand_Russell">Bertrand Russell</a>" studying "The impact of Science on Society".</p>
<p>The first essay is the most enjoyable of the seven in the book and lists the major inventions from the wheel to the nuclear bomb and how they were responsible in …</p><p>This book is a collection of essays by renowned author "<a class="reference external" href="https://en.wikipedia.org/wiki/Bertrand_Russell">Bertrand Russell</a>" studying "The impact of Science on Society".</p>
<p>The first essay is the most enjoyable of the seven in the book and lists the major inventions from the wheel to the nuclear bomb and how they were responsible in demolishing some traditions of the day.</p>
<p>The other essays study the impact of science on democracy, war and the value system. In the last essay the author predicts if a scientific society can be stable.</p>
<p>The essays are not remarkable and may be your last choice if you've got nothing to read.</p>
Waiting for the Mahatma2012-07-05T00:00:01+00:002012-07-05T00:00:01+00:00Thejaswi Puthrayatag:thejaswi.info,2012-07-05:/personal/blog/2012/07/05/waiting-for-the-mahatma/<p>Sriram grows up under the strict supervision of his grandmother and has just received his twentieth birthday gift in the form of a bank passbook. He now has financial independence and inherited a lot of money and life is beginning to look good when it turns upside down after he …</p><p>Sriram grows up under the strict supervision of his grandmother and has just received his twentieth birthday gift in the form of a bank passbook. He now has financial independence and inherited a lot of money and life is beginning to look good when it turns upside down after he falls in love with Bharati, a dedicated volunteer of Mahatma's entourage to Malgudi. He joins the Mahatma against the wishes of his grandmother to prove his love for Bharati.</p>
<p>At the peak of the independence agitation, Bharati courts arrest along with thousands of Mahatma followers and he yearns for her even more. He comes in contact with some volatile elements while trying to seek direction in the absence of Bharati and takes up arms to liberate the country. Not long after, he is arrested but is released after a few years when the country attains independence. He manages to track down Bharati and proposes his love for her once again. She agrees on the condition that it receive approval from the Mahatma.</p>
<p>The book's title seems to suggest that the Mahatma plays quite a significant role but he appears only twice in the book and Sriram and Bharati are the central characters. Sometimes while reading the book, you admire how the RK Narayan alludes Bharati to Bharat Mata. Compared to his other books, the humour in the book is subdued but definitely worth a read.</p>
The Guide2012-07-04T00:00:01+00:002012-07-04T00:00:01+00:00Thejaswi Puthrayatag:thejaswi.info,2012-07-04:/personal/blog/2012/07/04/the-guide/<p>Railway Raju is a famous guide who is solely responsible for putting the sleepy town of Malgudi on the tourism map. He falls in love with his client's wife and on learning that she is unhappy with her marriage tries desperately to woo her and succeeds only after fate takes …</p><p>Railway Raju is a famous guide who is solely responsible for putting the sleepy town of Malgudi on the tourism map. He falls in love with his client's wife and on learning that she is unhappy with her marriage tries desperately to woo her and succeeds only after fate takes his side. In this process he alienates his family and friends and loses interest in his profession.</p>
<p>Undeterred by the setbacks he nurtures his partner's passion for dance and his efforts finally pays off after she becomes a famous dancer. This time fate abandons him and he ends up in prison.</p>
<p>After being released from jail, he is mistaken for a holy man and a village adopts him and pins their hope on him to bring rainfall through penance. Will he walk from this sticky situation through his corrupt and wily means that he resorted to as a guide or will the circumstances get better of him?</p>
<p>While all the trademark elements of an R.K Narayan book are present, we see him portray the dark nature of humans for the first time brilliantly. Read this book even if you've watched the movie by the same name. The movie diverges quite a lot from the book and yet the book is more entertaining.</p>
The Mother2012-07-03T00:00:01+00:002012-07-03T00:00:01+00:00Thejaswi Puthrayatag:thejaswi.info,2012-07-03:/personal/blog/2012/07/03/the-mother/<p>A mother's love for her children knows no bounds and <a class="reference external" href="https://en.wikipedia.org/wiki/Maxim_Gorky">Maxim Gorky</a>'s "The Mother" is a masterpiece in this regard.</p>
<p>Vlasov has seen his father's life snuffed out by the factory and like thousands of other workers is staring down the same fate. One day, he comes back home …</p><p>A mother's love for her children knows no bounds and <a class="reference external" href="https://en.wikipedia.org/wiki/Maxim_Gorky">Maxim Gorky</a>'s "The Mother" is a masterpiece in this regard.</p>
<p>Vlasov has seen his father's life snuffed out by the factory and like thousands of other workers is staring down the same fate. One day, he comes back home with a few books and becomes a transformed person filled with confidence after reading them. He builds a close group of socialists and plans to create awareness about worker rights and worker revolutions outside Russia.</p>
<p>Vlasov's mother, Nilovna, is an uneducated and god fearing woman who was married off early and faced brutalities at the hand of her drunken husband. She is anxious about her son's radical thinking and like many other mothers prefers to see him settled. Slowly, she starts understanding the importance of socialism by overhearing her son and his comrades' meetings. Her skepticism and innocent questions regarding their future plans and their guarded answers worry her immensely.</p>
<p>She develops a respect for her son after his arrest while leading a peaceful protest of workers. After this, she is overwhelmed by the compassion of the workers towards her owing to her son's sacrifice. Her love for her son and all that he stood for leads her into taking up his incomplete work of bringing about a workers revolution. Whether her plans pay off and she is reunited with her son forms the rest of the story.</p>
<p>I was surprised to learn that this book was originally written in English and it has a fantastic style. The main emphasis of the book is on the mother and son relation and socialism receives little coverage and so you can read the book without the fear of philosophical overdose.</p>
Libvirt and KVM2012-06-25T16:33:23+00:002012-06-25T16:33:23+00:00Thejaswi Puthrayatag:thejaswi.info,2012-06-25:/tech/blog/2012/06/25/libvirt-and-kvm/<p>Cross-posted from my work <a class="reference external" href="http://agiliq.com/blog/2012/06/libvirt-and-kvm/">blog</a>.</p>
<div class="section" id="id1">
<h2>Libvirt and KVM</h2>
<p><em>"But it works on my local setup!"</em> We have heard or probably said this tens of
times after something that we deployed to the production server breaks. After
fire fighting for hours we learn that a particular package's version varies
from the …</p></div><p>Cross-posted from my work <a class="reference external" href="http://agiliq.com/blog/2012/06/libvirt-and-kvm/">blog</a>.</p>
<div class="section" id="id1">
<h2>Libvirt and KVM</h2>
<p><em>"But it works on my local setup!"</em> We have heard or probably said this tens of
times after something that we deployed to the production server breaks. After
fire fighting for hours we learn that a particular package's version varies
from the local setup. This is a fairly common problem that plagues every
developer. Off late, quite a lot of interest and work is going into reducing
the <a class="reference external" href="http://www.12factor.net/dev-prod-parity">dev/prod parity</a> to prevent such problems.</p>
<p>Software like virtualenv help a great deal in compartmentalizing python
dependencies but most web applications nowadays have to deal with loads of
other dependencies like web servers, application servers etc.</p>
<p>We use Ubuntu at work (not a rigid requirement) and they have biannual
releases with long term releases LTS every two years. We use LTS releases for
our servers and the general releases as our development desktops.</p>
<p>In such a case, how do we reduce the parity with our server setup? This was already
explained in a blog post <a class="reference external" href="http://agiliq.com/blog/2012/01/brief-overview-vagrant/">earlier</a> by Dheeraj. While Vagrant is a fine piece of
software, Virtualbox on Linux based operating systems tends to be very problematic.
There are a lot of random crashes, kernel dumps, disk corruptions etc and you spend
a lot of time repairing it rather than concentrating on developing. This is where
libvirt and KVM come in.</p>
<p><a class="reference external" href="http://libvirt.org/">Libvirt</a> is a common API that helps manage virtualization platforms (or hypervisors
in it's terminology). Through this single API, you will be able to talk to a host of
hypervisors like Virtualbox, KVM, Xen, LXC, OpenVZ, VMware based hypervisors and
also Microsoft Hyper-V. Libvirt also provides for network and disk management,
authentication and access control etc.</p>
<p><a class="reference external" href="http://linux-kvm.org/">KVM</a> (Kernel Virtual Machine) is a Linux kernel module (requires no compilation like
Xen) that supports native (hardware) virtualization. KVM based guests almost perform
as well as the host and since it is part of the mainline kernel since 2.6.20, you
may consider it the 'official' virtualization platform on most Linux based distros.</p>
<p><a class="reference external" href="http://qemu.org/">Qemu</a> is a userspace program that talks to the KVM module and emulates some hardware
devices.</p>
<p>A <cite>guest</cite> (or client/domain as some may refer) is a virtual machine running on
top of a <cite>host</cite> (or server).</p>
<p>So far we have just dealt with the definitions, let's install something to play
around with. But before that, here's the customary disclaimer.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">KVM works <strong>only</strong> on Linux based distributions and virtualization ready hardware.</p>
</div>
<p>Installing software on ubuntu is fairly easy thanks to apt-get.</p>
<ul>
<li><p class="first">Let's install libvirt and qemu-kvm (the userspace program mentioned above) first:</p>
<pre class="literal-block">
$ sudo apt-get install libvirt-bin qemu-kvm
</pre>
</li>
<li><p class="first">You will have to add the user who can access libvirt to the <cite>libvirtd</cite> group:</p>
<pre class="literal-block">
$ sudo adduser <username> libvirtd
</pre>
<p>If you have added the current user (specified by <cite><username></cite>), log out and login
to have the groups addition to get refreshed:</p>
<pre class="literal-block">
$ groups <username>
<username> : <username> libvirtd
</pre>
</li>
<li><p class="first">After you have successfully installed libvirt, check if <cite>virsh</cite> (virtualization shell)
works fine:</p>
<pre class="literal-block">
$ virsh
virsh #
</pre>
</li>
<li><p class="first">Now, you may create your guest VM in either of the two ways specified below,
through the CLI tool (<cite>virsh</cite>) or the graphical interface (<cite>virt-manager</cite>).</p>
</li>
<li><p class="first">If you prefer a graphical interface over <cite>virsh</cite>:</p>
<pre class="literal-block">
$ sudo apt-get install virt-manager
</pre>
</li>
<li><p class="first">If you are using <cite>virsh</cite> (<strong>note:</strong> not applicable if you are using <cite>virt-manager</cite>),
you need the <cite>virt-install</cite> package to create a new guest and <cite>virt-viewer</cite> to
view the VNC console:</p>
<pre class="literal-block">
$ sudo apt-get install python-virtinst virt-viewer
$ sudo virt-install -n guest_vm -r 512 --disk path=/path/to/store/vm,size=1 -c /path/to/guest_vm.iso -v --virt-type=kvm --connect=qemu:///system --vnc
</pre>
<p>The virt-install command creates a VM with the name <cite>guest_vm</cite>, assigns it
512 MB RAM and creates an associated disk using the arguments provided to
<cite>--disk path</cite> (size 1GB here). For installation, it makes use of the ISO file
provided. This ISO may be any OS image that you may have downloaded or generated.
The <cite>-v</cite> option instructs to make the guest 'fully' virtualized with the 'kvm'
hypervisor and start the VNC console. There are a multitude of options (like
setting the network etc) and you may want to check the man page.</p>
</li>
<li><p class="first">In <cite>virt-manager</cite> (<strong>note:</strong> not applicable if you are using <cite>virsh</cite>), go to
<cite>File > Add Connection</cite> and set the <cite>Hypervisor</cite> as Qemu (or KVM) and save
the connection.</p>
<a class="reference external image-reference" href="http://agiliq.com/static/dumps/images/20120625/libvirt_screen_1.png"><img alt="Virt-manager screen" class="align-center" src="http://agiliq.com/static/dumps/images/20120625/libvirt_screen_1.png" style="width: 90%;" /></a>
<p>Then, let's create a guest VM. Right click on the just created connection in
the host summary window and create a new VM by right clicking on your connection
and selecting 'New'.</p>
<a class="reference external image-reference" href="http://agiliq.com/static/dumps/images/20120625/libvirt_screen_2.png"><img alt="Creating a new VM" class="align-center" src="http://agiliq.com/static/dumps/images/20120625/libvirt_screen_2.png" style="width: 90%;" /></a>
<p>Select the method of your choice to install a new VM. I selected the <cite>Local install
media (ISO image or CDROM) option</cite>, set the name of the VM as <cite>guest_vm</cite> and
provided the path to the ISO image in the next screen. The steps 3 and 4 are
fairly straightforward and you can safely use the defaults. In the step 5, you
may modify the network (the default should be fine) and have the ability to
customize the hardware emulated by the hypervisor. I prefer not to fiddle with
those and click on <cite>Finish</cite> and wait for the VM to get created.</p>
</li>
<li><p class="first">Now we are done creating a new guest VM and installing it. We can start the
guest using <cite>virsh</cite> (<strong>note</strong>: Not applicable if you are using virt-manager):</p>
<pre class="literal-block">
$ virsh start guest_vm
$ virt-viewer -c qemu:///system guest_vm
</pre>
</li>
<li><p class="first">If you want to start the VM using <cite>virt-manager</cite>, right click on the VM
and click on <cite>Run</cite>.</p>
<a class="reference external image-reference" href="http://agiliq.com/static/dumps/images/20120625/libvirt_screen_3.png"><img alt="Running a VM" class="align-center" src="http://agiliq.com/static/dumps/images/20120625/libvirt_screen_3.png" style="width: 90%;" /></a>
</li>
<li><p class="first">After running the VM, right click on the running VM and select <cite>Open</cite> to view
the console.</p>
<a class="reference external image-reference" href="http://agiliq.com/static/dumps/images/20120625/libvirt_screen_4.png"><img alt="Running a VM" class="align-center" src="http://agiliq.com/static/dumps/images/20120625/libvirt_screen_4.png" style="width: 90%;" /></a>
</li>
</ul>
<p>So now we have guest VMs running and a way to install an OS of our choice.
For example, you can install the LTS release of ubuntu in a VM and use it
for development or Windows XP (or Windows 7) to test against Internet
Explorer or create one VM per project and manage your dependencies easily.</p>
</div>
Joy in the morning2012-03-25T22:27:27+00:002012-03-25T22:27:27+00:00Thejaswi Puthrayatag:thejaswi.info,2012-03-25:/personal/blog/2012/03/25/joy-in-the-morning/<p>You experience extreme joy in the morning when the excesses of the previous night are forgiven. Bertie Wooster experiences this joy when a warrant against him is quashed. Bertie finds himself in these unfortunate circumstances while playing a good samaritan! Jeeves as always plays the pivotal character advising not just …</p><p>You experience extreme joy in the morning when the excesses of the previous night are forgiven. Bertie Wooster experiences this joy when a warrant against him is quashed. Bertie finds himself in these unfortunate circumstances while playing a good samaritan! Jeeves as always plays the pivotal character advising not just Bertie but Bertie's uncle Percy as well as Bertie's bosom pal, Boko.</p>
<p>The Jeeves series is getting repetitive especially Jeeves who feels larger than life. With this I have exhausted all the Wodehouse books from the <a class="reference external" href="http://agiliq.com/">office</a> library (how cool is this?).</p>
Using D-Link DWL-G132 from Linux2012-03-23T12:38:00+00:002012-03-23T12:38:00+00:00Thejaswi Puthrayatag:thejaswi.info,2012-03-23:/tech/blog/2012/03/23/using-d-link-dwl-g132-from-linux/<p>A couple of weeks back, my wireless card on my <a class="reference external" href="http://thejaswi.info/personal/blog/2008/01/25/my-new-companion/">laptop</a> first started dropping more than half the packets and then stopped working. Since the laptop is 4 years old, I was not too keen to spend to replace the wireless card (if stock was available). I had a <a class="reference external" href="http://www.dlink.com/products/?pid=DWL-G132">DWL-G132 …</a></p><p>A couple of weeks back, my wireless card on my <a class="reference external" href="http://thejaswi.info/personal/blog/2008/01/25/my-new-companion/">laptop</a> first started dropping more than half the packets and then stopped working. Since the laptop is 4 years old, I was not too keen to spend to replace the wireless card (if stock was available). I had a <a class="reference external" href="http://www.dlink.com/products/?pid=DWL-G132">DWL-G132</a>, D-Link Wireless G USB adapter lying around from my old desktop and this was my best bet. In fact, I was so confident that it would work out of the box in Linux but I was disappointed. After a few searches, I realized that I could make the adapter work using <a class="reference external" href="http://ndiswrapper.sourceforge.net/">ndiswrapper</a>. Luckily, within a few minutes the wireless adapter was up and running.</p>
<p>Here's the process to make your adapter work on Linux:</p>
<ul>
<li><p class="first">Install <a class="reference external" href="http://ndiswrapper.sourceforge.net/">ndiswrapper</a>. I used the yum package from the rpmfusion repository. You may use apt-get on Ubuntu.</p>
</li>
<li><p class="first">Download the drivers from the D-Link site for Windows.</p>
</li>
<li><p class="first">Let's remove the ndiswrapper from the kernel from the time being using:</p>
<pre class="literal-block">
# modprobe -r ndiswrapper
</pre>
</li>
<li><p class="first">In the zip file downloaded from the D-Link site (under the <cite>Drivers/2KXP</cite> folder):</p>
<pre class="literal-block">
# ndiswrapper -i netA5AGU.inf
# ndiswrapper -i ar5523.bin
</pre>
</li>
<li><p class="first">Load the ndiswrapper module back into the kernel:</p>
<pre class="literal-block">
# modprobe ndiswrapper
</pre>
</li>
</ul>
<p>You should start seeing the LEDs on the adapter blinking (if not, repeat the process). You should observe a new wireless device on your NetworkManager and you can associate Wifi networks and get connected to the internet.</p>
Developing android applications from command line2012-03-20T17:55:23+00:002012-03-20T17:55:23+00:00Thejaswi Puthrayatag:thejaswi.info,2012-03-20:/tech/blog/2012/03/20/developing-android-applications-from-command-line/<p>Cross posted from my <a class="reference external" href="http://agiliq.com/blog/2012/03/developing-android-applications-from-command-line/">work blog</a>.</p>
<p>Here at Agiliq, we also develop cross-platform HTML5 mobile applications. Using
Eclipse to create an android project (one time task) and edit html and javascript
files for an android app is an overkill. Wouldn't it be great, if you could use
your favourite text …</p><p>Cross posted from my <a class="reference external" href="http://agiliq.com/blog/2012/03/developing-android-applications-from-command-line/">work blog</a>.</p>
<p>Here at Agiliq, we also develop cross-platform HTML5 mobile applications. Using
Eclipse to create an android project (one time task) and edit html and javascript
files for an android app is an overkill. Wouldn't it be great, if you could use
your favourite text editor to edit html and js files and then fall back to the
terminal to deploy the android app? We are going to see exactly this in the post.</p>
<p>First, let's install the android SDK starter package(I assume that you have
installed JDK and ant). Head over <a class="reference external" href="http://developer.android.com/sdk/index.html">here</a> and install the SDK for your platform.
Since I use ubuntu, I download the Linux platform SDK to my home directory.
Uncompress the download and set the path to load the executables:</p>
<pre class="literal-block">
$ tar xvf android-sdk_r16-linux.tgz
$ export PATH=$PATH:~/android-sdk-linux/tools:~/reqs/android-sdk-linux/platform-tools
$ android sdk
</pre>
<a class="reference external image-reference" href="http://agiliq.com/static/dumps/images/20120320/android_sdk_manager.png"><img alt="Android SDK manager" class="align-center" src="http://agiliq.com/static/dumps/images/20120320/android_sdk_manager.png" style="width: 90%;" /></a>
<p>If you don't wish to keep exporting the PATH variable everytime, you can set it in
your <cite>~/.bashrc</cite> or <cite>~/.bash_profile</cite> file.</p>
<p>The <cite>android sdk</cite> command opens the Android SDK manager. Download the requisite SDK
packages for the android versions that you plan to target. I plan to develop the app
for Gingerbread and Icecream Sandwich phones and hence download the Android 4.0.3
(API 15) and Android 2.3.3 (API 10) components.</p>
<p>Let's check which versions of the SDK are installed from the terminal:</p>
<pre class="literal-block">
$ android list targets
</pre>
<p>While developing the app, we need a way to test the app and hence let's create
Android Virtual Devices (AVD) that will create virtual devices that we'll run later
through the emulator:</p>
<pre class="literal-block">
$ android avd
</pre>
<a class="reference external image-reference" href="http://agiliq.com/static/dumps/images/20120320/android_avd_manager.png"><img alt="Android AVD manager" class="align-center" src="http://agiliq.com/static/dumps/images/20120320/android_avd_manager.png" style="width: 90%;" /></a>
<p>Create as many AVDs as the android SDK versions that you downloaded in the previous step.</p>
<p>To view a list of AVDs we just created on the terminal, use the following command:</p>
<pre class="literal-block">
$ android list avd
</pre>
<p>Let's test if the AVDs we created run on the emulator. I want to run the AVD named
<cite>Gingerbread</cite> on the emulator:</p>
<pre class="literal-block">
$ emulator @Gingerbread
</pre>
<a class="reference external image-reference" href="http://agiliq.com/static/dumps/images/20120320/android_emulator.png"><img alt="Android Emulator" class="align-center" src="http://agiliq.com/static/dumps/images/20120320/android_emulator.png" style="width: 90%;" /></a>
<p>We've setup the basic infrastructure for being able to develop android apps.</p>
<div class="section" id="creating-an-android-project">
<h2>Creating an android project</h2>
<p>Let's create an android project (for creating a phonegap based android project, skip to the next section):</p>
<pre class="literal-block">
$ android create project -n TestAndroidProj -t 'android-15' -p ~/android_proj -k com.example -a TestProjActivity
</pre>
<p>The value (<cite>TestAndroidProj</cite>) to the -n switch is the name of the project, the value
(<cite>android-15</cite>) to the -t switch is the android SDK version the app targets. The value
to the -p switch mentions the path of the android project. The -k switch requires a
valid (java) package name and the -a switch takes the name of the initial <a class="reference external" href="http://developer.android.com/reference/android/app/Activity.html">Activity</a>.</p>
<p>After running the above command, an android project should have got successfully created.
Check if everything's as expected:</p>
<pre class="literal-block">
$ cd android_proj/
$ ls src/com/example/TestProjActivity.java
src/com/example/TestProjActivity.java
</pre>
</div>
<div class="section" id="bonus-installing-and-creating-a-phonegap-app">
<h2><strong>(BONUS)</strong> Installing and creating a Phonegap app</h2>
<p>If you don't plan to create an HTML5 app or don't plan to use Phonegap, you
can safely skip this section. See you later...</p>
<p>Immediately after installing the android SDK, clone Cordova (formerly Phonegap)
from this <a class="reference external" href="git://git.apache.org/incubator-cordova-android.git">location</a> (or clone it from a <a class="reference external" href="https://github.com/apache/incubator-cordova-android/">github</a> tag for a stable version). Add
the <cite>bin</cite> directory under the cloned directory to your <cite>PATH</cite>:</p>
<pre class="literal-block">
$ git clone git://git.apache.org/incubator-cordova-android.git
$ export PATH=$PATH:~/incubator-cordova-android/bin
</pre>
<p>Let's create a Cordova project, which is a wrapper around <tt class="docutils literal">android create project</tt>
but additionally sets up phonegap dependencies (the jar and the js files) for you:</p>
<pre class="literal-block">
$ cd ~/incubator-cordova-android
$ ./bin/create ~/phonegap_android_proj com.example TestProjActivity 3
</pre>
<p>The first argument is the path of the project, the second is the (java) package
name, the third is the name of the initial activity that loads your index.html and
the fourth argument is the android sdk id (taken from <tt class="docutils literal">android list targets</tt>, in
my case 'android-15' id is '3').</p>
<p>Let's check if the project has been successfully created:</p>
<pre class="literal-block">
$ cd ~/phonegap_android_proj/
$ ls assets/www/
cordova-1.5.0.js index.html main.js master.css
$ ls libs/
cordova-1.5.0.jar
$ ls res/xml/
cordova.xml plugins.xml
</pre>
<p>The following sections are common to both native android projects and
phonegap based android projects.</p>
</div>
<div class="section" id="ant-commands">
<h2>Ant commands</h2>
<p>Now that we are done with the project and write all the code for the app, we
need to be able to test it in the emulator. So let's start the emulator (mentioned
above) and then start the Android Debug Bridge (adb). It is recommended you start
adb as a superuser because if you later connect your phone, it will have the
requisite permissions to access it:</p>
<pre class="literal-block">
$ sudo ~/android-sdk-linux/platform-tools/adb start-server
</pre>
<p>Check if the adb server process is running before you proceed further:</p>
<pre class="literal-block">
$ ps aux|grep adb
root 12589 0.0 0.0 20184 948 pts/3 Sl 16:43 0:00 adb fork-server server
</pre>
<div class="section" id="deploying-the-app-to-the-emulator">
<h3>Deploying the app to the emulator</h3>
<p>In your project root, run the ant commands to deploy the app (signed with the
debug key) to the emulator:</p>
<pre class="literal-block">
$ cd ~/android_proj
$ ant clean debug install
</pre>
<p>The app should show up on your emulator and you can test it out. If you plan to
use the phone, the same set of commands will work. You might want to close the
emulator then or adb will complain that both the emulator and the device are
connected. To debug and view log messages use the Dalvik Debug Monitor Server (ddms):</p>
<pre class="literal-block">
$ ddms
</pre>
<p>Once you are satisfied with the app, you will want to sign it and publish it
to the market (Google Play).</p>
</div>
<div class="section" id="signing-the-app-to-deploy-to-marketplace">
<h3>Signing the app to deploy to marketplace</h3>
<p>First, let's generate a private key that will be used to sign the application:</p>
<pre class="literal-block">
$ keytool -genkey -v -keystore app_signing.keystore -alias release \
-keyalg RSA -keysize 2048 -validity 10000
</pre>
<p>The <cite>keytool</cite> that is part of the JDK is used to create the private key. The
-keystore argument's value is the name of the output file where the keys are stored.
The -alias is a human readable name for the key (as multiple keys may be stored)
in the keystore which can be used to refer the key later on. The encryption
algorithm is set to RSA with a keysize of 2048 bits and a validity of 10000 days.
Keep the generated keystore file very safe as this identifies you on the Google
Play store.</p>
<p>After you have successfully generated your private key, let's compile the app
in the release mode:</p>
<pre class="literal-block">
$ ant clean release
</pre>
<p>You will notice under the <cite>bin</cite> directory of your project, a file of the format
<cite><project_name>-release-unsigned.apk</cite> (in our case, 'TestAndroidProj-release-unsigned.apk').
After we are done with this, we have to sign the app with the private key we created
previously:</p>
<pre class="literal-block">
$ jarsigner -keystore app_signing.keystore -digestalg SHA1 -sigalg MD5withRSA bin/TestAndroidProj-release-unsigned.apk release
</pre>
<p>The <cite>jarsigner</cite> utility uses the keystore (created previously) while specifying the
digest algorithm, signature algorithm, the release android application and the
name of the alias to be used from the keystore.</p>
<p>Let's verify if everything went fine:</p>
<pre class="literal-block">
$ jarsigner -verify bin/TestAndroidProj-release-unsigned.apk
</pre>
<p>You should get a 'jar verified' message and might want to repeat the signing process
if you didn't.</p>
<p>Finally, let us align the generated application file (apk) before submitting to
Google Play store.</p>
<blockquote>
$ zipalign -v 4 bin/TestAndroidProj-release-unsigned.apk bin/TestAndroidProj.apk</blockquote>
<p>'4' specifies that the files in the apk should be aligned to the 4-byte boundary. The
next argument is the input signed application file and the last argument is the output
file that is used to upload to the Google Play store.</p>
<p>The only command that we'll use frequently from the terminal is <tt class="docutils literal">ant clean debug install</tt>
and by doing so we can avoid running Eclipse (which hogs memory like there's no
tomorrow).</p>
<p><strong>Bonus</strong>: If you are an Emacs user, you might want to use <a class="reference external" href="http://marmalade-repo.org/packages/android-mode">android-mode</a> which
has key bindings for most of the above mentioned commands and other goodies.</p>
</div>
</div>
Inimitable Jeeves2012-03-20T09:54:37+00:002012-03-20T09:54:37+00:00Thejaswi Puthrayatag:thejaswi.info,2012-03-20:/personal/blog/2012/03/20/inimitable-jeeves/<p>This book is a tribute to Jeeves, Bertie Wooster's affable valet. Jeeves acts as a 'universal' saviour right from the first page. For a change, this time it's not Bertie who is in trouble but his best friend from school, Bingo. Jeeves sorts out the issues in Bingo's love life …</p><p>This book is a tribute to Jeeves, Bertie Wooster's affable valet. Jeeves acts as a 'universal' saviour right from the first page. For a change, this time it's not Bertie who is in trouble but his best friend from school, Bingo. Jeeves sorts out the issues in Bingo's love life, recovers Bertie's aunt Agatha's jewels from seasoned thieves, saves a young lady from the torture of Bertie's cousins and more.</p>
<p>By the time you put down the book, you realize that Jeeves gets away with almost everything and you can't stop wondering if Jeeves is some superhero. 'Inimitable Jeeves' is a trademark PG Wodehouse book but just as the last book, Uncle Fred feels more caring and believable.</p>
Outliers2012-03-12T09:00:00+00:002012-03-12T09:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2012-03-12:/personal/blog/2012/03/12/outliers/<p>When you pick a book written by a bestselling author, featured twice on the New York Times bestseller list, your expectations are high.</p>
<p>Outliers by <a class="reference external" href="https://en.wikipedia.org/wiki/Malcolm_Gladwell">Malcolm Gladwell</a> is a big letdown. The book is a study of success and relies on case studies to prove that hard work alone cannot …</p><p>When you pick a book written by a bestselling author, featured twice on the New York Times bestseller list, your expectations are high.</p>
<p>Outliers by <a class="reference external" href="https://en.wikipedia.org/wiki/Malcolm_Gladwell">Malcolm Gladwell</a> is a big letdown. The book is a study of success and relies on case studies to prove that hard work alone cannot guarantee success.</p>
<p>In the first chapter, the author states that age, time of birth may have a bearing in success (not astrology but through half baked statistics and psychology) and illustrates this through the Canadian ice hockey team. He studies other parameters and quotes examples while dissecting the story of success in the rest of the book.</p>
<p>I found the book largely disagreeable and wished I picked up something else.</p>
Aunts aren't gentlemen2012-03-11T14:00:00+00:002012-03-11T14:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2012-03-11:/personal/blog/2012/03/11/aunts-arent-gentlemen/<p>Based on doctor's advice, Bertram Wooster sets out to the countryside to relax and rejuvenate. At the village, he bumps into his ex-girlfriend. If that's not enough, her father suspects him of theft and her suspicious boyfriend has followed her from the city. With a lot of difficulty, Bertie manages …</p><p>Based on doctor's advice, Bertram Wooster sets out to the countryside to relax and rejuvenate. At the village, he bumps into his ex-girlfriend. If that's not enough, her father suspects him of theft and her suspicious boyfriend has followed her from the city. With a lot of difficulty, Bertie manages to clear the air that he is around only for medical reasons when his aunt gets him into more trouble by snitching his ex-girlfriend's dad's cat and leaves it at his protection. Already under suspicion and fearing being caught, he seeks the help of his butler, Jeeves who steps in and sorts everything out for his master the umpteenth time.</p>
<p>While the story is fun to read, I found it hard to stomach that a butler goes beyond his line of duty to save his master time and again. Uncle Fred, a maternal uncle to Pongo Twistleton is more believable in this sort of a role.</p>
The Mating Season2012-03-10T14:00:00+00:002012-03-10T14:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2012-03-10:/personal/blog/2012/03/10/the-mating-season/<p>Bertram Wooster is invited to a village to be part of a theatre troupe. Before leaving for the performance, he learns through his friend that his lover is being coaxed to marry her cousin and that Wooster was going to be their guest. After soliciting Jeeves advice, Wooster sets out …</p><p>Bertram Wooster is invited to a village to be part of a theatre troupe. Before leaving for the performance, he learns through his friend that his lover is being coaxed to marry her cousin and that Wooster was going to be their guest. After soliciting Jeeves advice, Wooster sets out to the village to give a stellar performance and sort out his friend's love matters. But things go bad at the last minute and Wooster has to improvise until the run up to the play. How Jeeves, Wooster's butler and he manage to fix the 'cross connections' and restore normalcy forms the rest of the story.</p>
<p>Despite a large ensemble of characters and numerous elements of confusion the story is very clear and hilarious. Only one author could have managed this, P.G Wodehouse.</p>
Talkative Man2012-01-29T20:23:29+00:002012-01-29T20:23:29+00:00Thejaswi Puthrayatag:thejaswi.info,2012-01-29:/personal/blog/2012/01/29/talkative-man/<p>R K Narayan is the natural choice after a heavy reading. "Talkative Man" is his shortest novel but not devoid of the signature humour or impressionable characters.</p>
<p>The "Talkative Man", a struggling journalist loves a good audience who are willing to lend their ears and he doesn't disappoint them. This …</p><p>R K Narayan is the natural choice after a heavy reading. "Talkative Man" is his shortest novel but not devoid of the signature humour or impressionable characters.</p>
<p>The "Talkative Man", a struggling journalist loves a good audience who are willing to lend their ears and he doesn't disappoint them. This time, he narrates the story of Dr. Rann from Timbuktu. Dr. Rann arrives in Malgudi for a UN research project, befriends the Talkative Man (TM) and moves into his house as a guest. TM begins hearing a lot of rumours about Dr. Rann and wants to evict him when an unexpected vistor to Malgudi arrives to assist him. How the visitor and TM conspire to get rid of Dr. Rann and save TM and Malgudi's reputation forms the rest of the story.</p>
<p>"Talkative Man" is yet another charming story from R K Narayan and you will not regret it.</p>
The Glass Palace2012-01-23T20:07:50+00:002012-01-23T20:07:50+00:00Thejaswi Puthrayatag:thejaswi.info,2012-01-23:/personal/blog/2012/01/23/the-glass-palace/<p>Amitav Ghosh is probably the best contemporary Indian writer. His books have style and are not formulaic.</p>
<p>The Glass Palace is a fictional novel that begins with the exile of the last king of Burma. The story spreads across 3 generations and ends in the 1990s with the Burmese junta …</p><p>Amitav Ghosh is probably the best contemporary Indian writer. His books have style and are not formulaic.</p>
<p>The Glass Palace is a fictional novel that begins with the exile of the last king of Burma. The story spreads across 3 generations and ends in the 1990s with the Burmese junta crackdown. The title might sound a little misleading because the central characters of the plot, Rajkumar and Dolly are not from the royal family. The story intertwines the personal events of Rajkumar and Dolly with historical events to add spice. Halfway through, the story sags but picks up momentum towards the end.</p>
<p>Read the book when you have got a lot of leisure and patience to appreciate it's style.</p>
Rework2012-01-21T18:51:53+00:002012-01-21T18:51:53+00:00Thejaswi Puthrayatag:thejaswi.info,2012-01-21:/personal/blog/2012/01/21/rework/<p><a class="reference external" href="http://37signals.com/rework/">Rework</a> might sound like a weird title for a book but after reading it, you can't think of a better one. The book is a collection of short essays on running a business from <a class="reference external" href="http://37signals.com/">37signals'</a> Jason Fried and David Heinemeier Hansson.</p>
<p>Most of the essays have been compiled from their …</p><p><a class="reference external" href="http://37signals.com/rework/">Rework</a> might sound like a weird title for a book but after reading it, you can't think of a better one. The book is a collection of short essays on running a business from <a class="reference external" href="http://37signals.com/">37signals'</a> Jason Fried and David Heinemeier Hansson.</p>
<p>Most of the essays have been compiled from their <a class="reference external" href="http://37signals.com/svn">Signal vs Noise blog</a> and are contrarian. Initially, I disregarded the essays but was involuntarily paying more attention as I progressed and my mind was blown off by the time I was done. Some of the essays like 'Meetings are toxic', 'ASAP is poison', 'Planning is guessing' are so compelling, you feel like implementing the suggestions immediately. The book has about 90 essays and an essay spans at most 3 pages. You can finish the book in a sitting of 3 hours.</p>
<p>If you harbour even a slight ambition of being an entrepreneur (in any field), you must read this book.</p>
Behind the Scenes: From request to response2012-01-02T20:45:23+00:002012-01-02T20:45:23+00:00Thejaswi Puthrayatag:thejaswi.info,2012-01-02:/tech/blog/2012/01/02/behind-the-scenes-from-request-to-response/<p>Cross posted from <a class="reference external" href="http://agiliq.com/blog/2012/01/behind-the-scenes-request-to-response/">my work blog</a>.</p>
<p>In the previous installment of "Behind the Scenes", we saw how the control flows from <a class="reference external" href="http://agiliq.com/blog/2011/09/behind-the-scenes-from-html-form-to-storage/">Form to File Storage</a>. Today, we are going to see how the application reacts from request to response.</p>
<p>In this post, we are going to assume that we are …</p><p>Cross posted from <a class="reference external" href="http://agiliq.com/blog/2012/01/behind-the-scenes-request-to-response/">my work blog</a>.</p>
<p>In the previous installment of "Behind the Scenes", we saw how the control flows from <a class="reference external" href="http://agiliq.com/blog/2011/09/behind-the-scenes-from-html-form-to-storage/">Form to File Storage</a>. Today, we are going to see how the application reacts from request to response.</p>
<p>In this post, we are going to assume that we are using django's inbuilt <tt class="docutils literal">runserver</tt>. The flow doesn't change much for other WSGI servers available.</p>
<p>When you invoke the <tt class="docutils literal">runserver</tt> management command, the command line options are validated and an instance of <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/core/servers/basehttp.py#L113">WSGIServer</a> is created and passed the <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/core/servers/basehttp.py#L130">WSGIRequestHandler</a>, which is used to create the request object (<a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/core/handlers/wsgi.py#L128">WSGIRequest</a>). After the request object is created and the request started signal is fired, the response is fetched through the <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/core/handlers/base.py#L72">WSGIRequestHandler.get_response(request)</a>.</p>
<p>In the <tt class="docutils literal">get_response</tt> method of the request handler, first the urlconf location (by default the <tt class="docutils literal">urls.py</tt>) is setup based on the <tt class="docutils literal">settings.ROOT_URLCONF</tt>. Then a <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/core/urlresolvers.py#L219">RegexURLResolver</a> compiles the regular expressions in the urlconf file. Next, the request middlewares are called in the order specified in the <tt class="docutils literal">settings.MIDDLEWARE_CLASSES</tt> followed by the view middlewares after matching the view (<tt class="docutils literal">callback</tt>) function against the compiled regular expressions from the urlconf. Then the view (<tt class="docutils literal">callback</tt>) is invoked and verified that it does not return <tt class="docutils literal">None</tt> before calling the response middlewares.</p>
<p>You can see the pictorial representation of the flow below:</p>
<a class="reference external image-reference" href="http://agiliq.com/static/dumps/images/20120102/request_to_response.png"><img alt="Request to Response Flow" class="align-center" src="http://agiliq.com/static/dumps/images/20120102/request_to_response.png" style="width: 543px; height: 792px;" /></a>
Sencha Touch vs jQuery Mobile2011-12-15T20:07:13+00:002011-12-15T20:07:13+00:00Thejaswi Puthrayatag:thejaswi.info,2011-12-15:/tech/blog/2011/12/15/sencha-touch-vs-jquery-mobile/<p>Generally, I don't like to do a comparison of technologies or products in a single post because each deserves a dedicated post. But such type of posts get obsolete fast and the effort put into writing (not researching) them goes waste.</p>
<p>Before I start off the comparison, I need to …</p><p>Generally, I don't like to do a comparison of technologies or products in a single post because each deserves a dedicated post. But such type of posts get obsolete fast and the effort put into writing (not researching) them goes waste.</p>
<p>Before I start off the comparison, I need to explain the workflow of developing mobile apps at <a class="reference external" href="http://agiliq.com/">work</a>. <a class="reference external" href="http://ilovemydesigns.com/">Sai</a>, the chief designer, draws the mockups on paper, then prototypes on Photoshop and sends them for the approval from the client. The client then suggests some changes and a final set of screens (PSDs set in order) are sent to the developers. We prefer to write HTML5 apps running on <a class="reference external" href="http://www.phonegap.com/">phonegap</a> because it gives us the ability to create cross platform apps effortlessly (well almost) and we write once (and in stuff we are most comfortable with) and deploy everywhere (well again almost). Another note to make is that <a class="reference external" href="http://agiliq.com/">we</a> specialize in writing web apps and are at home with <a class="reference external" href="http://jQuery.com/">jQuery</a>. So take our comparison with a slight pinch of salt.</p>
<p>Now based on the background above, here is the brain dump of the comparison between <a class="reference external" href="http://www.sencha.com/products/touch/">Sencha Touch</a> (v1.1) and <a class="reference external" href="http://jquerymobile.com/">jQueryMobile</a> (v1.0)</p>
<div class="section" id="pros-for-sencha">
<h2>Pros for Sencha</h2>
<ul class="simple">
<li>Everything is JS (JS generates the DOM for you)</li>
<li>Oldest mobile app framework.</li>
<li>MVC pattern (neat separation of models, views and controllers)</li>
</ul>
</div>
<div class="section" id="cons-for-sencha">
<h2>Cons for Sencha</h2>
<ul class="simple">
<li>Difficult to design layouts as it requires knowledge of JS. (Web) Designer unfriendly!</li>
<li>Negligible documentation (Needs a lot of love).</li>
<li>Too much dependence on global variables. Debugging mess.</li>
<li>Difficult to theme. Requires messing around with JS and SCSS.</li>
<li>Feels like using the <a class="reference external" href="http://shop.oreilly.com/product/9780596517748.do">bad parts of JS</a>. Lots of new operator, globals and an awkward API.</li>
<li>Only supports webkit based browsers (hence suitable mainly for mobile apps)</li>
<li>The code repo is available to you on only if you purchase support and development is mainly done within Sencha company.</li>
</ul>
</div>
<div class="section" id="pros-for-jqmobile">
<h2>Pros for jQMobile</h2>
<ul class="simple">
<li>It's jQuery!</li>
<li>Active ecosystem. Lots of plugins.</li>
<li>Better documentation</li>
<li>Finer control of the HTML. Can use full power of HTML5.</li>
<li>Dead easy to make themes. Have an online ThemeRoller!</li>
<li>Supports majority of the browsers (<a class="reference external" href="http://jquerymobile.com/gbs/">http://jquerymobile.com/gbs/</a>)</li>
<li>Can be used for mobile site as well as mobile app (embedded webkit)</li>
<li>Development is open and happens publicly with the support of the community.</li>
</ul>
</div>
<div class="section" id="cons-for-jqmobile">
<h2>Cons for jQMobile</h2>
<ul class="simple">
<li>Just reached 1.0. Fairly young but very promising.</li>
<li>No MVC. Lot of care has to be taken while organizing the code.</li>
</ul>
</div>
Guardian Angels2011-12-14T22:43:25+00:002011-12-14T22:43:25+00:00Thejaswi Puthrayatag:thejaswi.info,2011-12-14:/personal/blog/2011/12/14/guardian-angels/<p>It was the perfect weather for an excursion and Rajith was accompanying his friends to a nearby hill station. He had picked all but the last hiker. The car pulled outside Amitesh's house and Rajith honked twice to signal their arrival. Within a minute, they received a text message from …</p><p>It was the perfect weather for an excursion and Rajith was accompanying his friends to a nearby hill station. He had picked all but the last hiker. The car pulled outside Amitesh's house and Rajith honked twice to signal their arrival. Within a minute, they received a text message from Amitesh. He would join them as soon as he packed his hiking shoes. The group in the car were bubbling with excitement for the trip ahead and cursing Amitesh for holding them up. A few metres on the other side of the road, Rajith spotted a couple holding hands and struggling to cross the road. The old man wore a muffler round his neck and leaned on his walking stick. The woman, just a little younger walked with a slight limp and wore thick glasses. Rajith looked away and gnawed his teeth with discomfort. He quickly raised the car windows and hoped he hadn't been spotted. Slowly, guilt and a wave of memories started overpowering him and he hoped his discomfort was not visible to the rest of the group.</p>
<p>One day, sixteen years ago, when Rajith was just eight, his caretaker bolted him in the house and fled. After waking up from his afternoon siesta and finding no soul around, Rajith bawled until his neighbours Shekhar uncle and Madhavi aunty, who lived across in their NRI son's house rescued him. They looked after him till his parents got back from their day's work. Rajith's parents were very furious with the caretaker and also grateful to uncle and aunty. This happened to be their first encounter with the neighbours. For months, Rajith's parents had been avoiding all the neighbours fearing loss of privacy.</p>
<p>That night, Rajith's mother, Sarala Devi hatched a master plan. She questioned her husband why not leave young Rajith under the care of the neighbours? They looked after him so well and didn't seem to have many visitors or go out a lot. Her husband deferred the decision to next morning and went off to bed. In the morning, Sarala tried in vain to get her husband's approval as he was engrossed in the business paper. While leaving for work, she cursed her husband's indecisiveness and walked over to Shekhar uncle's house. She handed them a box of sweets and thanked them for the previous day's favour. Shekhar Thatha (as Rajith fondly addressed), reluctantly accepted the gift as he and his wife were diabetic. As Sarala was leaving, she put on a very embarrassed expression and requested if they could take care of Rajith after he was back from school till they arranged a caretaker. She promised it wouldn't take more than a couple of days.</p>
<p>After a few days, she went over to their house and informed them with a gloomy face that she was quitting her job to look after her son as she couldn't arrange a good caretaker. Shekhar uncle and Madhavi aunty were taken aback but did not utter a word. As she was leaving, she asked them for a last favour to look after Rajith till she put in her resignation. Later, during their night meal, Madhavi aunty convinced her husband to request Sarala to reconsider as they would love to look after Rajith. He came as a whiff of fresh air in their mundane retired life. When Rajith's mother heard the news, she jumped with joy and profusely thanked the couple for their gesture. She wished to know if they had any expectations but was surprised to know they had none.</p>
<p>Rajith literally lived at Shekhar Thatha's house for 6 years. He loved Madhavi Nanamma's evening snacks and would go to the playground accompanied by Thatha. These, as Rajith later recollected in his class 10 year book were the golden years of his life.</p>
<p>As Rajith grew up, he frequently dropped in to enquire about their well being and stayed back till dinner discussing a lot of topics, even some he was scared to breach with his parents. One day, as he got back from school after giving his last class 10 exam, the watchman informed him that Shekhar uncle and his wife had vacated their apartment. This left Rajith distraught but time healed his pain, until this day.</p>
<p>Today, his mind was torn between the hike with friends and being with Shekhar Thatha and Madhavi Nanamma. He kept running his fingers over the steering wheel and grimacing when Amitesh rushed into the car and followed it up with apologies to avoid angry stares and curses. The group prompted Rajith to rev the car to life and start off on the hike of a lifetime. Rajith obeyed but his face was pale and emotionless, as if under a trance. His thoughts and soul were now on the opposite side of the road helping Thatha and Nanamma cross the road and reliving the golden years of his life. It was his time to be their "Guardian Angel".</p>
Uncle Fred2011-12-13T22:18:55+00:002011-12-13T22:18:55+00:00Thejaswi Puthrayatag:thejaswi.info,2011-12-13:/personal/blog/2011/12/13/uncle-fred/<p>Uncle Fred is just like any other caring uncle but with one difference, his knack to invite trouble and then successfully sort it but only after a series of comic events. Lord Frederick Ickenham, better known as Uncle Fred is a lovable character from P.G. Wodehouse's novel series.</p>
<p>While …</p><p>Uncle Fred is just like any other caring uncle but with one difference, his knack to invite trouble and then successfully sort it but only after a series of comic events. Lord Frederick Ickenham, better known as Uncle Fred is a lovable character from P.G. Wodehouse's novel series.</p>
<p>While rummaging through the book shelf, I picked up "Uncle Fred, An Omnibus". I read this book many years back but couldn't recollect the stories and so started re-reading it.</p>
<p>Uncle Fred's wife who recognizes his talent for inviting trouble keeps him on a leash. But during her yearly summer outing, Uncle Fred is allowed to visit the town for a short period. All the stories from the omnibus are based during this 'liberated' period.</p>
<p>The omnibus consists of three stories:</p>
<ul class="simple">
<li>Uncle Fred in Springtime</li>
<li>Uncle Dynamite</li>
<li>Cocktail Time</li>
</ul>
<p>In "Uncle Fred in Springtime", Uncle Fred decides to abduct a pig from it's obsessive master for a friend and simultaneously tries to mend the broken heart of his niece. He does this assuming a false name and the events that ensue are humourous.</p>
<p>Uncle Fred who disapproves his nephew, Pongo Twistleton's engagement to Hermione decides to set the record straight and reunite his nephew with his previous love Sally in the "Uncle Dynamite". In this story, the manipulative nature of Uncle Fred is exhibited very well and Pongo who knows best about his uncle falls prey to his plan.</p>
<p>What starts off as a typical Uncle Fred prank in "Cocktail Time", inspires Raymond Bastable to write a novel ridiculing the younger generation. The book becomes a runaway hit but the author cannot claim it's authorship to prevent his public life and career from getting ruined. Uncle Fred steps in to sort Raymond's sticky problem but goes onto solve a lot more!</p>
<p>The books are from the P.G. Wodehouse stable, what more do I have to say?</p>
The Financial Expert2011-09-24T21:18:55+00:002011-09-24T21:18:55+00:00Thejaswi Puthrayatag:thejaswi.info,2011-09-24:/personal/blog/2011/09/24/the-financial-expert/<p>When does scarcity of money hurt the most? When you see it's grace showered on the undeserved. This is the premise of "The Financial Expert", yet another masterpiece from RK Narayan.</p>
<p>Margayya is a petty service agent who helps villagers extract loans from a co-operative society bank. One day, he …</p><p>When does scarcity of money hurt the most? When you see it's grace showered on the undeserved. This is the premise of "The Financial Expert", yet another masterpiece from RK Narayan.</p>
<p>Margayya is a petty service agent who helps villagers extract loans from a co-operative society bank. One day, he is obstructed by the secretary of the bank and this infuriates him and resolves to become rich and show the secretary his place.</p>
<p>After a series of misadventures, Margayya finally becomes rich. Still yearning for more he starts a new business which not only brings in money but also turmoil.</p>
<p>Only few writers can deal with sensitive topics like pain and personal setbacks with a sense of humour and RK Narayan has successfully delivered on that count.</p>
Behind the Scenes: From HTML Form to Storage2011-09-21T18:01:51+00:002011-09-21T18:01:51+00:00Thejaswi Puthrayatag:thejaswi.info,2011-09-21:/tech/blog/2011/09/21/behind-the-scenes-from-html-form-to-storage/<p>Cross posted from my <a class="reference external" href="http://agiliq.com/blog/2011/09/behind-the-scenes-from-html-form-to-storage/">work blog post</a></p>
<p>In this post, we are going to see what happens behind the scenes when a file is uploaded to a django powered web application.</p>
<a class="reference external image-reference" href="http://agiliq.com/dumps/images/20110921/file_storage.gif"><img alt="File Upload Flow" class="align-center" src="http://agiliq.com/dumps/images/20110921/file_storage.gif" style="width: 543px; height: 792px;" /></a>
<p>An HTML form with a file input (atleast one) and encoding set to <a class="reference external" href="https://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files">multipart/form-data</a> is submitted. The <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/http/multipartparser.py#L31">MultiPartParser …</a></p><p>Cross posted from my <a class="reference external" href="http://agiliq.com/blog/2011/09/behind-the-scenes-from-html-form-to-storage/">work blog post</a></p>
<p>In this post, we are going to see what happens behind the scenes when a file is uploaded to a django powered web application.</p>
<a class="reference external image-reference" href="http://agiliq.com/dumps/images/20110921/file_storage.gif"><img alt="File Upload Flow" class="align-center" src="http://agiliq.com/dumps/images/20110921/file_storage.gif" style="width: 543px; height: 792px;" /></a>
<p>An HTML form with a file input (atleast one) and encoding set to <a class="reference external" href="https://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files">multipart/form-data</a> is submitted. The <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/http/multipartparser.py#L31">MultiPartParser</a> parses the POST request and returns a tuple of the POST and FILES data <tt class="docutils literal">(request.POST, request.FILES)</tt>. The MultiPartParser processes the uploaded data using the <a class="reference external" href="https://docs.djangoproject.com/en/dev/topics/http/file-uploads/#upload-handlers">File Upload Handlers</a> objects (through the <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/core/files/uploadhandler.py#L87">new_file</a>, <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/core/files/uploadhandler.py#L100">receive_data_chunk</a> and <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/core/files/uploadhandler.py#L116">upload_complete</a> methods). The <tt class="docutils literal">request.FILES</tt> values are a sequence of instances of <a class="reference external" href="https://docs.djangoproject.com/en/dev/topics/http/file-uploads/#uploadedfile-objects">UploadedFile</a>.</p>
<p>In the django form, we pass the <tt class="docutils literal">request.FILES</tt> MultiValueDict. These UploadedFile instances are validated by the <tt class="docutils literal">full_clean</tt> method on the <a class="reference external" href="https://docs.djangoproject.com/en/dev/ref/forms/api/">Form</a>. The <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/forms/forms.py#L254">full_clean</a> method in turn calls the <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/forms/forms.py#L273">_clean_fields</a> method which calls the <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/forms/fields.py#L493">clean</a> method on the <tt class="docutils literal">forms.FileField</tt> and checks if the data is empty.</p>
<p>After the form is successfully validated, we might assign and save the <tt class="docutils literal">cleaned_data</tt> of the form to a model instance (or by saving the <tt class="docutils literal">ModelForm</tt>). When the <tt class="docutils literal">save</tt> method on the model instance is called, the <tt class="docutils literal">save_base</tt> method calls a <tt class="docutils literal">pre_save</tt> method on each field of the model. This <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/db/models/fields/files.py#L244">pre_save</a> method returns the value of the file instance bound to that FileField and calls it's <tt class="docutils literal">save</tt> method. This <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/db/models/fields/files.py#L84">save</a> method (on the models.FileField) in turn calls the <a class="reference external" href="https://code.djangoproject.com/browser/django/trunk/django/core/files/storage.py#L34">save (Storage)</a> method on the <tt class="docutils literal">Storage</tt> which is either picked up from the arguments passed to the FileField (<tt class="docutils literal"><span class="pre">FileField(storage=...)</span></tt>) or the <a class="reference external" href="https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-DEFAULT_FILE_STORAGE">DEFAULT_FILE_STORAGE</a> settings attribute.</p>
<p>This is the flow from the HTML Form all the way upto the File Storage. Hope you liked it.</p>
Installing drivers for Samsung ML-1676 on Linux2011-09-10T22:16:08+00:002011-09-10T22:16:08+00:00Thejaswi Puthrayatag:thejaswi.info,2011-09-10:/tech/blog/2011/09/10/installing-drivers-for-samsung-ml-1676-on-linux/<p>Today, I purchased a Samsung ML-1676 Monochrome Laser Printer. I was under the impression that most printers are now supported out of the box but I was wrong. This model of the printer uses a proprietary language called the Samsung Printing Language (SPL) and hence drivers are not included in …</p><p>Today, I purchased a Samsung ML-1676 Monochrome Laser Printer. I was under the impression that most printers are now supported out of the box but I was wrong. This model of the printer uses a proprietary language called the Samsung Printing Language (SPL) and hence drivers are not included in the distributions by default. But fear not, there is a very simple process to setup your printer because Samsung provides drivers not just for Windows but also for Mac and Linux based distributions! Great going Samsung, you deserve a pat on the back.</p>
<p>Download the "Unified Drivers" for Linux from the download center on Samsung website. At the moment of writing this post, the drivers are available <a class="reference external" href="http://www.samsung.com/in/support/detail/supportPrdDetail.do?menu=SP00&prd_ia_cd=1704&prd_mdl_cd=ML-1676%2FXIP&prd_mdl_name=ML-1676&srchword=ML-1676">here</a>.</p>
<p>Switch on your printer and connect it to your PC. Then, extract the downloaded file and start your printer configuration suite. On KDE, it is found under System Settings > Printer Configuration. Click on the "New Printer" option and select a "New Network Printer". Most likely, you will see a "Samsung ML-1670 Series" connection in the various printer connection options. If you do not find it, check if the printer is connected and switched on. Select the "Samsung ML-1670 Series" connection and proceed. In the next screen, select the "Provide the PPD file" (PPD - PostScript Printer Description) option and select the following file from your downloaded directory (<Download_directory>/cdroot/Linux/noarch/at_opt/share/ppd/ML-1670spl.ppd).</p>
<p>The driver for the printer is installed. All you now need is the 'rastertosamsungsplc' utility which translates the default print language to the Samsung Printer Language. This utility is also present in the download. Copy the 'rastertosamsungsplc' from the <Download_directory>/cdroot/Linux/<arch>/at_root/usr/lib/cups/filter/ directory to /usr/lib/cups/filter/ on your PC. Fill the <arch> in the path appropriately. If you use a 32-bit machine, arch would be i386 and x86_64 on a 64-bit.</p>
<p>Setting up this printer is a little bit of a struggle but once setup, it works perfectly.</p>
<p>PS: The option of providing PPD works for a lot of Samsung models and you may be lucky to find your model in the "Unified Driver" download.</p>
The Bachelor of Arts2011-09-04T08:40:20+00:002011-09-04T08:40:20+00:00Thejaswi Puthrayatag:thejaswi.info,2011-09-04:/personal/blog/2011/09/04/the-bachelor-of-arts/<p>"The Bachelor of Arts" is probably RK Narayan's best book I have read so far. It has all the elements that contemporary writers abuse - friendship, infatuation, heart break, self awakening and love. But the book differs from the current crop in it's treatment. It is subtle and the doesn't go …</p><p>"The Bachelor of Arts" is probably RK Narayan's best book I have read so far. It has all the elements that contemporary writers abuse - friendship, infatuation, heart break, self awakening and love. But the book differs from the current crop in it's treatment. It is subtle and the doesn't go overboard at any point.</p>
<p>The book is divided into 4 parts with the first describing Chandran's final year of "Bachelor of Arts". The second part of the book deals with his "love" at first sight for Malathi. Sadly, a series of events (hilariously narrated) derail the wedding. This leaves Chandran heart broken and he punishes himself by donning saffron robes and imposing a self exile. Later on, he realizes that he is needlessly punishing his caring parents over his "silly" infatuation.</p>
<p>In the final part, Chandran dedicates himself to find a purpose in life and starts a business. While he is working hard to improve his business, he finally finds love in the "most" conventional way.</p>
<p>What impressed me in the book is the author's treatment of Chandran's friendship with Ramu and later Chandran's bitterness towards Ramu when they lose contact after college. This is summed up perfectly below:</p>
<p><em>"People pretended that they were friends, when the fact that they were brought together by force of circumstances. The classroom or the club or office created friendships. When circumstances changed the relations, too, snapped."</em></p>
<p>There is another instance that is brought out very beautifully in the book about how our respect for teachers and their attitude towards us changes after graduation.</p>
<p>I had a smile while reading this book as it made me reminisce my school and college days.</p>
Let The People Think2011-09-03T12:05:47+00:002011-09-03T12:05:47+00:00Thejaswi Puthrayatag:thejaswi.info,2011-09-03:/personal/blog/2011/09/03/let-the-people-think/<p>"Let The People Think" is a collection of essays by <a class="reference external" href="http://en.wikipedia.org/wiki/Bertrand_Russell">Bertrand Russell</a>, an English writer, philosopher and mathematician. He was one of the very few English men to profess his anti-war and anti-colonial thoughts during the two world wars and this nearly led to his persecution after being labelled a …</p><p>"Let The People Think" is a collection of essays by <a class="reference external" href="http://en.wikipedia.org/wiki/Bertrand_Russell">Bertrand Russell</a>, an English writer, philosopher and mathematician. He was one of the very few English men to profess his anti-war and anti-colonial thoughts during the two world wars and this nearly led to his persecution after being labelled a "traitor". He also championed for other causes like freedom of thought, free love and nuclear disarmament.</p>
<p>The essays discuss a wide array of topics like the importance of scepticism in society, deregulation of education from the hands of the state, free speech and the effect of propaganda on it. He has done quite a lot of research on these topics and backs them up with convincing arguments. I found this book very contextual (despite having been written in the 1920s) in the wake of an anti-corruption movement in India and how media played a massive role in it's success.</p>
The Real Inspector Hound2011-09-01T19:18:57+00:002011-09-01T19:18:57+00:00Thejaswi Puthrayatag:thejaswi.info,2011-09-01:/personal/blog/2011/09/01/the-real-inspector-hound/<p>"The Real Inspector Hound" is a satire on theatre critics and the image of English aristocracy built by P.G Wodehouse and Agatha Christie. While taking the viewers through a murder plot, the play showcases the absurdity of theatre critics. Throughout the 75 minutes, the viewers are kept guessing the …</p><p>"The Real Inspector Hound" is a satire on theatre critics and the image of English aristocracy built by P.G Wodehouse and Agatha Christie. While taking the viewers through a murder plot, the play showcases the absurdity of theatre critics. Throughout the 75 minutes, the viewers are kept guessing the identity of the murder victim and "The Real Inspector Hound". The screenplay is unconventional and has lot of twists to keep the viewer engrossed.</p>
<p>The play is based on Tom Stoppard's by the same name and was performed by the Quaff Theatre for The Hindu MetroPlus Theatre Fest 2011.</p>
Success2011-08-28T12:30:24+00:002011-08-28T12:30:24+00:00Thejaswi Puthrayatag:thejaswi.info,2011-08-28:/personal/blog/2011/08/28/success/<p>"Success", a play directed by Edward Morgan of Theatre MXT (USA) explores the cost of success. Success has lot of meanings and people tend to categorize it further as professional success, academic success etc.</p>
<p>Rick Sterling, a media consultant is sought after by lots of politicians as he is credited …</p><p>"Success", a play directed by Edward Morgan of Theatre MXT (USA) explores the cost of success. Success has lot of meanings and people tend to categorize it further as professional success, academic success etc.</p>
<p>Rick Sterling, a media consultant is sought after by lots of politicians as he is credited with getting the current President of USA elected. Though he is successful, he is going through a lot of traumatic events in his personal life. At this juncture, an Egyptian woman who plans to run for presidency in her country seeks Rick's help. The play ends with Rick on the verge of making a decision to accept the President's re-election campaign or the Egyptian woman's offer.</p>
<p>John Kishline was amazing as Rick Sterling and he held the whole play together. It might be slightly difficult for Indians to relate to this play as it requires understanding that the American president is "manufactured" by a series of corporate deals, high profile endorsements and a high pitched campaign which involves a well organized team of hard working professionals in the background.</p>
The Interview2011-08-27T15:17:40+00:002011-08-27T15:17:40+00:00Thejaswi Puthrayatag:thejaswi.info,2011-08-27:/personal/blog/2011/08/27/the-interview/<p>Yesterday, I watched my first play after school at Ravindra Bharathi as a part of The Hindu Metroplus Theatre Fest 2011.</p>
<p>"<a class="reference external" href="http://akvarious.com/projects_theinterview.htm">The Interview</a>", an award winning play directed by <a class="reference external" href="http://akvarious.com/team.htm">Akarsh Khurana</a> of <a class="reference external" href="http://akvarious.com/">Akvarious Productions</a> depicted a stressful interview of a desperate job seeker at the country's largest corporation. It showcased …</p><p>Yesterday, I watched my first play after school at Ravindra Bharathi as a part of The Hindu Metroplus Theatre Fest 2011.</p>
<p>"<a class="reference external" href="http://akvarious.com/projects_theinterview.htm">The Interview</a>", an award winning play directed by <a class="reference external" href="http://akvarious.com/team.htm">Akarsh Khurana</a> of <a class="reference external" href="http://akvarious.com/">Akvarious Productions</a> depicted a stressful interview of a desperate job seeker at the country's largest corporation. It showcased the dark aspects of corporate culture through black humour and had the audience in splits through most of the play. The job seeker is promised the job if he successfully completes a personal errand for the interviewer. How the interviewee uses his resourcefulness and if he is successful forms rest of the play. With a running time of 80 minutes and lots of witty dialogues, this play is a blast!</p>
Mr. Sampath: The Printer of Malgudi2011-08-19T22:12:44+00:002011-08-19T22:12:44+00:00Thejaswi Puthrayatag:thejaswi.info,2011-08-19:/personal/blog/2011/08/19/mr-sampath-the-printer-of-malgudi/<p>Srinivas wants to chart his own path but is burdened by responsibilities. He comes to Malgudi to start "The Banner", a weekly magazine and here he meets Sampath, the printer. Together, they form a partnership to promote the weekly. When the subscriptions start looking up, Sampath forces Srinivas to suspend …</p><p>Srinivas wants to chart his own path but is burdened by responsibilities. He comes to Malgudi to start "The Banner", a weekly magazine and here he meets Sampath, the printer. Together, they form a partnership to promote the weekly. When the subscriptions start looking up, Sampath forces Srinivas to suspend the publication and drags him into writing a story for a movie he is co-producing. The rest of the book deals with the fate of the movie and if "The Banner" is resurrected.</p>
<p>A simple story narrated in typical RK Narayan style.</p>
The Serpent and the Rope2011-08-01T20:14:32+00:002011-08-01T20:14:32+00:00Thejaswi Puthrayatag:thejaswi.info,2011-08-01:/personal/blog/2011/08/01/the-serpent-and-the-rope/<p>As I was cleaning a shelf full of books from my dad's collection, my eyes fell on an old and faded book that went unnoticed in the previous chores. The book was "The Serpent and the Rope" by <a class="reference external" href="http://en.wikipedia.org/wiki/Raja_Rao">Raja Rao</a>. I looked up the name on Wikipedia and realized that …</p><p>As I was cleaning a shelf full of books from my dad's collection, my eyes fell on an old and faded book that went unnoticed in the previous chores. The book was "The Serpent and the Rope" by <a class="reference external" href="http://en.wikipedia.org/wiki/Raja_Rao">Raja Rao</a>. I looked up the name on Wikipedia and realized that the author is considered one of India's finest English novelists. This was sufficient for me to start off with the book immediately.</p>
<p>This book is the story of Ramaswamy, a brahmin from India and his wife Madeleine, a French atheist. The book discusses the journey of the couple in their search for truth and spirituality. This book is loosely based on the life of Raja Rao and is generally labelled as his semi-autobiography.</p>
<p>As I started reading the book, I realized it was very heavy in Hinduism and philosophy. Concepts like <a class="reference external" href="http://en.wikipedia.org/wiki/Dualism_(philosophy_of_mind)">duality</a>, <a class="reference external" href="http://en.wikipedia.org/wiki/Metaphysics">metaphysics</a>, <a class="reference external" href="http://en.wikipedia.org/wiki/Advaita_Vedanta">advaita</a> etc were 'repeatedly' written about in the book. Being an atheist, I got bored but stuck on because the book effortlessly switches between the scenic Alps at Aix, Benares and London and has a different style interspersed with couplets and slokas.</p>
<p>If you are a philosophical person, this 'is' a book for you. Though the book spans to just above 400 pages, it took me close to 2 months to finish it because it was a challenge trying to understand such 'heavy' stuff. Time for something lighter now.</p>
Relationships that defy logic2011-07-24T12:05:58+00:002011-07-24T12:05:58+00:00Thejaswi Puthrayatag:thejaswi.info,2011-07-24:/personal/blog/2011/07/24/relationships-that-defy-logic/<p>Some bonds transcend logic and blood relationships. When was the last time you experienced this?</p>
<p>This morning, my neighbour's mother whom I fondly called "Paati" (grandmother in Tamil) passed away. She was an active lady who cared for everyone and bore no ill feelings against anyone. She knew my culinary …</p><p>Some bonds transcend logic and blood relationships. When was the last time you experienced this?</p>
<p>This morning, my neighbour's mother whom I fondly called "Paati" (grandmother in Tamil) passed away. She was an active lady who cared for everyone and bore no ill feelings against anyone. She knew my culinary likes and would get those tasty dishes over just for me whenever she cooked them or would cook for me when my parents would be out of town despite my vehement protestations. Before I started off on a new step of life or on success, she would be among the first to wish me in the neighbourhood.</p>
<p>I never understood her feelings especially since I was just a neighbour's son and rarely met her. But today, in her passing I have realized the importance of those feelings and feel guilty that I did not reciprocate.</p>
<p>"Paati", you will be missed and may your soul rest in peace.</p>
Sharing X display over VNC2011-07-21T11:01:22+00:002011-07-21T11:01:22+00:00Thejaswi Puthrayatag:thejaswi.info,2011-07-21:/tech/blog/2011/07/21/sharing-x-display-over-vnc/<p>Designing for browsers is hard! There are a multitude of browsers that have to be supported and each have their quirks. While there are tools to make this task easy, recently <a class="reference external" href="http://ilovemydesigns.com/">Sai</a> (chief designer at <a class="reference external" href="http://www.agiliq.com/">Agiliq</a>) had to checkout how a client's project looked in Chromium and Firefox on Linux …</p><p>Designing for browsers is hard! There are a multitude of browsers that have to be supported and each have their quirks. While there are tools to make this task easy, recently <a class="reference external" href="http://ilovemydesigns.com/">Sai</a> (chief designer at <a class="reference external" href="http://www.agiliq.com/">Agiliq</a>) had to checkout how a client's project looked in Chromium and Firefox on Linux based operating systems.</p>
<p>We could have setup VirtualBox and installed Ubuntu image and all related software but it sounded like a pain for a one-time exercise. We wanted some quick way to set up and ended sharing an <a class="reference external" href="http://www.x.org/">X</a> display over VNC.</p>
<p>Before I describe the process, let's take a small detour to understand some technicalities.</p>
<ul>
<li><p class="first">By default, X runs on display <cite>:0</cite> or <cite>:0.0</cite>. Here's how you can check it out:</p>
<pre class="literal-block">
$ echo $DISPLAY
:0.0
</pre>
</li>
<li><p class="first">The X process runs as <cite>root</cite> on most Linux based operating systems and you would generally require administrator access to run a new X display. We overcome this restriction by using <a class="reference external" href="http://en.wikipedia.org/wiki/Xvfb">Xvfb</a>, a headless X server.</p>
</li>
</ul>
<p>Things to setup before the you can share the display:</p>
<ul class="simple">
<li>Install <a class="reference external" href="http://en.wikipedia.org/wiki/Xvfb">Xvfb</a></li>
<li>Install <a class="reference external" href="http://www.karlrunge.com/x11vnc/">x11vnc</a></li>
<li>Install a VNC client on the client machine (We used <a class="reference external" href="http://www.realvnc.com/">RealVNC</a> on Sai's windows machine)</li>
</ul>
<p>Most of the above software can easily be installed through a package manager (say Ubuntu's <cite>apt-get</cite> or Fedora's <cite>yum</cite>).</p>
<p>Here's the process:</p>
<ul>
<li><p class="first">Run Xvfb on display <cite>:1</cite> with a resolution of <cite>1366x768</cite>, colour depth of <cite>24</cite> and on screen <cite>0</cite>:</p>
<pre class="literal-block">
xinit -- /usr/bin/Xvfb :1 -screen 0 1366x768x24
</pre>
</li>
<li><p class="first">Point x11vnc to use the display <cite>:1</cite> and forward to a VNC client:</p>
<pre class="literal-block">
x11vnc -display :1
</pre>
</li>
<li><p class="first">On the client, fire up your VNC client and enter the IP address of the box running the above setup.</p>
</li>
</ul>
<p>There are a huge set of options for Xvfb and x11vnc (like authorization, caching etc) that may be set to tweak the display. Just check the man pages for more details.</p>
Everybody loves a good drought2011-07-11T21:26:35+00:002011-07-11T21:26:35+00:00Thejaswi Puthrayatag:thejaswi.info,2011-07-11:/personal/blog/2011/07/11/everybody-loves-a-good-drought/<p>The news of the number of <a class="reference external" href="http://en.wikipedia.org/wiki/List_of_Indians_by_net_worth">Indian billionaires</a> in the <a class="reference external" href="http://en.wikipedia.org/wiki/Forbes_list_of_billionaires">Forbes list</a> increasing every year should be heartening, right? Actually not, the major portion of the country (generally dubbed "The other India" by the foreign press) only seems to be getting poorer by the day. They are dispossessed of their …</p><p>The news of the number of <a class="reference external" href="http://en.wikipedia.org/wiki/List_of_Indians_by_net_worth">Indian billionaires</a> in the <a class="reference external" href="http://en.wikipedia.org/wiki/Forbes_list_of_billionaires">Forbes list</a> increasing every year should be heartening, right? Actually not, the major portion of the country (generally dubbed "The other India" by the foreign press) only seems to be getting poorer by the day. They are dispossessed of their only belongings of land and livestock, their identities fudged and don't even get a decent hearing in the media or any other public fora.</p>
<p>A friend who saw me reading this book, brushed it off as "Poverty porn" just by looking at the cover! This book is anything but that. It is based on the research of eminent journalist and Magsaysay award winner Palagummi Sainath. For those who read "The Hindu", he would be no stranger. The book written in the late 90s covers the unheard stories of the farmers, tribals, landless labourers and project evacuees from the states of Orissa, Madhya Pradesh and Tamil Nadu.</p>
<p>As you keep reading the book, you keep wondering if this book was really written in the 90s because similar stories are still being reported in the media. Looks like we have still not learnt any lessons. This book hits out at our conscience without being sensationalist. Plain reporting of facts that I assure will get you thinking.</p>
<p>You should read <a class="reference external" href="http://en.wikipedia.org/wiki/Everybody_Loves_a_Good_Drought">the book</a> to learn about real extent of development in India. Something needs to be done about these issues...</p>
The Wanderer and The Prophet2011-07-08T21:12:34+00:002011-07-08T21:12:34+00:00Thejaswi Puthrayatag:thejaswi.info,2011-07-08:/personal/blog/2011/07/08/the-wanderer-and-the-prophet/<p><a class="reference external" href="http://afrozensecond.wordpress.com/">Kalyan</a> recommended these books and need I say more about his recommendations? The Wanderer and The Prophet (two separate books) are a collection of fables and parables by <a class="reference external" href="http://en.wikipedia.org/wiki/Khalil_Gibran">Kahlil Gibran</a>.</p>
<p>"The Wanderer" is a collection of close to twenty stories each spanning a couple of pages and discuss one philosophical …</p><p><a class="reference external" href="http://afrozensecond.wordpress.com/">Kalyan</a> recommended these books and need I say more about his recommendations? The Wanderer and The Prophet (two separate books) are a collection of fables and parables by <a class="reference external" href="http://en.wikipedia.org/wiki/Khalil_Gibran">Kahlil Gibran</a>.</p>
<p>"The Wanderer" is a collection of close to twenty stories each spanning a couple of pages and discuss one philosophical concept each. The way these concepts have been handled is interesting and you can't stop drawing parallels to India's Jataka tales except that most characters are humans and not animals.</p>
<p>"The Prophet" on the other hand is the story of a Greek Prophet's discourse to his followers before he moves on where life takes him. This book documents a question and answer session between the prophet and his followers. The followers seek knowledge about education, work, wealth etc and the prophet uses imagery and analogies to enlighten them. Each Q&A session forms a chapter and like "The Wanderer" spans a couple of pages each.</p>
<p>The books are lively reading especially when waiting for an impunctual person (like a doctor). Read these books especially now that you have two people recommending them!</p>
Backup SMS database on Android2011-04-29T11:12:59+00:002011-04-29T11:12:59+00:00Thejaswi Puthrayatag:thejaswi.info,2011-04-29:/tech/blog/2011/04/29/backup-sms-database-on-android/<p>While there are ready made apps that backup and restore your SMSes, you can easily backup the database if you have a <strong>rooted</strong> phone without installing any external software.</p>
<p>The SMSes are stored in an SQLite database available under:</p>
<pre class="literal-block">
/dbdata/data/com.android.providers.telephony/databases/mmssms.db
</pre>
<p>Here is …</p><p>While there are ready made apps that backup and restore your SMSes, you can easily backup the database if you have a <strong>rooted</strong> phone without installing any external software.</p>
<p>The SMSes are stored in an SQLite database available under:</p>
<pre class="literal-block">
/dbdata/data/com.android.providers.telephony/databases/mmssms.db
</pre>
<p>Here is the procedure:</p>
<pre class="literal-block">
$ sudo ./adb start-server
$ ./adb pull /dbdata/data/com.android.providers.telephony/databases/mmssms.db ~/sms_backup.db
</pre>
<p>Simple!</p>
All work and no play...2011-04-17T10:53:25+00:002011-04-17T10:53:25+00:00Thejaswi Puthrayatag:thejaswi.info,2011-04-17:/personal/blog/2011/04/17/all-work-and-no-play/<p>As the sun gleamed through the news paper plastered window, he regained his senses but shifted his position and tried to get back to sleep. Ten minutes later, he was awake but struggling to get off the bed. He felt a lump in his throat, eyes burning and his back …</p><p>As the sun gleamed through the news paper plastered window, he regained his senses but shifted his position and tried to get back to sleep. Ten minutes later, he was awake but struggling to get off the bed. He felt a lump in his throat, eyes burning and his back was hurting. His thoughts were hazy and his brain sluggishly worked to recollect if he attended a party last night but realized that he was at work preparing an important report for his manager.</p>
<p>Blaming his current physical state to the long and boring work, he dragged himself to the wash basin. While comforting his reflection in the mirror, he brushed his teeth. He then laboured to pick up the newspaper from the doorstep and crashed on the couch after pushing off all the week's used laundry onto the floor. With his eyes watering, he gave up after glancing at the sports headlines and drifted back to sleep.</p>
<p>Forty minutes later, he woke up with a jolt and frantically started hunting for his mobile phone to check the time. He was twenty minutes past his usual routine and would have been on the road racing with hundreds of other office goers trying to reach office on time. He rushed to the kitchen and emptied a corn flakes carton and realized he forgot to pick up milk on Saturday, his weekly shopping day. Not having the stamina or the time to buy milk, he stuffed a couple of spoons of corn flakes before ravaging his wardrobe to select the day's attire. He chose a light blue full sleeve shirt and black trouser after smelling them to confirm they had been washed. This activity caused his back to hurt more and he assured himself that he would rest for a few minutes before starting off for work.</p>
<p>Close to noon, he woke up after his stomach started grumbling with hunger. He visualized his manager breathing fire and taking him to task for being late. Taking a few deep breaths, he rehearsed his apology and dialled his manager's number. Immediately after the pleasantries, he apologized, "Sir, I am sorry that I am late to office as I down with a mild flu. I will be in office by 2:30pm and work till late in the night to complete my work". There was a brief pause at the other end and this made his heart pound faster. All of a sudden, his manager burst out laughing and this rattled his nerves further. He mustered a little courage and stammered, "I am...extremely sorry sir. I will not repeat this mistake again". The manager while continuing to laugh exclaimed "You better be sorry kid! I don't want you to repeat this mistake. Don't even think of coming to work on a national holiday. Happy Gandhi Jayanthi! Take medicines and get good rest. I will see you in office when you are fully fit", and hung up. Embarrassed, he tapped his forehead and went back to sleep with a smile after apologizing to the Mahatma.</p>
Hackers and Painters2011-03-27T22:51:51+00:002011-03-27T22:51:51+00:00Thejaswi Puthrayatag:thejaswi.info,2011-03-27:/personal/blog/2011/03/27/hackers-and-painters/<p>When I picked up "Hackers and Painters", I didn't believe that I would be bored even for a moment but my premonition was wrong.</p>
<p><a class="reference external" href="http://en.wikipedia.org/wiki/Hackers_%26_Painters">"Hackers and Painters"</a> is a collection of 15 essays on startups and programming by <a class="reference external" href="http://en.wikipedia.org/wiki/Paul_Graham_%28computer_programmer%29">Paul Graham</a>, an eminent VC and the founder of Y Combinator.</p>
<p>"Why …</p><p>When I picked up "Hackers and Painters", I didn't believe that I would be bored even for a moment but my premonition was wrong.</p>
<p><a class="reference external" href="http://en.wikipedia.org/wiki/Hackers_%26_Painters">"Hackers and Painters"</a> is a collection of 15 essays on startups and programming by <a class="reference external" href="http://en.wikipedia.org/wiki/Paul_Graham_%28computer_programmer%29">Paul Graham</a>, an eminent VC and the founder of Y Combinator.</p>
<p>"Why nerds are unpopular?" is the first essay where PG (as Paul Graham is fondly called) discusses the reasons why students with good academics and better IQ are treated shabbily by the rest of the pack. He places most of the blame on adults while almost exonerating the education system. PG gives an example of teens in the Renaissance age, who were productively employed as apprentices. I failed to understand if he was encouraging child labour to quell teen problems?</p>
<p>"Hackers and Painters", after which the book is named draws an analogy between hackers and painters.</p>
<p>"What you can't say?" is a long boring essay on how trend setters are branded heretics for their outspokenness and open defiance.</p>
<p>"Good bad attitude" is the best essay where PG summarizes that attitude plays an huge role in a startup and hacker's career.</p>
<p>"The other road ahead" is an essay where PG exhorts his readers (mostly startup wannabes) that web apps are the best way forward. He points out various problems in desktop apps and I feel most of these problems have been addressed like cross platform libraries, one click installers etc. Whereas with regards to web apps, he doesn't address questions like privacy and data ownership.</p>
<p>"How to make wealth?" as PG points out is his most controversial essay. He defends the high pays of certain people like CEOs as they are highly skilled, guide a company and take risks and are answerable for the decisions. I am not sure if PG would defend the huge payouts to CEOs of banks who were partly responsible for the recent financial crisis. They took decisions to fire thousands of employees while paying themselves huge bonuses and bailing their companies out with tax payer's money. PG also states that creators of wealth are generally the richest. I differ with him on this point. For example, take the Indian farmer, he toils hard and his produce is not just his wealth but for thousands of consumers. But he still languishes, while the middlemen and speculators who hardly create any wealth make a killing. VCs and PE funds also hardly create any wealth but make quite a lot when a startup is acquired.</p>
<p>"Programming languages explained" is a high level overview of programming languages and a good read for non-technical people.</p>
<p>"The hundred year language" is a set of predictions on the direction of hardware and it's impact on programming languages.</p>
<p>"Taste for makers" is a long and repetitive essay on how taste like attitude decides the course of a startup.</p>
<p>"Beating averages" is an essay where PG informs his startup's decisions of choosing Lisp and how they outperformed their "average" competitors. He makes use of an Eric Raymond (ESR) quote to convince startups and hackers to use Lisp. While there is no doubt that Lisp is a powerful language, I personally believe that a startup should focus most of it's time on solving it's problem rather than hiring or learning a new language. It should be interesting how many of YC backed companies use Lisp.</p>
<p>PG encourages companies to come out with prototypes early in the "Research and Design" essay. This contradicts his earlier view where he advices them to take time to design. One point I liked in the essay was "Research doesn't have to be good but new and design doesn't have to be new but good".</p>
<p>As I mentioned earlier, I found the book disappointing because I picked it up with high expectations. Most of the essays are fairly long and explaining "one" point. Thankfully, the essays are not interdependent and so you can mix and match the order of reading.</p>
Catcher in the Rye2011-03-20T11:53:16+00:002011-03-20T11:53:16+00:00Thejaswi Puthrayatag:thejaswi.info,2011-03-20:/personal/blog/2011/03/20/catcher-in-the-rye/<p>"The Catcher in the Rye" is J.D Salinger's novel that depicts teen turmoil through the story of the protagonist, Holden Caulfield. Holden is a student of Pencey prep school and just like in his earlier schools has been kicked out for failing all his subjects.</p>
<p>The book starts off …</p><p>"The Catcher in the Rye" is J.D Salinger's novel that depicts teen turmoil through the story of the protagonist, Holden Caulfield. Holden is a student of Pencey prep school and just like in his earlier schools has been kicked out for failing all his subjects.</p>
<p>The book starts off at this point and Holden has a few days before the Christmas vacation begins and informing his parents of his expulsion. He decides to spend these days catching up with friends and acquaintances at New York rather than with his "superficial" friends at school or at home only to aggravate his ailing mother's condition. The rest of the story is about the lonely and confused teenager's misadventures in the city.</p>
<p>"The Catcher in the Rye" wonderfully portrays rebellion, depression and crude language, generally associated with teens. While reading the book, you feel that it was written by the author in his teens but you'll be surprised to know that Salinger wrote it at 32! What makes the book even more fascinating is that even after 60 years, it is still timeless and appeals to global readers.</p>
<p>While many who recommended the book claimed it was inspirational, I didn't find it so. I loved it for the writing style and the characterizations. The justification for the title is apparent only in the last chapter and the ending is subdued and left open for interpretations. This book is a must read even if you are not a teen and you will not regret reading it.</p>
Time to grow up2011-03-19T13:51:59+00:002011-03-19T13:51:59+00:00Thejaswi Puthrayatag:thejaswi.info,2011-03-19:/personal/blog/2011/03/19/time-to-grow-up/<p>This world is full of immature kids! Kids, who might have grown up physically and hold responsible positions in society but display immaturity by posting your private conversations with them on online public fora. Conversations that are harmless, with titbits of gossip and usually forgotten in a few moments.</p>
<p>These …</p><p>This world is full of immature kids! Kids, who might have grown up physically and hold responsible positions in society but display immaturity by posting your private conversations with them on online public fora. Conversations that are harmless, with titbits of gossip and usually forgotten in a few moments.</p>
<p>These kids seem to think they are 'Wikileaks' and get a kick out of doing this. Atleast, Wikileaks posts confidential conversations 'as is' with sensitive information hidden. They realize that posting the entire conversation would spoil the fun and they attempt summarizing hours long conversation under 140 characters. Some cool feat! Only, they get it wrong 'all' the time. They butcher the context and portray you in bad light.</p>
<p>Twitter and Facebook are weapons of mass destruction in their hands. They destroy your credibility among the masses on these fora through their childish actions.</p>
<p>Hey kids, it's totally my fault for having trusted you. I deserve to flog myself for this mistake. Not just in my eyes, you are degrading your image indulging in such immature acts.</p>
<p>GROW UP kids, it's time you really GROW UP!</p>
Defence with a difference2011-03-10T22:38:21+00:002011-03-10T22:38:21+00:00Thejaswi Puthrayatag:thejaswi.info,2011-03-10:/photo/blog/2011/03/10/defence-with-a-difference/<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/5375689830/"><img alt="Defence with a difference" class="align-center" src="http://farm6.static.flickr.com/5128/5375689830_374ff464dc_d.jpg" /></a>
My emacs setup2010-12-26T19:11:03+00:002010-12-26T19:11:03+00:00Thejaswi Puthrayatag:thejaswi.info,2010-12-26:/tech/blog/2010/12/26/my-emacs-setup/<p>Cross posted from <a class="reference external" href="http://agiliq.com/blog/2010/12/my-emacs-setup/">my work blog</a>...</p>
<p>My colleague <a class="reference external" href="https://github.com/tuxcanfly">Javed</a> had written a fantastic article a short while back on <a class="reference external" href="http://agiliq.com/blog/2010/11/seven-reasons-why-you-should-switch-to-vim-for-dja/">"Seven reasons why you should switch to Vim"</a> and as an <a class="reference external" href="http://en.wikipedia.org/wiki/emacs">emacs</a> user I thought I should share my setup too. One of the coolest things at <a class="reference external" href="http://agiliq.com/">Agiliq</a> is that we …</p><p>Cross posted from <a class="reference external" href="http://agiliq.com/blog/2010/12/my-emacs-setup/">my work blog</a>...</p>
<p>My colleague <a class="reference external" href="https://github.com/tuxcanfly">Javed</a> had written a fantastic article a short while back on <a class="reference external" href="http://agiliq.com/blog/2010/11/seven-reasons-why-you-should-switch-to-vim-for-dja/">"Seven reasons why you should switch to Vim"</a> and as an <a class="reference external" href="http://en.wikipedia.org/wiki/emacs">emacs</a> user I thought I should share my setup too. One of the coolest things at <a class="reference external" href="http://agiliq.com/">Agiliq</a> is that we are free to use the development tools of our choice. As a case to explain the point, everyone at agiliq uses a different editor and if someday a flame war would escalate to the third world war, I assure you it would start from Agiliq ;-)</p>
<p>Though I have been using <a class="reference external" href="http://en.wikipedia.org/wiki/emacs">emacs</a> for more than two years now, I still am an amateur. In this post, I am not going to exhort you to switch to emacs but explain my setup.</p>
<p>If you are planning to give emacs a try, I would suggest you start with the inbuilt emacs tutorial (C-h t). After you've gone through the tutorial, start using emacs while noting your most repetitive actions. Later, bind these repetitive actions to suitable shortcuts so that you can maximize your productivity and reduce keystrokes. Whenever in doubt, refer to <a class="reference external" href="http://emacswiki.org">emacswiki</a> for clarifications. Another wonderful reference would be <a class="reference external" href="http://duckduckgo.com/?q=steve+yegge+emacs">Steve Yegge's</a> articles on emacs.</p>
<p>Before I explain my setup, let me make it clear that most editors already have a lot of the functionality and I am not being judgemental in this post. If you've come here to see me bash other editors or proclaim that emacs is the best editor, you are going to be disappointed. Emacs has worked for me and a lot of other people and may work for you. Give a couple of editors out there in the market a try (atleast for a fortnight for each editor) and decide the one that you are most comfortable with.</p>
<p>I use emacs without a window system (emacs -nw) and have an alias entry in my .bashrc to load it in this mode by default.</p>
<p>Here are the contents on my .emacs.d/init.el file and I will explain them below line by line:</p>
<div class="highlight"><pre><span></span><span class="c1">;; .emacs</span>
<span class="c1">;; enable visual feedback on selections</span>
<span class="p">(</span><span class="nf">setq</span> <span class="nv">transient-mark-mode</span> <span class="nv">t</span><span class="p">)</span>
<span class="c1">;;; interfacing with ELPA, the package archive.</span>
<span class="c1">;;; Move this code earlier if you want to reference</span>
<span class="c1">;;; packages in your .emacs.</span>
<span class="p">(</span><span class="nf">when</span>
<span class="p">(</span><span class="nf">load</span>
<span class="p">(</span><span class="nf">expand-file-name</span> <span class="s">"~/.emacs.d/elpa/package.el"</span><span class="p">))</span>
<span class="p">(</span><span class="nf">package-initialize</span><span class="p">))</span>
<span class="c1">;; My customizations</span>
<span class="p">(</span><span class="nf">ido-mode</span> <span class="mi">1</span><span class="p">)</span>
<span class="p">(</span><span class="nf">icomplete-mode</span> <span class="mi">1</span><span class="p">)</span>
<span class="p">(</span><span class="nf">column-number-mode</span> <span class="mi">1</span><span class="p">)</span>
<span class="p">(</span><span class="nf">menu-bar-mode</span> <span class="mi">1</span><span class="p">)</span>
<span class="p">(</span><span class="nf">setq</span> <span class="nv">tags-file-name</span> <span class="s">"~/TAGS"</span><span class="p">)</span>
<span class="p">(</span><span class="nf">global-set-key</span> <span class="p">(</span><span class="nf">kbd</span> <span class="s">"<f5>"</span><span class="p">)</span> <span class="ss">'find-tag</span><span class="p">)</span>
<span class="p">(</span><span class="nf">global-set-key</span> <span class="p">(</span><span class="nf">kbd</span> <span class="s">"<f6>"</span><span class="p">)</span> <span class="ss">'rgrep</span><span class="p">)</span>
<span class="p">(</span><span class="nf">global-set-key</span> <span class="p">(</span><span class="nf">kbd</span> <span class="s">"<f7>"</span><span class="p">)</span> <span class="ss">'magit-status</span><span class="p">)</span>
<span class="p">(</span><span class="nf">setq</span> <span class="nv">yas/root-directory</span> <span class="s">"~/.emacs.d/snippets"</span><span class="p">)</span>
<span class="p">(</span><span class="nf">yas/load-directory</span> <span class="nv">yas/root-directory</span><span class="p">)</span>
<span class="p">(</span><span class="nb">load </span><span class="p">(</span><span class="nf">expand-file-name</span> <span class="s">"~/.emacs.d/multi-term.el"</span><span class="p">))</span>
</pre></div>
<p>The transient-mark-mode symbol when enabled gives feedback while marking regions (highlighting selected regions).</p>
<p>I use <a class="reference external" href="http://tromey.com/elpa/">ELPA</a> (Emacs Lisp Package Archive) for installing and managing my packages. Though currently, there are a few packages only in ELPA, they've been sufficient for me. There's another emacs package manager that I am looking forward to called <a class="reference external" href="https://github.com/emacsmirror/epkg">epkg</a> which will install packages from the <a class="reference external" href="https://github.com/emacsmirror">EmacsMirror</a>.</p>
<p>I have a few modes enabled by default like <a class="reference external" href="http://www.emacswiki.org/emacs/InteractivelyDoThings">ido-mode</a> (for intelligent auto completion in the minibuffer), <a class="reference external" href="http://www.emacswiki.org/emacs/IcompleteMode">icomplete-mode</a> (for helping me complete commands in the minibuffer without remembering the full names), column-number-mode (to display the column number at which the point is currently located, useful if you follow PEP-8 for python) and disable the menu-bar as I hardly use it. The menu-bar is a distraction especially when you are using emacs on a separate display in a maximized state.</p>
<p>I use <a class="reference external" href="http://www.emacswiki.org/emacs/EmacsTags">emacs tags</a> to jump between function calls and definitions very frequently and hence bound this invocation to the F5 key. One thing to note is that F5-F9 are generally unassigned and can be bound to your most frequently used actions.</p>
<p>I also search very often for files or content within files and use <a class="reference external" href="http://www.emacswiki.org/emacs/GrepMode">rgrep</a> and this has been bound to the F6 key.</p>
<p>I use git a lot and hence use <a class="reference external" href="http://www.emacswiki.org/emacs/Magit">magit</a>, a fantastic emacs mode to interact with <a class="reference external" href="http://git-scm.com">git</a>. This mode has been bound to the F7 key of the keyboard.</p>
<p>I am not a big fan of auto-complete but use some snippet based auto-completion using <a class="reference external" href="http://code.google.com/p/yasnippet/">yasnippets</a>. It's very easy to write your own snippets and I've written lots of them for django and some dom elements.</p>
<p>Whenever I start emacs, I also start a shell and <a class="reference external" href="http://www.emacswiki.org/emacs/download/multi-term.el">multi-term</a> is very useful in this regard. It handles unicode and ncurses based output very well. This is where I run the django development server or deploy using the fabric scripts.</p>
<p>Apart from these elisp packages, I run <a class="reference external" href="http://www.emacswiki.org/emacs/ERC">erc</a> (an IRC client written for emacs) occasionally to lurk on <a class="reference external" href="irc://irc.freenode.net/django">#django</a>. I manage my tasks using the <a class="reference external" href="http://orgmode.org/org.html">org-mode</a> and synchronize these tasks with my home workstation using the <a class="reference external" href="http://mobileorg.ncogni.to/">mobileorg</a> android app and <a class="reference external" href="http://www.dropbox.com">dropbox</a>.</p>
<p>As you would've observed my emacs setup is fairly minimal but suffices most of my django and python development. If you are an emacs user and have tips for me and other users, leave your comments. There's always a lot to learn in emacs :)</p>
Changing fonts for Platypus document templates in reportlab2010-11-30T16:26:54+00:002010-11-30T16:26:54+00:00Thejaswi Puthrayatag:thejaswi.info,2010-11-30:/tech/blog/2010/11/30/changing-fonts-for-platypus-document-templates-in-reportlab/<p>If you've wanted to generate PDF reports in python, you don't have choices. Most of the so called alternatives are also built on top of '<a class="reference external" href="http://www.reportlab.com/">reportlab</a>'.</p>
<p>I am not comfortable with reportlab (this is a post in itself) but because there's no viable alternative, I have stuck on. Reportlab has …</p><p>If you've wanted to generate PDF reports in python, you don't have choices. Most of the so called alternatives are also built on top of '<a class="reference external" href="http://www.reportlab.com/">reportlab</a>'.</p>
<p>I am not comfortable with reportlab (this is a post in itself) but because there's no viable alternative, I have stuck on. Reportlab has got a feature called 'Platypus' which lets the developer build a PDF document by arranging elements very similar to an HTML document.</p>
<p>For a side-project, I was looking at generating reports with Platypus. Things were fairly easy to setup but the PDF wouldn't display properly in windows because the Helvetica font replaced the diacritics with black boxes. The problem could not be reproduced on a linux based operating system.</p>
<p>The solution was to embed a font so that the PDF would render uniformly across all fonts. I selected the <a class="reference external" href="http://en.wikipedia.org/wiki/Linux_Libertine">LinLibertine</a> font because it was being used at Wikipedia and has a liberal license.</p>
<p>I struggled to embed the font even though it looked straight forward. I ran into lot of issues and took nearly a month to read the code and try to figure it out. Finally, I gave up and consulted the reportlab mailing list. I got very quick responses <a class="reference external" href="http://two.pairlist.net/pipermail/reportlab-users/2010-November/009870.html">[1]</a> and the problem was solved. At this point, I swore to blog about this scenario to be of assistance to some other frustrated soul.</p>
<p>Here's how to embed a custom font while using Platypus:</p>
<div class="highlight"><pre><span></span><span class="n">pdfmetrics</span><span class="o">.</span><span class="n">registerFont</span><span class="p">(</span><span class="n">TTFont</span><span class="p">(</span><span class="s1">'LinLibertine'</span><span class="p">,</span>
<span class="s2">"/path/to/font.ttf"</span><span class="p">)))</span>
<span class="n">doct</span> <span class="o">=</span> <span class="n">doctemplate</span><span class="o">.</span><span class="n">SimpleDocTemplate</span><span class="p">(</span><span class="s2">"/path/to/output.pdf"</span><span class="p">,</span>
<span class="n">pagesize</span><span class="o">=</span><span class="n">landscape</span><span class="p">(</span><span class="n">A4</span><span class="p">))</span>
<span class="n">style_sheet</span> <span class="o">=</span> <span class="n">getSampleStyleSheet</span><span class="p">()</span>
<span class="n">style_sheet</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">ParagraphStyle</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">'TestStyle'</span><span class="p">,</span>
<span class="n">fontName</span><span class="o">=</span><span class="s1">'LinLibertine'</span><span class="p">,</span>
<span class="n">fontSize</span><span class="o">=</span><span class="mi">12</span><span class="p">,</span>
<span class="n">leading</span><span class="o">=</span><span class="mi">12</span><span class="p">)</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">Paragraph</span><span class="p">(</span><span class="n">some_content</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="n">style_sheet</span><span class="p">[</span><span class="s2">"Title"</span><span class="p">]),</span>
<span class="n">Paragraph</span><span class="p">(</span><span class="n">story_content</span><span class="p">,</span>
<span class="n">style</span><span class="o">=</span><span class="n">style_sheet</span><span class="p">[</span><span class="s2">"TestStyle"</span><span class="p">])))</span>
<span class="n">style</span> <span class="o">=</span> <span class="n">GRID_STYLE</span>
<span class="n">style</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="s1">'VALIGN'</span><span class="p">,</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="s1">'MIDDLE'</span><span class="p">))</span>
<span class="n">style</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="s1">'LEFTPADDING'</span><span class="p">,</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="mi">15</span><span class="p">))</span>
<span class="n">style</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="s1">'RIGHTPADDING'</span><span class="p">,</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">),</span> <span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="mi">15</span><span class="p">))</span>
<span class="n">table</span> <span class="o">=</span> <span class="n">LongTable</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">colWidths</span><span class="o">=</span><span class="mi">360</span><span class="p">,</span> <span class="n">rowHeights</span><span class="o">=</span><span class="mi">215</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="n">style</span><span class="p">)</span>
<span class="n">page_flowables</span> <span class="o">=</span> <span class="p">[</span><span class="n">table</span><span class="p">]</span>
<span class="n">doct</span><span class="o">.</span><span class="n">_doSave</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">doct</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">page_flowables</span><span class="p">)</span>
<span class="n">canvas</span> <span class="o">=</span> <span class="n">doct</span><span class="o">.</span><span class="n">canv</span>
<span class="n">canvas</span><span class="o">.</span><span class="n">setTitle</span><span class="p">(</span><span class="s2">"Some title"</span><span class="p">)</span>
<span class="n">canvas</span><span class="o">.</span><span class="n">showPage</span><span class="p">()</span>
<span class="c1"># Use the raw data below to pass into a HTTP Response</span>
<span class="n">canvas</span><span class="o">.</span><span class="n">getpdfdata</span><span class="p">()</span>
</pre></div>
<p>The process is:</p>
<ul class="simple">
<li>Register a font through <cite>registerFont</cite></li>
<li>Create a style (here <cite>TestStyle</cite>)</li>
<li>Reference it in the Platypus flowables</li>
</ul>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Remember to use the <cite>doct._doSave</cite> line because it does not save the canvas while building it. Saving the canvas will prevent it from being modified later. If you forget the above mentioned line, there are possibilities of getting <cite>redefining named object</cite> error in reportlab.</p>
</div>
<p>Hopefully, this short post might be helpful. Thanks to Robin Becker and Henning von Bargen for assisting me in solving the issue. Remember when in doubt, try to solve it yourself and seek help if you aren't able to help yourself :)</p>
Medicinal Ubuntu2010-11-30T01:46:53+00:002010-11-30T01:46:53+00:00Thejaswi Puthrayatag:thejaswi.info,2010-11-30:/photo/blog/2010/11/30/medicinal-ubuntu/<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/5220677084/"><img alt="Ubuntu among a box of medicines" class="align-center" src="http://farm5.static.flickr.com/4154/5220677084_f370ab6124_d.jpg" /></a>
<p>Ubuntu can cure quite a few headaches and illnesses! Taken from Shabda's medicine basket.</p>
Summarize commits for the day2010-11-01T22:57:11+00:002010-11-01T22:57:11+00:00Thejaswi Puthrayatag:thejaswi.info,2010-11-01:/tech/blog/2010/11/01/summarize-commits-for-the-day/<p>Managers will always be managers! Despite having the coolest project management tool (PMT), (D)VCS and what not, they generally request you to send a daily status. You are surprised by this request, especially when an auto generated email is sent for 'every' commit you make, items struck off the …</p><p>Managers will always be managers! Despite having the coolest project management tool (PMT), (D)VCS and what not, they generally request you to send a daily status. You are surprised by this request, especially when an auto generated email is sent for 'every' commit you make, items struck off the todo list and clarifications sought on tickets.</p>
<p>I have been in this situation quite a few times before and usually feel their request is 'irrational' and 'redundant'. A manager is generally overwhelmed by the number of emails sent from a small yet active team. So their request is actually 'justified'. Why do so many PMTs (quite a few of them obscenely expensive) not generate and send a daily summary and alleviate the manager's (and also the team members') pain?</p>
<p>Here's a small one-liner bash script that I've used for generating a summary of the work I have done for the day. It builds a summary based on the git commit messages for the code pushed that day. The most important thing to remember is to <a class="reference external" href="http://lbrandy.com/blog/2009/03/writing-better-commit-messages/">write good commit messages</a> (not like <a class="reference external" href="http://whatthecommit.com/">these</a>) so that the summary is coherent.</p>
<div class="highlight"><pre><span></span>git log --date<span class="o">=</span>iso --author<span class="o">=</span><span class="s1">'<author_name>'</span> <span class="se">\</span>
--since<span class="o">=</span><span class="sb">`</span>date --date<span class="o">=</span><span class="s1">'today'</span> +%Y-%m-%d<span class="sb">`</span> <span class="se">\</span>
--until<span class="o">=</span><span class="sb">`</span>date --date<span class="o">=</span><span class="s1">'tomorrow'</span> +%Y-%m-%d<span class="sb">`</span> <span class="se">\</span>
--summary --show-notes --oneline --date-order
</pre></div>
<p>Reference it as an alias by adding to gitconfig.</p>
<div class="highlight"><pre><span></span><span class="c1"># In .git/config</span>
<span class="o">[</span>alias<span class="o">]</span>
<span class="nv">summarize</span> <span class="o">=</span> !git log --date<span class="o">=</span>iso --author<span class="o">=</span><span class="s1">'<author_name>'</span> <span class="se">\</span>
--since<span class="o">=</span><span class="sb">`</span>date --date<span class="o">=</span><span class="s1">'today'</span> +%Y-%m-%d<span class="sb">`</span> <span class="se">\</span>
--until<span class="o">=</span><span class="sb">`</span>date --date<span class="o">=</span><span class="s1">'tomorrow'</span> +%Y-%m-%d<span class="sb">`</span> <span class="se">\</span>
--summary --show-notes --oneline --date-order
</pre></div>
<div class="highlight"><pre><span></span>$ git summarize
5e5605c Homepage logo size has been reduced to align the divs correctly.
94ea527 Added the new community page. Requires layout changes and images.
c58411d First iteration of the new community page.
06ed1f1 Removed alert boxes and replaced with overlays.
a3115e8 The overlay works but other smaller issues to fix.
</pre></div>
<p>For mercurial users,</p>
<div class="highlight"><pre><span></span>hg log --user<span class="o">=</span><span class="s1">'<author_name>'</span> --date<span class="o">=</span><span class="s2">"`date --date='today' +%Y-%m-%d`"</span> --template <span class="s2">"{node|short}\t{desc}\n"</span>
</pre></div>
<p>I don't think it's possible to run shell commands in mercurial aliases, so you've to create a shell alias in either .bashrc or .bash_aliases</p>
<div class="highlight"><pre><span></span><span class="nb">alias</span> <span class="nv">summarize</span><span class="o">=</span><span class="s2">"hg log --user='<author_name>' --date=\"`date --date='today' +%Y-%m-%d`\" --template \"{node|short}\t{desc}\n\""</span>
$ summarize
2ca037d7d7e0 Merging the dev and stable branch
66faaf77da63 Added pyc* pattern to the .hgignore file
b1de7610277d Removed sitemedia images totally from being added to the repo
c6d6838a2ac2 Prevent the top.jpg from getting added to the repo by adding in .hgignore
473dcbab500d Removed a hardcoding in the web/views.py file
</pre></div>
Extending JQuery UI widgets2010-07-27T03:22:14+00:002010-07-27T03:22:14+00:00Thejaswi Puthrayatag:thejaswi.info,2010-07-27:/tech/blog/2010/07/27/extending-jquery-ui-widgets/<p><a class="reference external" href="http://jqueryui.com/">JQuery UI</a> is a useful project that provides theme-able widgets built on top of the <a class="reference external" href="http://www.jquery.com/">JQuery</a> project. It has an <a class="reference external" href="http://forum.jquery.com/">active community</a> and lots of <a class="reference external" href="http://plugins.jquery.com/">community contributed widgets</a> that do a lot of <a class="reference external" href="http://www.denbagus.net/jquery-ui-developers/">interesting</a> and sometimes <a class="reference external" href="http://plugins.jquery.com/project/lensflare">out of the world</a> stuff!</p>
<p>For a mini-project, I had to work on replicating …</p><p><a class="reference external" href="http://jqueryui.com/">JQuery UI</a> is a useful project that provides theme-able widgets built on top of the <a class="reference external" href="http://www.jquery.com/">JQuery</a> project. It has an <a class="reference external" href="http://forum.jquery.com/">active community</a> and lots of <a class="reference external" href="http://plugins.jquery.com/">community contributed widgets</a> that do a lot of <a class="reference external" href="http://www.denbagus.net/jquery-ui-developers/">interesting</a> and sometimes <a class="reference external" href="http://plugins.jquery.com/project/lensflare">out of the world</a> stuff!</p>
<p>For a mini-project, I had to work on replicating the <a class="reference external" href="http://www.gmail.com/">GMail</a> filter labels widget. I looked around if any were available and the closest I came to was the <a class="reference external" href="http://code.google.com/p/dropdown-check-list/">dropdownchecklist</a> project. Then I had to figure out how to extend this widget and in the process learned a lot of cool stuff that I would love to share on this post. These are two very good posts that you must read before you try to extend widgets:</p>
<blockquote>
<ul class="simple">
<li><a class="reference external" href="http://bililite.com/blog/understanding-jquery-ui-widgets-a-tutorial/">Understanding jQuery UI widgets: A tutorial</a></li>
<li><a class="reference external" href="http://bililite.com/blog/extending-jquery-ui-widgets/">Extending JQuery UI widgets</a></li>
</ul>
</blockquote>
<p>Here are some observations from my attempt at overriding the widget:</p>
<blockquote>
<ul class="simple">
<li>The <a class="reference external" href="http://www.jquery.com/">JQuery</a> <a class="reference external" href="http://api.jquery.com/jQuery.extend/">extend</a> method is the best way to extend the widgets.</li>
<li><a class="reference external" href="http://jqueryui.com/">JQuery UI</a> hides methods that start with an <cite>_</cite> (underscore) from being called by the instance.</li>
</ul>
</blockquote>
<p>So here are two snippets of extending the widget:</p>
<div class="section" id="method-1">
<h2>Method - 1</h2>
<div class="highlight"><pre><span></span><span class="nx">$</span><span class="p">.</span><span class="nx">ui</span><span class="p">.</span><span class="nx">widgetName</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">someMethod</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">someArgs</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Function body ...</span>
<span class="p">}</span>
</pre></div>
</div>
<div class="section" id="method-2-recommended">
<h2>Method - 2 (recommended)</h2>
<div class="highlight"><pre><span></span><span class="nx">$</span><span class="p">.</span><span class="nx">extend</span><span class="p">(</span><span class="nx">$</span><span class="p">.</span><span class="nx">ui</span><span class="p">.</span><span class="nx">widgetName</span><span class="p">.</span><span class="nx">prototype</span><span class="p">,</span> <span class="p">{</span><span class="nx">newMethod</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">someArgs</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// Function body ...</span>
<span class="p">}</span>
<span class="p">});</span>
</pre></div>
</div>
My new phone : Samsung i75002010-05-16T08:27:34+00:002010-05-16T08:27:34+00:00Thejaswi Puthrayatag:thejaswi.info,2010-05-16:/photo/blog/2010/05/16/my-new-phone-samsung-i7500/<p>Just bought a <a class="reference external" href="http://www.gsmarena.com/samsung_i7500_galaxy-2791.php">Samsung i7500 Galaxy Phone</a>. It's <a class="reference external" href="http://www.android.com/">Android</a> powered.</p>
<p>A few pics below...</p>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4610573035/"><img alt="Samsung i7500 Front View" class="align-center" src="http://farm2.static.flickr.com/1401/4610573035_a12d08fbc4_d.jpg" /></a>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4611182790/"><img alt="Samsung i7500 Side View" class="align-center" src="http://farm2.static.flickr.com/1253/4611182790_da3148c0e2_d.jpg" /></a>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4611183458/"><img alt="Samsung i7500 Rear View" class="align-center" src="http://farm5.static.flickr.com/4001/4611183458_58238d75a2_d.jpg" /></a>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4610574855/"><img alt="Samsung i7500 Homepage view" class="align-center" src="http://farm4.static.flickr.com/3375/4610574855_ae54005acf_d.jpg" /></a>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4610575203/"><img alt="Samsung i7500 Icon Grid" class="align-center" src="http://farm2.static.flickr.com/1276/4610575203_b81d97c84a_d.jpg" /></a>
Recaptcha Fail2010-05-13T10:43:44+00:002010-05-13T10:43:44+00:00Thejaswi Puthrayatag:thejaswi.info,2010-05-13:/photo/blog/2010/05/13/recaptcha-fail/<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4602713741/"><img alt="Recpatcha Fail" class="align-center" src="http://farm2.static.flickr.com/1361/4602713741_572070d7a3_d.jpg" /></a>
<p>I know it's fairly easy to reload the <a class="reference external" href="http://recaptcha.net/">recaptcha</a> and the second word is not the 'challenge' word and will get accepted no matter what I enter. But this is the heights of <strong>"Are you a human or a bot?"</strong>.</p>
Use the Windows key as Ctrl Key on Linux2010-05-11T21:44:59+00:002010-05-11T21:44:59+00:00Thejaswi Puthrayatag:thejaswi.info,2010-05-11:/tech/blog/2010/05/11/use-the-windows-key-as-ctrl-key-on-linux/<p>The Ctrl key on the Samsung R517 laptop is placed awkwardly for comfortable use with <a class="reference external" href="http://www.gnu.org/software/emacs/">Emacs</a>. Off late due to the strain of hitting the Ctrl key often, I started to feel a mild tingling on my <a class="reference external" href="http://en.wikipedia.org/wiki/Little_finger">pinky</a>. I was anxious if this was the first stage of the infamous …</p><p>The Ctrl key on the Samsung R517 laptop is placed awkwardly for comfortable use with <a class="reference external" href="http://www.gnu.org/software/emacs/">Emacs</a>. Off late due to the strain of hitting the Ctrl key often, I started to feel a mild tingling on my <a class="reference external" href="http://en.wikipedia.org/wiki/Little_finger">pinky</a>. I was anxious if this was the first stage of the infamous <a class="reference external" href="http://en.wikipedia.org/wiki/Emacs#Emacs_Pinky">Emacs pinky</a>. So I started looking for ways of reducing the pain and I came across a beautiful article by <a class="reference external" href="http://steve-yegge.blogspot.com/">Steve Yegge</a> on <a class="reference external" href="http://sites.google.com/site/steveyegge2/effective-emacs">Effective Emacs</a>. If you wish to become a power <a class="reference external" href="http://www.gnu.org/software/emacs/">Emacs</a> user, then you ought to read it. This article came as a real blessing in disguise and I hope my post might be useful to some other soul.</p>
<p>The article actually recommends swapping the Caps Lock and the Ctrl key. But as a fairly frequent user of the Caps Lock key, I did not like the idea and hence decided to swap it with the 'vestigial' Windows key. This is fairly simple process on Linux. Here's how I went about it...</p>
<ol class="arabic simple">
<li>Figure out the key code of the windows key. Linux comes with an X utility called 'xev'. After firing that utility, I pressed the windows key several times and noted down the key symbol and key code. In my case, they were "Super_L" and "133".</li>
</ol>
<blockquote>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4600821396/"><img alt="Keycode identification using xev" class="align-center" src="http://farm2.static.flickr.com/1414/4600821396_298c4dec1a_d.jpg" /></a>
</blockquote>
<ol class="arabic simple" start="2">
<li>Map the key using 'xmodmap'.</li>
</ol>
<blockquote>
<div class="highlight"><pre><span></span>keysym <span class="nv">Control_L</span> <span class="o">=</span> Super_L
keycode <span class="nv">37</span> <span class="o">=</span> Control_L
remove <span class="nv">mod4</span> <span class="o">=</span> Super_L
add <span class="nv">Control</span> <span class="o">=</span> Control_L Control_R Super_L
</pre></div>
<p>What the code above does is that it first assigns the left control to the windows key and deassigns the left control. But we want an additional control key instead of deassigning it. So we take the key code of the left control as mentioned in Step 1 and reassign it to the Control_L key symbol. We then, remove the Windows key from the modifier group called 'mod4'. The 8 modifier groups are <strong>Shift</strong>, <strong>Lock</strong>, <strong>Control</strong>, <strong>Mod1</strong>, <strong>Mod2</strong>, <strong>Mod3</strong>, <strong>Mod4</strong> and <strong>Mod5</strong>. These modifier groups hold a collection of keys for a specific action. For example, by default the Caps Lock is part of the <strong>Lock</strong> modifier. Suppose, you add another key to this group, you can make it function like a Caps Lock. This is the basis for the last line, where I wish to use the Left Control, Right Control and Windows key as control keys.</p>
</blockquote>
<ol class="arabic simple" start="3">
<li>Add the above xmodmap file to your bashrc (or bashrc_profile depending on your distro)</li>
</ol>
<blockquote>
<div class="highlight"><pre><span></span><span class="nb">source</span> path/to/the/above/xmodmap/file
</pre></div>
</blockquote>
<p>May the power of <a class="reference external" href="http://www.gnu.org/software/emacs/">Emacs</a> be with you!</p>
Which century do we live in?2010-03-29T18:44:53+00:002010-03-29T18:44:53+00:00Thejaswi Puthrayatag:thejaswi.info,2010-03-29:/photo/blog/2010/03/29/which-century-do-we-live-in/<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4475044470/"><img alt="Bank of India, use Internet Explorer" class="align-center" src="http://farm5.static.flickr.com/4006/4475044470_c799441ce7_d.jpg" /></a>
<a class="reference external image-reference" href="hhttp://www.flickr.com/photos/puthraya/4474268701/"><img alt="Bank of India, use Internet Explorer" class="align-center" src="http://farm5.static.flickr.com/4041/4474268701_e95ddc7bf8_o_d.png" /></a>
<p>One of those things that makes me go beyond yelling <a class="reference external" href="http://en.wikipedia.org/wiki/WTF">WTF</a>!</p>
Released django-check-constraints2010-03-15T23:41:46+00:002010-03-15T23:41:46+00:00Thejaswi Puthrayatag:thejaswi.info,2010-03-15:/tech/blog/2010/03/15/released-django-check-constraints/<p>Ever since <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/models/instances/#validating-objects">model validation</a> hit the <a class="reference external" href="http://www.djangoproject.com/">django</a> trunk, I had been having thoughts of reviving my <a class="reference external" href="http://code.google.com/soc/2007/django/appinfo.html?csaid=63426CED5B1E571B">Google Summer of Code 2007</a> project. So nearly a couple of weeks back, I started resurrecting django-check-constraints. Today, I released the code into wild <a class="reference external" href="http://github.com/theju/django-check-constraints/">here</a>.</p>
<p>The feature of the project is that it not …</p><p>Ever since <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/models/instances/#validating-objects">model validation</a> hit the <a class="reference external" href="http://www.djangoproject.com/">django</a> trunk, I had been having thoughts of reviving my <a class="reference external" href="http://code.google.com/soc/2007/django/appinfo.html?csaid=63426CED5B1E571B">Google Summer of Code 2007</a> project. So nearly a couple of weeks back, I started resurrecting django-check-constraints. Today, I released the code into wild <a class="reference external" href="http://github.com/theju/django-check-constraints/">here</a>.</p>
<p>The feature of the project is that it not only generates the required SQL statements for creating the constraints during syncdb but also adds validators to the model fields so that any errors can be gracefully handled exactly like normal model validation. All this without having to write extra validation in the form or model!</p>
<p>The usage is fairly simple.</p>
<blockquote>
<ul class="simple">
<li>Define the constraints in the inner Meta class of the model</li>
<li>Override the model's metaclass with the CheckConstraintMetaClass provided.</li>
</ul>
</blockquote>
<p>Here are some screenshots (they say a picture is worth a thousand words):</p>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4438098334/"><img alt="Model definition for django-check-constraints" class="align-center" src="http://farm5.static.flickr.com/4010/4438098334_5fd698f0c0_o_d.png" /></a>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4437322303/"><img alt="SQL generated for the model" class="align-center" src="http://farm5.static.flickr.com/4017/4437322303_f08fbc0096_d.jpg" /></a>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4437322237/"><img alt="Validators at work using django-check-constraints" class="align-center" src="http://farm5.static.flickr.com/4039/4437322237_18b986a969_d.jpg" /></a>
Jeffrey Archer's Cat O' Nine Tales2010-01-26T04:24:09+00:002010-01-26T04:24:09+00:00Thejaswi Puthrayatag:thejaswi.info,2010-01-26:/personal/blog/2010/01/26/jeffrey-archers-cat-o-nine-tales/<p><a class="reference external" href="http://en.wikipedia.org/wiki/Cat_O%27Nine_Tales">Cat O' Nine Tales</a> was my first <a class="reference external" href="http://en.wikipedia.org/wiki/Jeffrey_Archer">Jeffrey Archer</a> book. I picked it up with great hesitation because I hadn't read any of his previous books and a friend warned me that his books required lot of patience to finish.Luckily, <a class="reference external" href="http://en.wikipedia.org/wiki/Cat_O%27Nine_Tales">Cat O' Nine Tales</a> was Jeffrey Archer's fifth instalment …</p><p><a class="reference external" href="http://en.wikipedia.org/wiki/Cat_O%27Nine_Tales">Cat O' Nine Tales</a> was my first <a class="reference external" href="http://en.wikipedia.org/wiki/Jeffrey_Archer">Jeffrey Archer</a> book. I picked it up with great hesitation because I hadn't read any of his previous books and a friend warned me that his books required lot of patience to finish.Luckily, <a class="reference external" href="http://en.wikipedia.org/wiki/Cat_O%27Nine_Tales">Cat O' Nine Tales</a> was Jeffrey Archer's fifth instalment of short stories and so my friend's warning went unheeded.</p>
<p>The book has 12 stories of which 9 (and hence the name) are based on true incidents with embellishment. These stories were written while Jeffrey Archer was serving a sentence at Her Majesty's prisons. Most stories involve convicts or criminals and their run in with the law eventually.</p>
<p><strong>"Maestro"</strong> is the story of an Italian restaurateur who almost ends up behind bars after evading tax for years. <strong>"Do not disturb"</strong> is the tale of an English business man who plans to murder his wife in Russia to save himself from a messy divorce. In yet another tale of deceit, <strong>"Red King"</strong>, a conman fools an English Lord into believing that he possesses a missing chess piece to a set that could fetch a fortune. <strong>"Charity begins at home"</strong> is the story of a retired accountant who plans to make up for lost time by trying to make a fortune from charity fund raisers. <strong>"The Commissioner"</strong> is the tale of a witty commissioner with the Bombay police who sends a petty criminal to a morgue after the latter tries to use the top cop's office to scam people.</p>
<p>The book spans 255 pages, costs Rs.270 and is <strong>simply fabulous</strong>. Period!</p>
How cricket can save other sports2010-01-17T04:27:23+00:002010-01-17T04:27:23+00:00Thejaswi Puthrayatag:thejaswi.info,2010-01-17:/personal/blog/2010/01/17/how-cricket-can-save-other-sports/<p>The <a class="reference external" href="http://beta.thehindu.com/opinion/editorial/article79687.ece">recent impasse</a> between the Indian <a class="reference external" href="http://en.wikipedia.org/wiki/Hockey">hockey</a> players and the federation that finally caught the attention of the nation, might have been <a class="reference external" href="http://beta.thehindu.com/sport/hockey/article80037.ece">resolved</a> till the hockey world cup next month. During this impasse, the media highlighted some disturbing questions like <em>"Why other sports are meted step-motherly treatment?"</em> and <em>"Why is …</em></p><p>The <a class="reference external" href="http://beta.thehindu.com/opinion/editorial/article79687.ece">recent impasse</a> between the Indian <a class="reference external" href="http://en.wikipedia.org/wiki/Hockey">hockey</a> players and the federation that finally caught the attention of the nation, might have been <a class="reference external" href="http://beta.thehindu.com/sport/hockey/article80037.ece">resolved</a> till the hockey world cup next month. During this impasse, the media highlighted some disturbing questions like <em>"Why other sports are meted step-motherly treatment?"</em> and <em>"Why is cricket so popular in India?"</em>.</p>
<p>The latter question is very disturbing because we are a country of more than a billion and have varied interests but when it comes to <a class="reference external" href="http://en.wikipedia.org/wiki/Cricket">cricket</a> our obsession is unanimous. Certain disturbing trends like <a class="reference external" href="http://en.wikipedia.org/wiki/P._T._Usha">PT Usha</a> (our golden girl) <a class="reference external" href="http://beta.thehindu.com/sport/athletics/article29783.ece">breaking down</a> on seeing the dismal accommodation provided to her by a state government, <a class="reference external" href="http://en.wikipedia.org/wiki/Dhanraj_Pillay">Dhanraj Pillay</a> (a hockey legend) breaking down during a <a class="reference external" href="http://www.rediff.com/sports/2000/jul/27dhan.htm">TV interview</a> when asked if he would encourage his son to take up the sport or the emerging extravagance of cricket do not seem to even make a difference. Cricket players are <a class="reference external" href="http://beta.thehindu.com/sport/cricket/article15915.ece">earning</a> crores of rupees for a handful IPL matches while some sports players live off paltry wages (as less as Rs.200/- a day) to make both ends meet, sometimes selling their trophies and medals off.</p>
<p>This post is my take on why cricket is popular and more importantly, how it can save our sports.</p>
<p>Cricket in India is promoted and commercialized by a private monopolistic company called the <a class="reference external" href="http://en.wikipedia.org/wiki/Board_of_Control_for_Cricket_in_India">BCCI</a>. Most key people in this organization are businessmen or politicians linking their commercial interests with the sport.</p>
<p>On the other hand, other sports are promoted by the respective state sports federation which comes under the national sports federation. The government babus administer these organizations and most have never played any sport in their life, cannot even relate to it but control the lives of hundreds of hard working sportsmen. Since the government at the helm it controls the administration, the budget and how it is used. No politician ever cares to even question the policies of the federations because there is no economic incentive for them here. These sports federations don't even have the means to look after the welfare of our sportsmen leave alone identify, hone and retain talent. There are no incentives for performers, not even appreciation from the head of the federation. No money or appreciation...but we expect medals!</p>
<p>So how can cricket save other sports?</p>
<p>I believe that by replicating the BCCI model, the other sports too can benefit. First, the government can start by kicking out these babus and replacing them with former sports persons. Pay them a decent salary to keep out corruption and give them the autonomy to take decisions because they are aware of the problems. Conduct regular elections to elect the governing body for a term of 4 years (because most major tournaments like the <a class="reference external" href="http://en.wikipedia.org/wiki/Olympics">Olympics</a> are conducted every 4 years). The government can raise money for the federation by levying a tax on <strong>every</strong> cricket related transaction (like from sale of cricket gear, tickets, player earnings, sponsorships etc). Even if the tax is as low as 0.5% the federation can easily raise upto 50 crores. Apart from this, donations should be made tax exemptible so that corporates can support the cause. With so much money available, independent auditors must be appointed to overlook the accounts. The performance of the federation and sports persons should be reviewed by external consultants.</p>
<p>The federation should make use of the money to promote sports in schools, building hostels, training and covering the costs of sports persons.</p>
<p>Hopefully through these changes, India might be able to improve it's medal tally at the <a class="reference external" href="http://en.wikipedia.org/wiki/2016_Summer_Olympics">2016 olympics</a>. All this without sacrificing our love for the pseudo-national sport. The more cricket flourishes, so will the other sports!</p>
5 funny myths on losing weight2010-01-12T21:48:33+00:002010-01-12T21:48:33+00:00Thejaswi Puthrayatag:thejaswi.info,2010-01-12:/personal/blog/2010/01/12/5-funny-myths-on-losing-weight/<p>With the new year day past us, lots of us would have made resolutions. It's another matter that most of the resolutions would have already been forgotten by now. A couple of friends resolved to lose weight and regain their shape.</p>
<p>In <a class="reference external" href="http://en.wikipedia.org/wiki/India">India</a>, where every <a class="reference external" href="http://en.wikipedia.org/wiki/Tom,_Dick_and_Harry">Tom, Dick and Harry</a> gives …</p><p>With the new year day past us, lots of us would have made resolutions. It's another matter that most of the resolutions would have already been forgotten by now. A couple of friends resolved to lose weight and regain their shape.</p>
<p>In <a class="reference external" href="http://en.wikipedia.org/wiki/India">India</a>, where every <a class="reference external" href="http://en.wikipedia.org/wiki/Tom,_Dick_and_Harry">Tom, Dick and Harry</a> gives free advice, <a class="reference external" href="http://en.wikipedia.org/wiki/Obesity">obese</a> people need to be discerning. They shoudl ascertain facts and not act desperately. With due regards to obese people, most of them fall prey to pedestrian advice and eventually become a laughing stock.</p>
<p>Here is a list of such funny advice that I have overheard in ascending order of comedy:</p>
<ul>
<li><p class="first"><strong>Dieting</strong>:</p>
<p><em>"Don't consume carbohydrates"</em></p>
<p><em>"Don't eat greasy food"</em></p>
<p>Heard these before? <a class="reference external" href="http://en.wikipedia.org/wiki/Dieting">Dieting</a> is by far the most common advice given and most people actually fall for this. Off late, some people are taking this very seriously that it is losing it's comic value.</p>
<p>It is a scientifically proven fact that our body needs all nutrients in optimum quantities and depriving the body of these is only going to harm it further.</p>
</li>
<li><p class="first"><strong>Regulate your breath</strong>:</p>
<p><em>"Control your breathing and you can lose weight"</em></p>
<p>If this were true, you don't even have to watch what you eat!</p>
</li>
<li><p class="first"><strong>काट को काट स निकाला जाता ह</strong>:</p>
<p>In English, <strong>a thorn is to be removed with a thorn</strong>. I heard some chap giving this advice to his brother in a train. He was suggesting his brother to eat so much junk food that his body's <a class="reference external" href="http://en.wikipedia.org/wiki/Metabolism">metabolism</a> reverses and he starts losing weight. Outright stupid and suicidal! Don't even attempt this in your dream!</p>
</li>
<li><p class="first"><strong>Kareena did it, so can I!</strong>:</p>
<p><a class="reference external" href="http://en.wikipedia.org/wiki/Kareena_Kapoor">Kareena Kapoor</a> became (in)famous after her <a class="reference external" href="http://en.wikipedia.org/wiki/Size_zero">size-zero</a> look was unveiled but it is foolishness if you believe that you too can lose weight the same way. Every human body is different and no weight loss method is sure shot or foolproof.</p>
</li>
<li><p class="first"><strong>Paying for your sins</strong>:</p>
<p><em>"Your obesity is a punishment for your previous life's sins. Do good deeds and you'll lose weight."</em></p>
<p>This one's got to be the funniest! I overheard my friend's grandmother share this advice and I burst out laughing on her face! Going by this, all slim people were probably priests in their previous life. If you really want people to do good, then think of a better story.</p>
</li>
</ul>
<p>Come on folks! How gullible can you be? Such stupid advice should never be attempted but laughed at. Did you or your friends get any such advice? If yes, please do share them with us and spread the cheer!</p>
R.K Narayan's "A Tiger for Malgudi"2010-01-02T10:57:02+00:002010-01-02T10:57:02+00:00Thejaswi Puthrayatag:thejaswi.info,2010-01-02:/personal/blog/2010/01/02/rk-narayans-a-tiger-for-malgudi/<p><a class="reference external" href="http://en.wikipedia.org/wiki/R._K._Narayan">R.K. Narayan</a> happens to be my favourite author because most of his stories are timeless and make for a light reading at the end of a heavy work day. He is undoubtedly the widest read author in India, right from high school kids to retired grandparents. Clearly, this reflects …</p><p><a class="reference external" href="http://en.wikipedia.org/wiki/R._K._Narayan">R.K. Narayan</a> happens to be my favourite author because most of his stories are timeless and make for a light reading at the end of a heavy work day. He is undoubtedly the widest read author in India, right from high school kids to retired grandparents. Clearly, this reflects the versatility and greatness of the man who is able to satisfy such a wide age parity.</p>
<p>As, I was browsing through books at my <a class="reference external" href="http://www.openstreetmap.org/?lat=17.44114&lon=78.48779&zoom=17&layers=B000FTF">favourite book store</a>, my eyes were stuck on a red coloured book decorated with floral motifs and a tiger and a sage on the cover. I almost replaced the book on the stand when my eyes caught a glimpse of <a class="reference external" href="http://en.wikipedia.org/wiki/R._K._Narayan">R.K. Narayan</a>'s name. Without any hesitation, I purchased "<a class="reference external" href="http://en.wikipedia.org/wiki/A_Tiger_for_Malgudi">A Tiger for Malgudi</a>" written by <a class="reference external" href="http://en.wikipedia.org/wiki/R._K._Narayan">R.K. Narayan</a> in 1983 and published by <a class="reference external" href="http://en.wikipedia.org/wiki/Indian_Thought_Publications">Indian Thought Publications</a>.</p>
<p>This book review might be slightly biased (difficult to dispassionate when you are reviewing your favourite author) but you have nothing to lose reading a book that spans less than 200 pages and costs just Rs. 95/- and is written by one of the greatest authors of <a class="reference external" href="http://en.wikipedia.org/wiki/India">India</a>.</p>
<p>"A Tiger for Malgudi" is the story of the life of a tiger. The tiger is the narrator and protagonist of the story, probably one of the very few stories where an animal is the narrator.</p>
<p>The story begins with an old and dying tiger recollecting it's carefree cub days with it's mother and siblings. As it grew into a ferocious tiger, it moved and hunted independently. As it started ageing, it came across a human habitation in a forest and made easy pickings of the livestock. Tired of losing their livelihood to the tiger, the villagers contact a circus ringmaster to trap the tiger. The ringmaster vows to make the tiger a star attraction in his circus and begins inflicting torture on the poor creature. The feline breaks under the pressure and kills the trainer in a freak accident and walks out unchallenged into <a class="reference external" href="http://en.wikipedia.org/wiki/Malgudi">Malgudi</a> where the circus is camping. The sight of a tiger strolling through the town causes a lot of commotion in the town and this is depicted comically through the eyes of the tiger. Finally, a wise sage comes to the rescue of the town and controls the tiger through his mystical powers. The animal is captivated by his new master's sparkling eyes and follows him devoutly to the hills. Here the master enlightens the tiger and brings about a change of heart in the tiger. The tiger spends the rest of it's life loyal to it's master in penance.</p>
<p>R.K. Narayan intricately draws parallels to the stages of life of a man and tiger and beautifully depicts our life through the eyes of a tiger. Nothing very fancy but a simple story with comical elements and a vivid description of human life and emotions through the eyes of an animal. On the whole, a great book for a weekday reading and a treasurable gift.</p>
Use the power of git to develop with both git and svn2009-12-27T11:45:50+00:002009-12-27T11:45:50+00:00Thejaswi Puthrayatag:thejaswi.info,2009-12-27:/tech/blog/2009/12/27/use-the-power-of-git-to-develop-with-both-git-and-svn/<p><a class="reference external" href="http://theju.in/">I</a> was one of the thousands who jumped on to <a class="reference external" href="http://code.google.com/hosting/">Google Code</a> when
it was released sighing a relief that <a class="reference external" href="http://www.sourceforge.net/">Sourceforge</a> was no more a
<a class="reference external" href="http://en.wikipedia.org/wiki/Hobson%27s_choice">Hobson's choice</a>.</p>
<p>But very soon <a class="reference external" href="http://github.com/">github</a> was released and showcased <a class="reference external" href="http://git-scm.org/">git</a>'s amazing
power. Again like the thousands, I too switched but this time I …</p><p><a class="reference external" href="http://theju.in/">I</a> was one of the thousands who jumped on to <a class="reference external" href="http://code.google.com/hosting/">Google Code</a> when
it was released sighing a relief that <a class="reference external" href="http://www.sourceforge.net/">Sourceforge</a> was no more a
<a class="reference external" href="http://en.wikipedia.org/wiki/Hobson%27s_choice">Hobson's choice</a>.</p>
<p>But very soon <a class="reference external" href="http://github.com/">github</a> was released and showcased <a class="reference external" href="http://git-scm.org/">git</a>'s amazing
power. Again like the thousands, I too switched but this time I really
wanted to mirror the <a class="reference external" href="http://github.com/">github</a> changes to <a class="reference external" href="http://code.google.com/hosting/">Google Code</a> rather than
orphan the repo. This would ensure that I could utilize the power of
<a class="reference external" href="http://git-scm.org/">git</a> (mainly local branches for development).</p>
<p>So here is a step by step procedure of how to go about it (mainly as
an archival purpose after having struggled for more than two hours).
You need to have <a class="reference external" href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git-svn</a> installed to be able to fetch the changes
from google code for the initial code:</p>
<div class="highlight"><pre><span></span><span class="c1"># Clone the google code svn repo first</span>
$ git svn clone https://<google_code_project_url>/trunk checkout_name --username<span class="o">=</span><google_username>
$ <span class="nb">cd</span> checkout_name
<span class="c1"># Add a remote to github and fetch</span>
$ git remote add -f -m master git_origin git@github.com:<username>/<git_project.git>
<span class="c1"># Track the 'master' remote branch on github</span>
$ git branch -t github remotes/git_origin/master
// Make the changes in the master repo <span class="o">(</span>say<span class="o">)</span>
<span class="c1"># Commit from the local 'master' branch to google code</span>
$ git svn dcommit
<span class="c1"># Move to the local 'github' branch</span>
$ git checkout github
<span class="c1"># Merge the changes from master into github</span>
$ git merge master
<span class="c1"># Push the changes to github</span>
$ git push
</pre></div>
<p>Not very difficult but slightly cumbersome to repeat! <a class="reference external" href="http://code.google.com/hosting/">Google Code</a> offers <a class="reference external" href="http://mercurial.selenic.com/">mercurial</a>
support but I have not had an opportunity to work it.</p>
Riding on popularity2009-12-15T16:08:14+00:002009-12-15T16:08:14+00:00Thejaswi Puthrayatag:thejaswi.info,2009-12-15:/photo/blog/2009/12/15/riding-on-popularity/<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4189706572/"><img alt="A spurious Nokia charger" class="align-center" src="http://farm3.static.flickr.com/2493/4189706572_7507f78a3b_d.jpg" /></a>
<p>A Nokia phone charger that rides on a <a class="reference external" href="http://en.wikipedia.org/wiki/Unix">popular name</a>! (<a class="reference external" href="http://en.wikipedia.org/wiki/SCO_Group">SCO</a> should check this out) Another interesting fact is that this charger costs 1/3rd that of the original and is as good ala lower <a class="reference external" href="http://en.wikipedia.org/wiki/Total_cost_of_ownership">TCO</a> using <a class="reference external" href="http://en.wikipedia.org/wiki/Free_software">Free Software</a> (some might call it a rotten analogy but my <cite>creative</cite> :-P …</p><a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4189706572/"><img alt="A spurious Nokia charger" class="align-center" src="http://farm3.static.flickr.com/2493/4189706572_7507f78a3b_d.jpg" /></a>
<p>A Nokia phone charger that rides on a <a class="reference external" href="http://en.wikipedia.org/wiki/Unix">popular name</a>! (<a class="reference external" href="http://en.wikipedia.org/wiki/SCO_Group">SCO</a> should check this out) Another interesting fact is that this charger costs 1/3rd that of the original and is as good ala lower <a class="reference external" href="http://en.wikipedia.org/wiki/Total_cost_of_ownership">TCO</a> using <a class="reference external" href="http://en.wikipedia.org/wiki/Free_software">Free Software</a> (some might call it a rotten analogy but my <cite>creative</cite> :-P mind couldn't stop drawing parallels).</p>
Some humourous shop salesman!2009-12-15T15:56:44+00:002009-12-15T15:56:44+00:00Thejaswi Puthrayatag:thejaswi.info,2009-12-15:/photo/blog/2009/12/15/some-humourous-shop-salesman/<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4173142516/"><img alt="Bargaining conditions" class="align-center" src="http://farm3.static.flickr.com/2723/4173142516_75d2ceb60d_d.jpg" /></a>
<p>Seen at a shop (selling agro products) outside the Tribal Museum at <a class="reference external" href="http://en.wikipedia.org/wiki/Araku_Valley">Araku</a>, <a class="reference external" href="http://en.wikipedia.org/wiki/Visakhapatnam">Visakhapatnam</a>.</p>
Confista: A conference management app2009-11-24T14:06:14+00:002009-11-24T14:06:14+00:00Thejaswi Puthrayatag:thejaswi.info,2009-11-24:/tech/blog/2009/11/24/confista-a-conference-management-app/<p>I can't believe I had been living under a rock all this while!
How could I have missed <a class="reference external" href="http://www.pinaxproject.com/">Pinax</a>? I knew it existed but was under
a wrong impression that it was only for the <tt class="docutils literal">social</tt> stuff.</p>
<p>Recently, I forced myself to look at <a class="reference external" href="http://www.pinaxproject.com/">Pinax</a> for a project and
after …</p><p>I can't believe I had been living under a rock all this while!
How could I have missed <a class="reference external" href="http://www.pinaxproject.com/">Pinax</a>? I knew it existed but was under
a wrong impression that it was only for the <tt class="docutils literal">social</tt> stuff.</p>
<p>Recently, I forced myself to look at <a class="reference external" href="http://www.pinaxproject.com/">Pinax</a> for a project and
after evaluating it, I must admit that I was blown off my feet.
It is really awesome! If <a class="reference external" href="http://www.djangoproject.com/">django</a> is a "web framework for
perfectionists with deadlines" then <a class="reference external" href="http://www.pinaxproject.com/">Pinax</a> is "the fastest way
to develop awesome django apps without repeating and embarassing
yourself".</p>
<p>Coming to the point of this post, I have managed to port the
<a class="reference external" href="http://bitbucket.org/lawgon/fossconf/">fossconf</a> app that powered <a class="reference external" href="http://in.pycon.org/">Pycon India 2009</a> to <a class="reference external" href="http://www.pinaxproject.com/">Pinax</a>. Actually,
I have not ported all the features but the current version is fairly
usable. I would love to hear feedback from you regarding the app that
I named <a class="reference external" href="http://github.com/theju/confista">Confista</a> (Conference + Assistant). I know the name sucks but
could not think of something better! If you wish to contribute to the
project, please <a class="reference external" href="http://github.com/theju/confista">fork</a> the code and suggest improvements.</p>
<p>And there is another <a class="reference external" href="http://www.pinaxproject.com/">Pinax</a> based project underway to power the
<a class="reference external" href="http://www.avayamtrust.org/">Avayam Trust</a> site that I am associated with as a web master.</p>
RFC: Comments framework usage documentation2009-10-29T15:59:39+00:002009-10-29T15:59:39+00:00Thejaswi Puthrayatag:thejaswi.info,2009-10-29:/tech/blog/2009/10/29/rfc-comments-framework-usage-documentation/<p>This is my attempt at ticket <a class="reference external" href="http://code.djangoproject.com/ticket/9819">#9819</a> which aims for better documentation to the <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/contrib/comments/#ref-contrib-comments-index">comments</a> framework. This is my second attempt at writing documentation
and I have uploaded a <a class="reference external" href="http://code.djangoproject.com/attachment/ticket/9819/9819.diff">patch</a> to the ticket but wanted some feedback here without spamming the <a class="reference external" href="http://code.djangoproject.com/timeline">timeline</a>.</p>
<div class="section" id="example-of-using-the-in-built-comments-app">
<h2>Example of using the in-built comments app</h2>
<ol class="arabic simple">
<li>Follow …</li></ol></div><p>This is my attempt at ticket <a class="reference external" href="http://code.djangoproject.com/ticket/9819">#9819</a> which aims for better documentation to the <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/contrib/comments/#ref-contrib-comments-index">comments</a> framework. This is my second attempt at writing documentation
and I have uploaded a <a class="reference external" href="http://code.djangoproject.com/attachment/ticket/9819/9819.diff">patch</a> to the ticket but wanted some feedback here without spamming the <a class="reference external" href="http://code.djangoproject.com/timeline">timeline</a>.</p>
<div class="section" id="example-of-using-the-in-built-comments-app">
<h2>Example of using the in-built comments app</h2>
<ol class="arabic simple">
<li>Follow the first three steps of the quick start guide in the <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/contrib/comments/#ref-contrib-comments-index">documentation</a>.</li>
<li>Now suppose, you have an app (<tt class="docutils literal">blog</tt>) with a model (<tt class="docutils literal">Post</tt>) to which you want to attach comments. Let us also suppose that you have a template called <tt class="docutils literal">blog_detail.html</tt> where you want to display the comments list and comment form.</li>
<li>First, we should load the <tt class="docutils literal">comment</tt> template tags in the <tt class="docutils literal">blog_detail.html</tt> so that we can use it's functionality. So just like all other custom template tag libraries:</li>
</ol>
<blockquote>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">load</span> <span class="nv">comments</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</blockquote>
<ol class="arabic">
<li><p class="first">Next, let us add the number of comments attached to the particular model instance of <tt class="docutils literal">Post</tt>. For this we assume that a context variable <tt class="docutils literal">object_pk</tt> is present which gives the <tt class="docutils literal">id</tt> of the instance of <tt class="docutils literal">Post</tt>.</p>
<p>The usage of the <tt class="docutils literal">get_comment_count</tt> tag is like below:</p>
</li>
</ol>
<blockquote>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">get_comment_count</span> <span class="nv">for</span> <span class="nv">blog.post</span> <span class="nv">object_pk</span> <span class="k">as</span> <span class="nv">comment_count</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"><p></span><span class="cp">{{</span> <span class="nv">comment_count</span> <span class="cp">}}</span><span class="x"> comments have been posted.</p></span>
</pre></div>
</blockquote>
<p>If you have the instance (say <tt class="docutils literal">entry</tt>) of the model (<tt class="docutils literal">Post</tt>) available in the context, then you can refer to it directly:</p>
<blockquote>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">get_comment_count</span> <span class="nv">for</span> <span class="nv">entry</span> <span class="k">as</span> <span class="nv">comment_count</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"><p></span><span class="cp">{{</span> <span class="nv">comment_count</span> <span class="cp">}}</span><span class="x"> comments have been posted.</p></span>
</pre></div>
</blockquote>
<ol class="arabic">
<li><p class="first">To get a list of comments, we make use of the <tt class="docutils literal">get_comment_list</tt> tag. This tag's usage is very similar to the <tt class="docutils literal">get_comment_count</tt> tag. We
need to remember that the <tt class="docutils literal">get_comment_list</tt> returns a list of comments and hence we will have to iterate through them to display them:</p>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">get_comment_list</span> <span class="nv">for</span> <span class="nv">blog.post</span> <span class="nv">object_pk</span> <span class="k">as</span> <span class="nv">comment_list</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">comment</span> <span class="k">in</span> <span class="nv">comment_list</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"><p>Posted by: </span><span class="cp">{{</span> <span class="nv">comment.user_name</span> <span class="cp">}}</span><span class="x"> on </span><span class="cp">{{</span> <span class="nv">comment.submit_date</span> <span class="cp">}}</span><span class="x"></p></span>
<span class="x">...</span>
<span class="x"><p>Comment: </span><span class="cp">{{</span> <span class="nv">comment.comment</span> <span class="cp">}}</span><span class="x"></p></span>
<span class="x">...</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</li>
<li><p class="first">Finally, we display the comment form, enabling users to enter their comments. There are two ways of doing so. The first is when you want to display the
comments template available under your <tt class="docutils literal">comments/form.html</tt>. The other method gives you a chance to customize the form.</p>
<p>The first method makes use of the <tt class="docutils literal">render_comment_form</tt> tag. It's usage too is similar to the other two tags we have discussed above:</p>
</li>
</ol>
<blockquote>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">render_comment_form</span> <span class="nv">for</span> <span class="nv">entry</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</blockquote>
<p>It looks for the <tt class="docutils literal">form.html</tt> under the following directories (for our example):</p>
<pre class="literal-block">
comments/blog/post/form.html
comments/blog/form.html
comments/form.html
</pre>
<dl class="docutils">
<dt>Since we customize the form in the second method, we make use of another tag called <tt class="docutils literal">get_comment_target</tt>. This tag on rendering gives the URL where the comment form is posted. Without any <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/#ref-contrib-comments-custom">customization</a>, <tt class="docutils literal">get_comment_target</tt></dt>
<dd><blockquote class="first">
evaluates to <tt class="docutils literal">/comments/post/</tt>. We use this tag in the form's <tt class="docutils literal">action</tt> attribute. The <tt class="docutils literal">get_comment_form</tt> tag renders a <tt class="docutils literal">form</tt> for a model instance by creating a context variable. One can iterate over the <tt class="docutils literal">form</tt> object to get individual fields. This gives you fine-grain control over the form:</blockquote>
<div class="last"><div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">field</span> <span class="k">in</span> <span class="nv">form</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">ifequal</span> <span class="nv">field.name</span> <span class="s2">"comment"</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> <!-- Customize the "comment" field, say, make CSS changes --></span>
<span class="x">...</span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div></dd>
</dl>
<p>But let's look at a simple example:</p>
<blockquote>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">get_comment_form</span> <span class="nv">for</span> <span class="nv">entry</span> <span class="k">as</span> <span class="nv">form</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"><!-- A context variable called form is created with the necessary hidden fields,</span>
<span class="x">timestamps and security hashes --></span>
<span class="x"><table></span>
<span class="x"><form action="</span><span class="cp">{%</span> <span class="k">comment_form_target</span> <span class="cp">%}</span><span class="x">" method="POST"></span>
<span class="x"> </span><span class="cp">{{</span> <span class="nv">form</span> <span class="cp">}}</span><span class="x"></span>
<span class="x"> <tr></span>
<span class="x"> <td></td></span>
<span class="x"> <td><input type="submit" name="preview" class="submit-post" value="Preview"></td></span>
<span class="x"> </tr></span>
<span class="x"></form></span>
<span class="x"></table></span>
</pre></div>
</blockquote>
<ol class="arabic">
<li><p class="first">If you want your users to be able to flag comments (say for profanity), you can just direct them (by placing a link in your comment list) to <tt class="docutils literal"><span class="pre">/flag/{{</span> comment.id }}/</tt>. Similarly, a user with
requisite permissions (<tt class="docutils literal">"Can moderate comments"</tt>) can approve and delete comments. This can also be done through the <tt class="docutils literal">admin</tt> as you'll see later. You might also want to customize the following templates:</p>
<blockquote>
<ul class="simple">
<li><tt class="docutils literal">flag.html</tt></li>
<li><tt class="docutils literal">flagged.html</tt></li>
<li><tt class="docutils literal">approve.html</tt></li>
<li><tt class="docutils literal">approved.html</tt></li>
<li><tt class="docutils literal">delete.html</tt></li>
<li><tt class="docutils literal">deleted.html</tt></li>
</ul>
</blockquote>
<p>found under the directory structure we saw for <tt class="docutils literal">form.html</tt>.</p>
</li>
<li><p class="first">Suppose you want to export a <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/contrib/syndication/#ref-contrib-syndication">feed</a> of the latest comments, you can use the in-built <tt class="docutils literal">LatestCommentFeed</tt>. Just enable it in your project's <tt class="docutils literal">urls.py</tt>:</p>
</li>
</ol>
<blockquote>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.conf.urls.defaults</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">django.contrib.comments.feeds</span> <span class="kn">import</span> <span class="n">LatestCommentFeed</span>
<span class="n">feeds</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">'latest'</span><span class="p">:</span> <span class="n">LatestCommentFeed</span><span class="p">,</span>
<span class="p">}</span>
<span class="n">urlpatterns</span> <span class="o">=</span> <span class="n">patterns</span><span class="p">(</span><span class="s1">''</span><span class="p">,</span>
<span class="c1"># ...</span>
<span class="p">(</span><span class="sa">r</span><span class="s1">'^feeds/(?P<url>.*)/$'</span><span class="p">,</span> <span class="s1">'django.contrib.syndication.views.feed'</span><span class="p">,</span>
<span class="p">{</span><span class="s1">'feed_dict'</span><span class="p">:</span> <span class="n">feeds</span><span class="p">}),</span>
<span class="c1"># ...</span>
<span class="p">)</span>
</pre></div>
</blockquote>
<p>Now you should have the latest comment feeds being served off <tt class="docutils literal">/feeds/latest/</tt>.</p>
<ol class="arabic">
<li><p class="first">Now that we have the comments framework working, we might want to have some moderation setup to administer the comments. The comments framework comes in-built with <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/contrib/comments/moderation/#ref-contrib-comments-moderation">generic comment moderation</a>. The comment moderation has the following features (all of which or only certain can be enabled):</p>
<blockquote>
<ul class="simple">
<li>Enable comments for a particular model instance.</li>
<li>Close comments after a particular (user-defined) number of days.</li>
<li>Email new comments to the site-staff.</li>
</ul>
</blockquote>
</li>
<li><p class="first">To enable comment moderation, we subclass the <tt class="docutils literal">CommentModerator</tt> and register it with the moderation features we want. Let us suppose we want to close comments after 7 days of posting and also send out an email to the site staff. In <tt class="docutils literal">blog/models.py</tt>, we register a comment moderator in the following way:</p>
</li>
</ol>
<blockquote>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.contrib.comments.moderation</span> <span class="kn">import</span> <span class="n">CommentModerator</span><span class="p">,</span> <span class="n">moderator</span>
<span class="kn">from</span> <span class="nn">django.db</span> <span class="kn">import</span> <span class="n">models</span>
<span class="k">class</span> <span class="nc">Post</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
<span class="n">title</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span> <span class="o">=</span> <span class="mi">255</span><span class="p">)</span>
<span class="n">content</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">TextField</span><span class="p">()</span>
<span class="n">posted_date</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">DateTimeField</span><span class="p">()</span>
<span class="k">class</span> <span class="nc">PostModerator</span><span class="p">(</span><span class="n">CommentModerator</span><span class="p">):</span>
<span class="n">email_notification</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">auto_close_field</span> <span class="o">=</span> <span class="s1">'posted_date'</span>
<span class="c1"># Close the comments after 7 days.</span>
<span class="n">close_after</span> <span class="o">=</span> <span class="mi">7</span>
<span class="n">moderator</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">Post</span><span class="p">,</span> <span class="n">PostModerator</span><span class="p">)</span>
</pre></div>
</blockquote>
<ol class="arabic">
<li><p class="first">The generic comment moderation also has the facility to remove comments. These comments can
then be moderated by any user who has access to the <tt class="docutils literal">admin</tt> site and the <tt class="docutils literal">Can moderate comments</tt> permission (can be set under the <tt class="docutils literal">Users</tt> page in the <tt class="docutils literal">admin</tt>).</p>
</li>
<li><p class="first">The moderator can <tt class="docutils literal">Flag</tt>, <tt class="docutils literal">Approve</tt> or <tt class="docutils literal">Remove</tt> comments using the <tt class="docutils literal">Action</tt> drop-down
in the <tt class="docutils literal">admin</tt> under the <tt class="docutils literal">Comments</tt> page.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Only a super-user will be able to delete comments from the database. <tt class="docutils literal">Remove Comments</tt>
only sets the <tt class="docutils literal">is_public</tt> attribute to <tt class="docutils literal">False</tt>.</p>
</div>
</li>
</ol>
</div>
Git workflow for enterprises2009-10-25T10:15:02+00:002009-10-25T10:15:02+00:00Thejaswi Puthrayatag:thejaswi.info,2009-10-25:/tech/blog/2009/10/25/git-workflow-for-enterprises/<p><a class="reference external" href="http://git-scm.com/">Git</a> is a super-cool <a class="reference external" href="http://en.wikipedia.org/wiki/Revision_control">VCS</a> that encourages a distributed workflow. Sorry, this post is full of enterprisey jargon because it is meant for them.</p>
<p>Usually, most enterprises have development teams that consist of smaller <cite>independent</cite> sub-teams with little communication among them. They have a workflow where the code is first …</p><p><a class="reference external" href="http://git-scm.com/">Git</a> is a super-cool <a class="reference external" href="http://en.wikipedia.org/wiki/Revision_control">VCS</a> that encourages a distributed workflow. Sorry, this post is full of enterprisey jargon because it is meant for them.</p>
<p>Usually, most enterprises have development teams that consist of smaller <cite>independent</cite> sub-teams with little communication among them. They have a workflow where the code is first tested (against dummy data) on a development machine and then on a staged machine with production data before the code is finally promoted.</p>
<p>The development teams have no access to production data because it could be confidential or too cumbersome to setup. The staging teams (in enterprise jargon called "integration teams") usually consists of senior folks (probably under <a class="reference external" href="http://en.wikipedia.org/wiki/Non-disclosure_agreement">NDAs</a>) who monitor the staging servers and report bugs and anomalies to the developers. Finally,
there is a production (operations or ops) team that communicates with the staging team once in a while and promotes tested code.</p>
<p>Laborious process...eh? True, but it is a time-tested process that hardly fails (do I sound like a manager? Oh gosh!). This workflow is
called the <strong>"Staged Integration Workflow"</strong>.</p>
<p>Now imagine implementing this workflow in <a class="reference external" href="http://subversion.tigris.org/">Subversion</a>! Ah...I bet you just said "Painful". <a class="reference external" href="http://git-scm.com/">Git</a> can help reduce the pain because of the way
it has been designed. This article is inspired from scenarios at my previous work place. I wasn't successful in convincing a migration to <a class="reference external" href="http://git-scm.com/">Git</a> because of a strong <a class="reference external" href="http://subversion.tigris.org/">Subversion</a> bias. But hopefully, this article will be helpful to some others willing to give <a class="reference external" href="http://git-scm.com/">Git</a> a try.</p>
<p>So time to make a few assumptions:</p>
<ul class="simple">
<li>The enterprise is using a nix variant (most enterprises are already singled out because they love the Redmond based company. If your enterprise in one among them, time to stop reading this and go pester your management for "A Real OS").</li>
<li>The enterprise has no problems using SSH.</li>
</ul>
<div class="section" id="workflow">
<h2>Workflow</h2>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4041428107/"><img alt="Git Workflow for enterprises" class="align-center" src="http://farm3.static.flickr.com/2715/4041428107_9f5cd7fcdc_d.jpg" /></a>
<ul>
<li><p class="first">Create users for each developer (you don't have to create them if you already have user accounts setup). Create 3 additional accounts for the git development, staging and production repositories.</p>
</li>
<li><p class="first">Create SSH keys for each user and copy them to the corresponding repository's authorized keys ie copy the SSH keys of the developers into the development
repository's user account, the staging team's SSH keys into the development repository. Finally, the production team's SSH keys into staging repository.</p>
</li>
<li><p class="first">Create a git project in the <a class="reference external" href="http://git-scm.com/">Git</a> development repository user.</p>
<div class="highlight"><pre><span></span>$ mkdir git_project
$ <span class="nb">cd</span> git_project
$ git init
<span class="c1"># Add, edit and finally commit your files to the repository</span>
$ git commit -m <span class="s2">"Commit Message"</span> .
</pre></div>
</li>
<li><p class="first">Now the developers clone this repository on their dev boxes, create multiple branches according to their comfort and push their changes back to the server after running the test-suite.</p>
<div class="highlight"><pre><span></span>$ git clone dev_user@dev_server:/path/to/git_project
<span class="c1"># Makes his own branches and works on features and pushes</span>
<span class="c1"># code after the test-suite passes.</span>
$ git push
</pre></div>
</li>
<li><p class="first">The staging server is setup the following way:</p>
<div class="highlight"><pre><span></span><span class="c1"># The following steps are done for the first time</span>
$ mkdir git_project
$ <span class="nb">cd</span> git_project
$ git init
$ git remote add dev_repo dev_repo_user@dev_server:/path/to/git_project
$ git pull dev_repo
$ git checkout -b dev_branch dev_repo/master
$ git checkout -b staging_branch
</pre></div>
</li>
<li><p class="first">A tag is created to refer to the commit when the pull is performed. This tag is used as a reference for bug reports and internal communication. Then
pull from the development repository is done on a pull request from the developers or periodically (say end of day).</p>
<div class="highlight"><pre><span></span>$ git checkout dev_branch
$ git pull dev_repo dev_branch
<span class="c1"># Create a unique tag</span>
$ git tag tag_<span class="sb">`</span>date +%Y%m%d<span class="sb">`</span>
$ git push dev_repo tag_<span class="sb">`</span>date +%Y%m%d<span class="sb">`</span>
<span class="c1"># The stage user runs a test against production data</span>
<span class="c1"># After it passes, the dev_branch is merged with the</span>
<span class="c1"># staging branch</span>
$ git checkout staging_branch
$ git merge dev_branch
</pre></div>
</li>
<li><p class="first">A similar process happens on the production side.</p>
<div class="highlight"><pre><span></span><span class="c1"># The following steps are done for the first time</span>
$ mkdir git_project
$ <span class="nb">cd</span> git_project
$ git init
$ git remote add staging_repo staging_repo_user@staging_server:/path/to/git_project
$ git pull staging_repo
$ git checkout -b staging_branch staging_repo/staging_branch
$ git checkout -b prod_branch
</pre></div>
</li>
<li><p class="first">Once more for clarity:</p>
<div class="highlight"><pre><span></span>$ git checkout staging_branch
$ git pull staging_repo staging_branch
$ git checkout prod_branch
$ git merge prod_branch
</pre></div>
</li>
</ul>
<p>The steps that I have written are quite verbose. If you are comfortable with the usual <a class="reference external" href="http://git-scm.com/">Git</a> terminology of <cite>origin</cite> (default remote repo) and <cite>master</cite> (default refspec), you can reduce the number of lines. It is also possible to host the repositories (dev, staging and prod) on one machine, as 3 different users (useful for small enterprises that can't afford many machines).</p>
<p>It is possible to implement the same workflow with <a class="reference external" href="http://subversion.tigris.org/">Subversion</a> but it can be very painful and confusing. What applies to <a class="reference external" href="http://git-scm.com/">Git</a> will also apply to any other <a class="reference external" href="http://en.wikipedia.org/wiki/Distributed_revision_control">DVCS</a> like <a class="reference external" href="http://www.selenic.com/mercurial/">Mercurial</a> and <a class="reference external" href="http://bazaar-vcs.org/">Bazaar</a>.</p>
<p>So go ahead and refine your workflow and don't forget <a class="reference external" href="http://git-scm.com/">Git</a>, the stupid content tracker.</p>
</div>
Pay per second or per minute?2009-10-23T08:59:48+00:002009-10-23T08:59:48+00:00Thejaswi Puthrayatag:thejaswi.info,2009-10-23:/tech/blog/2009/10/23/pay-per-second-or-per-minute/<p>Lots of my friends and acquaintances have moved to
a new GSM service that promises them a pay per second
service. On their website it clearly mentions that
if you talk for 67 seconds then you pay only for 67
seconds and not for 2 minutes like other providers.
The …</p><p>Lots of my friends and acquaintances have moved to
a new GSM service that promises them a pay per second
service. On their website it clearly mentions that
if you talk for 67 seconds then you pay only for 67
seconds and not for 2 minutes like other providers.
The service I am talking about is <a class="reference external" href="http://tatadocomo.com/">Tata Docomo</a>
(yes, the <a class="reference external" href="http://www.nttdocomo.com/">Docomo</a> from <a class="reference external" href="http://en.wikipedia.org/wiki/Japan">Japan</a>). I tried dissuading
a lot of them mentioning it was actually costlier
but no one would listen. So today, I am writing it
down not just for their benefit but for others too.</p>
<p>Before I begin the explanation, I make some assumptions:</p>
<ul class="simple">
<li>I am considering <a class="reference external" href="http://airtel.in/">Airtel</a> because it is the largest mobile service provider and offers a pay per minute scheme in <a class="reference external" href="http://en.wikipedia.org/wiki/India">India</a> and <a class="reference external" href="http://tatadocomo.com/">Tata Docomo</a> because it pioneered the pay per second scheme in <a class="reference external" href="http://en.wikipedia.org/wiki/India">India</a>. Most assumptions will stand good for other pay per second and pay per minute service providers.</li>
<li>The <a class="reference external" href="http://tatadocomo.com/">Tata Docomo</a> plan that I refer to is the well advertised 1p/1sec plan with a 1 sec pulse rate.</li>
<li>The <a class="reference external" href="http://airtel.in/">Airtel</a> plan is any base plan with RC-53 (ie an annual rental of Rs 53 that reduces your local call rates including wirelines to Rs 0.50).</li>
<li>Both these plans are well documented on the respective service provider websites for <a class="reference external" href="http://en.wikipedia.org/wiki/Andhra_Pradesh">Andhra Pradesh</a> (that's where I live).</li>
<li>I am not taking the cost of RC-53 voucher into consideration because it account to Rs 0.15/day which is almost negligible.</li>
<li>I am excluding STD (out-station calls) charges because it is very difficult to compare two unlike plans.</li>
<li>Both plans are prepaid. I am excluding post-paid because 94.3% of mobile connections in India are prepaid.</li>
</ul>
<p>I have written a small <a class="reference external" href="http://www.python.org/">python</a> script that dumps a csv file with the
call costs for both providers till 600 seconds (ie a call duration
till 600 seconds in steps of 10 seconds).</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">math</span> <span class="kn">import</span> <span class="n">ceil</span>
<span class="kn">from</span> <span class="nn">csv</span> <span class="kn">import</span> <span class="n">DictWriter</span>
<span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
<span class="n">dw</span> <span class="o">=</span> <span class="n">DictWriter</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="s1">'airtel_docomo.csv'</span><span class="p">,</span><span class="s1">'w'</span><span class="p">),</span> <span class="p">[</span><span class="s1">'Number of Secs'</span><span class="p">,</span> <span class="s1">'Airtel Cost'</span><span class="p">,</span> <span class="s1">'Tata Docomo Cost'</span><span class="p">])</span>
<span class="n">dw</span><span class="o">.</span><span class="n">writerow</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">dw</span><span class="o">.</span><span class="n">fieldnames</span><span class="p">,</span> <span class="n">dw</span><span class="o">.</span><span class="n">fieldnames</span><span class="p">)))</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">xrange</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mi">600</span><span class="p">,</span> <span class="mi">10</span><span class="p">):</span>
<span class="n">dw</span><span class="o">.</span><span class="n">writerow</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">dw</span><span class="o">.</span><span class="n">fieldnames</span><span class="p">,</span> <span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">ceil</span><span class="p">(</span><span class="n">i</span> <span class="o">/</span> <span class="mf">60.0</span><span class="p">)</span> <span class="o">*</span> <span class="mf">0.5</span><span class="p">,</span> <span class="n">i</span> <span class="o">*</span> <span class="mf">0.01</span><span class="p">]))</span>
<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">'__main__'</span><span class="p">:</span>
<span class="n">main</span><span class="p">()</span>
</pre></div>
<p>If you don't understand the code, no problem. I am just creating a file with the costs of
both providers for every 10 seconds upto 600 seconds. If you are a code police, then please
forgive me...this is just a quick and dirty script.</p>
<p>I then used a plotting program (for the curious, it is <a class="reference external" href="http://www.gnuplot.info/">gnuplot</a>) to visualize the results.</p>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4036949082/"><img alt="Airtel vs Tata Docomo Average call cost" class="align-center" src="http://farm3.static.flickr.com/2785/4036949082_18315dd4bd_d.jpg" /></a>
<p>So clearly, <a class="reference external" href="http://airtel.in/">Airtel</a> is costly if a call lasts less than 4 minutes. Post
that, you can see that <a class="reference external" href="http://tatadocomo.com/">Tata Docomo</a> is costly.</p>
<div class="section" id="diet-sms-vs-vanilla-sms">
<h2>Diet SMS vs Vanilla SMS</h2>
<p>Now let's focus to the other unique feature of <a class="reference external" href="http://tatadocomo.com/">Tata Docomo</a>, Diet SMS.
Under this scheme they charge you per character (1p/1character).</p>
<p>According to TRAI's latest figures (June-2009), the average number of
outgoing SMSes per subscriber per month is 28. So I calculate the cost
based on this number.</p>
<p>Further assumptions:</p>
<ul class="simple">
<li>The subscriber sends only local SMSes.</li>
<li>Linearity ie the subscriber sends the same number of characters throughout the whole month.</li>
</ul>
<p>The comparision:</p>
<ul class="simple">
<li>The cost of 28 SMSes in <a class="reference external" href="http://airtel.in/">Airtel</a> without any special scheme is Rs 28/month. This plan is very uneconomical and hence I compare it to another.</li>
<li>The cost of 28 SMSes in <a class="reference external" href="http://tatadocomo.com/">Tata Docomo</a> ranges from Rs 0.28/month to Rs 44.80/month depending on the characters. The average price is Rs 22.50 (approx).</li>
<li>Now <a class="reference external" href="http://airtel.in/">Airtel</a> has a scheme where they offer unlimited local SMSes for a flat payment of Rs 22/month.</li>
</ul>
<p>The accompanying code is given below:</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">math</span> <span class="kn">import</span> <span class="n">ceil</span>
<span class="kn">from</span> <span class="nn">csv</span> <span class="kn">import</span> <span class="n">DictWriter</span>
<span class="n">number_of_messages</span> <span class="o">=</span> <span class="mi">28</span>
<span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
<span class="n">dw</span> <span class="o">=</span> <span class="n">DictWriter</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="s1">'airtel_docomo.csv'</span><span class="p">,</span><span class="s1">'w'</span><span class="p">),</span> <span class="p">[</span><span class="s1">'Number of Chars'</span><span class="p">,</span> <span class="s1">'Airtel Cost'</span><span class="p">,</span> <span class="s1">'Tata Docomo Cost'</span><span class="p">])</span>
<span class="n">dw</span><span class="o">.</span><span class="n">writerow</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">dw</span><span class="o">.</span><span class="n">fieldnames</span><span class="p">,</span> <span class="n">dw</span><span class="o">.</span><span class="n">fieldnames</span><span class="p">)))</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">xrange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">161</span><span class="p">):</span>
<span class="n">dw</span><span class="o">.</span><span class="n">writerow</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">dw</span><span class="o">.</span><span class="n">fieldnames</span><span class="p">,</span> <span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="mf">22.0</span><span class="p">,</span> <span class="n">i</span> <span class="o">*</span> <span class="mf">0.01</span> <span class="o">*</span> <span class="n">number_of_messages</span><span class="p">])))</span>
<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">'__main__'</span><span class="p">:</span>
<span class="n">main</span><span class="p">()</span>
</pre></div>
<p>Here are the graphs:</p>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4036949184/"><img alt="Airtel vs Tata Docomo Average SMS cost" class="align-center" src="http://farm3.static.flickr.com/2471/4036949184_57df04c938_d.jpg" /></a>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4036949156/"><img alt="Airtel vs Tata Docomo 10 SMS cost" class="align-center" src="http://farm3.static.flickr.com/2570/4036949156_73e0b0477a_d.jpg" /></a>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4036197155/"><img alt="Airtel vs Tata Docomo 20 SMS cost" class="align-center" src="http://farm3.static.flickr.com/2722/4036197155_9650ce141e_d.jpg" /></a>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4036197127/"><img alt="Airtel vs Tata Docomo 50 SMS cost" class="align-center" src="http://farm3.static.flickr.com/2781/4036197127_b8dd0dd6b4_d.jpg" /></a>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4036197099/"><img alt="Airtel vs Tata Docomo 100 SMS cost" class="align-center" src="http://farm3.static.flickr.com/2715/4036197099_d54ea3b2a1_d.jpg" /></a>
<p>As you can see, <a class="reference external" href="http://airtel.in/">Airtel</a> turns out to be a lot cheaper if your SMS volume is huge else
you are good with <a class="reference external" href="http://tatadocomo.com/">Tata Docomo</a></p>
</div>
<div class="section" id="why-is-pay-per-second-so-enticing-for-people">
<h2>Why is pay per second so enticing for people?</h2>
<p>Actually, this is a hard question to answer because it involves some psychology.
But I believe most people are falling for the marketing.</p>
<p>Another explanation could be that <a class="reference external" href="http://tatadocomo.com/">Tata Docomo</a> has studied the national averages
and come out with a plan that closely matches these numbers.</p>
<p>From <a class="reference external" href="http://www.trai.gov.in/">TRAI</a>'s, quarterly report for the quarter ending June,2009, it mentions that the
national average minutes of usage (MOU) (includes both incoming and outgoing) is 454
minutes/subscriber/month ie approximately 15 minutes/day. And out of this only around
30% is outgoing (the time for which you pay). This is around 5 minutes/day and for such
low usage pay per second is beneficial.</p>
</div>
<div class="section" id="i-believe-pay-per-second-brings-in-healthy-competition">
<h2>I believe pay per second brings in healthy competition...</h2>
<p>Ideally, competition is good because it gives the customer more choices. But the kind
of competition that has started now is not healthy, it is <a class="reference external" href="http://en.wikipedia.org/wiki/Competition#Destructive_competition">destructive</a>. Companies are
slowly killing each other and in the process, the customer.</p>
</div>
<div class="section" id="how-can-the-customer-be-harmed">
<h2>How can the customer be harmed?</h2>
<p>Most of these telecom companies invest crores of rupees in licensing (just for
a rough idea, around 10% of their Gross Revenue. For <a class="reference external" href="http://airtel.in/">Airtel</a> it is nearly 1000 crores),
billing, marketing, network maintenance and expansion and customer service (free for
the customer but a huge expenditure to the company). This kind of competition is definitely
bringing down call costs but affecting the companies and in turn the customer.</p>
<p>Here is data from the same TRAI report to confirm the same:</p>
<ul class="simple">
<li>Average Outgo Per Min = (Rental Revenue + Airtime Revenue)/Total number of minutes. The Average outgo per minute decreased to 0.74 in June from 0.76 in March, 2009 (It was Rs 15 exactly a decade ago).</li>
<li>But look at the call drop rate (number of calls disconnected), it increased to 2.56% from 2.05% in the same period with a benchmark of < 3% (very close to crossing that limit). Also look at the deterioration in customer service. The number of complaints per 100 bills issued increased to 3.21% from 1.37% in the same period with a TRAI specified benchmark of < 0.1%.</li>
<li>The average revenue per user (ARPU) too decreased from Rs 205/month to Rs 185/month.</li>
<li>The number of minutes of usage (MOU) too decreased from 488 to 454 minutes. So the customer has reduced the number of calls despite the costs decreasing. The number of outgoing SMSes too reduced from 30 to 28. So mobile carriers are losing revenues from their core and value added services.</li>
</ul>
<p>The companies that are in to make money are losing money....What an irony!</p>
</div>
<div class="section" id="so-is-this-the-end-of-conventinal-mobile-companies">
<h2>So is this the end of conventinal mobile companies?</h2>
<p>If stock analysts are to be believed, the answer is "YES". They triggered a large sell-off
in telecom stocks <a class="reference external" href="http://uk.biz.yahoo.com/06102009/323/update-2-call-charge-cuts-hammer-india-telecom-stocks.html">recently</a> because of the competition and have downgraded earnings.</p>
<p>My answer is a "probably not". I believe the company which manages to retain customers by
providing them the best network and moderate call rates with superb customer service will
survive. You can see a lot of consolidation in the telecom space in the next 2-3 years.
Lots of these new (and probably some well established ones) companies will struggle to
survive and will merge (comparable with what happened in the Indian aviation sector nearly
3 years back). I think the next big thing that could affect mobile operators in a huge way
would not be competition but <strong>number portability</strong> (where the customer can switch operators
while retaining the same number).</p>
<p>Finally, I would like to inform all mobile subscribers to choose a service based not just
on the call rates or marketing but also on the important features like network superiority
and customer service.</p>
<p><strong>Be a happy and informed customer!</strong></p>
<p><strong>Annexure</strong>: Most statistics are taken from <a class="reference external" href="http://www.trai.gov.in/WriteReadData/trai/upload/Reports/48/IndicatorReport1oct09.pdf">here</a>.</p>
</div>
Rangoli Design2009-10-14T22:03:41+00:002009-10-14T22:03:41+00:00Thejaswi Puthrayatag:thejaswi.info,2009-10-14:/photo/blog/2009/10/14/rangoli-design/<p>Come <a class="reference external" href="http://en.wikipedia.org/wiki/Diwali">Diwali</a> and most Indian porticos are adorned with <a class="reference external" href="http://en.wikipedia.org/wiki/Rangoli">Rangolis</a>.</p>
<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/4014410360/"><img alt="Rangoli Design on Paper" class="align-center" src="http://farm3.static.flickr.com/2639/4014410360_3098de9058_d.jpg" /></a>
<p>I caught my mom practicing it on paper before she sets out to make one soon.</p>
<p>Happy Diwali!</p>
My VPS was compromised!2009-10-13T12:55:49+00:002009-10-13T12:55:49+00:00Thejaswi Puthrayatag:thejaswi.info,2009-10-13:/tech/blog/2009/10/13/my-vps-was-compromised/<p>Some of you might have seen tweets as I was working on the problem starting from <a class="reference external" href="http://twitter.com/theju/status/4827480527.">this one</a>. But this post is a clearer explanation of all that I did because 140 characters (even multiple tweets) is not sufficient to convey the message.</p>
<div class="section" id="how-i-realized-there-was-a-problem">
<h2>How I realized there was a problem …</h2></div><p>Some of you might have seen tweets as I was working on the problem starting from <a class="reference external" href="http://twitter.com/theju/status/4827480527.">this one</a>. But this post is a clearer explanation of all that I did because 140 characters (even multiple tweets) is not sufficient to convey the message.</p>
<div class="section" id="how-i-realized-there-was-a-problem">
<h2>How I realized there was a problem</h2>
<p>Yesterday, I wrote a blog <a class="reference external" href="http://thejaswi.info/personal/blog/2009/10/12/need-a-challenging-job/">post</a> and it did not get saved onto <a class="reference external" href="http://couchdb.apache.org/">CouchDB</a> immediately. I thought the problem was with the load on my server because of traffic (I should have realized this wasn't the reason because my blog has around 20 visitors per day).</p>
<p>Figuring something wrong, not seeing the post even a couple of hours later, I tried 'ssh'ing into my machine and observed that it was very slow and the CPU was getting thrashed (pegged at 100%) and the memory consumption at 70%.</p>
<p>But due to a personal commitment, I did not try to troubleshoot the problem then and didn't even suspect anything was wrong! My initial feeling was that it was probably caused by memory leaks in apache. How wrong I was!</p>
<p>Today morning I had forgotten about the problem until I saw a mail from my hosting service, <a class="reference external" href="http://www.gandi.net/hosting/">Gandi</a>
warning me to take action against a botnet hosted on my <a class="reference external" href="http://en.wikipedia.org/wiki/Virtual_Private_Server">VPS</a>. I was shocked! Had this been a mistake or was I looking at a phished mail. Then I recollected yesterday's problem and thought probably they were right.</p>
</div>
<div class="section" id="how-i-fixed-it">
<h2>How I fixed it</h2>
<p>I had a tough time logging in today also, but after I logged in the first thing I did was to stop the network. With that the load on the machine reduced dramatically. But the memory usage was still around 70%. Then I shut down <a class="reference external" href="http://nginx.net/">nginx</a>, <a class="reference external" href="http://httpd.apache.org/">apache http server</a>, <a class="reference external" href="http://www.postfix.org/">postfix</a> and <a class="reference external" href="http://www.nagios.org/">nagios</a> one by one while noting if any of these were the culprits. The memory reduction was visible but there was still something that was running (or sleeping).</p>
<p>Next, I performed a 'top' to check all processes running and noticed that nearly 100 binary instances of 'Xploit' was running. I killed them but they respawned within a second. I also noticed another binary called 'pscan2' running that was scanning a lot of ports on the network. So now I could confirm that my VPS was botted. But I wondered how the bots got in, especially when I was upgrading packages promptly and running a firewall. More on the actual break-in later in the post.</p>
<p>Then I ran 'netstat -plant' to check all open tcp ports and saw tens of connections to port 22 (the reason for slowness in ssh while trying to login) with the status SYN_WAIT (because I had shut down network access). Then I 'lsof'ed to see which application was opening so many connections to port 22 and saw something like this.</p>
<div class="highlight"><pre><span></span>/home2/server/ /a/Xploit ....
</pre></div>
<p>(Note the 'space' in the pathname. It was intentional on the botnet author's part).
Neat! So the botnet had found itself into the home directory of the apache process. I just copied the botnet directory over to my local directory. Then I deleted it on the VPS. I also cleaned /tmp/ and /var/tmp/ to be on the safe side and rebooted my VPS.</p>
<p>While I was rebooting I started digging through the botnet code (yes, quite a lot of C, Perl and Bash source code) on my local box and learnt that the main objectives of this botnet were:</p>
<blockquote>
<ul class="simple">
<li>To bruteforce SSH logins on random IPs.</li>
<li>To make the botted machine an open relay to send spam messages.</li>
</ul>
</blockquote>
<p>It looked like a fairly complicated botnet because it had atleast more than a couple of objectives. The password dictionary being used for bruteforcing was very simple and something like below:</p>
<blockquote>
<ul class="simple">
<li><username>123</li>
<li>password</li>
<li>test</li>
<li>123456</li>
<li>qwerty</li>
<li>asdf</li>
<li>oracle</li>
<li>admin</li>
<li>demo</li>
<li>pass</li>
</ul>
</blockquote>
<p>Some of the funny ones were like:</p>
<blockquote>
<ul class="simple">
<li>homework</li>
<li>einstein</li>
<li>nopassword</li>
<li>opensesame</li>
<li>letmein</li>
<li>nohackhere</li>
</ul>
</blockquote>
<p>After breaking in, the zombie computer would announce itself on the darknet IRC network. My machine had announced itself on the tampa.fl.us.undernet.org IRC server and was being commandeered from there.</p>
</div>
<div class="section" id="how-the-machine-was-broken-into">
<h2>How the machine was broken into?</h2>
<p>Ok, now coming to the point on how the machine was compromised. Nearly a couple of months back, I was getting lots of spam comments on my site and I was fairly sure they were manual (because breaking a recaptcha) is not that easy. But I was curious as to how this was happening. I also noticed that there were lots of port scans around port 25 (SMTP) then. So I created a dummy user and ran a trivial site with apache running with that dummy user's privileges and observed that most comments posted were coming from a single country and within a few seconds of each other. But the user agent seemed to suggest that it was a valid browser (probably a headless browser, who knows?). I had collected a lot of data about this and suddenly one fine day, the network scans and the spam comments vanished (check <a class="reference external" href="http://www.symantec.com/connect/blogs/latvian-isp-closure-dents-cutwail-botnet">symantec</a> for an approximate timeline).</p>
<p>I got busy later as I was relocating and leaving my job and forgot to delete the dummy user with the stupidly simple password (yes, one among the list that I provided) and the rest as they say is history....</p>
<p>As a corrective action, I have changed all passwords and this time, they are very difficult to guess and not based on any dictionary word. I have also configured PAM to prompt me for a change in password every month and reject common dictionary words.</p>
<p>I had read zillions of articles on common passwords like <a class="reference external" href="http://tech.yahoo.com/blog/hughes/11844">this</a> (and a lot that I can't remember) and have laughed my head off on the stupidity of people but I turned out to be as stupid as them! Very valuable lesson learnt...one that I can never forget in my life. I would recommend you too follow good password management techniques.</p>
<p><strong>PS</strong>: If anyone is interested in having the botnet code and logs, please mail me and I shall mail them over to you after I am convinced that you have no malafide intentions.</p>
</div>
Need a challenging job2009-10-12T12:55:49+00:002009-10-12T12:55:49+00:00Thejaswi Puthrayatag:thejaswi.info,2009-10-12:/personal/blog/2009/10/12/need-a-challenging-job/<p>September 25th,
was the last day at my previous job with <a class="reference external" href="http://www.citigroup.com/">Citi</a>. I had taken the decision after a slight deterioration in health and lack of satisfaction.</p>
<p>If you have
an interesting and challenging job, then please <a class="reference external" href="http://thejaswi.info/about/">contact</a> me.</p>
Writing a keylogger in Linux is very easy!2009-09-21T15:11:31+00:002009-09-21T15:11:31+00:00Thejaswi Puthrayatag:thejaswi.info,2009-09-21:/tech/blog/2009/09/21/writing-a-keylogger-in-linux-is-very-easy/<p>I strongly believe that an employer shouldn't monitor an employee's usage of internet and computing resources at work. But when the employer has <a class="reference external" href="http://en.wikipedia.org/wiki/Circumstantial_evidence">circumstantial evidence</a> to prove that an employee is using computing resources to benefit a competitor, then it is a different matter altogether.</p>
<p>Recently, my cousin requested me …</p><p>I strongly believe that an employer shouldn't monitor an employee's usage of internet and computing resources at work. But when the employer has <a class="reference external" href="http://en.wikipedia.org/wiki/Circumstantial_evidence">circumstantial evidence</a> to prove that an employee is using computing resources to benefit a competitor, then it is a different matter altogether.</p>
<p>Recently, my cousin requested me to write a <a class="reference external" href="en.wikipedia.org/wiki/Keystroke_logging">keylogger</a> after he got a call from a regular customer who had received a bid from a competitor for a project whose quotes were only emailed to his company. After a little investigation, he learnt that some employees created a similar looking email address (just missing a period (.)) and were diverting order enquiries. My cousin wanted to get the password of this new email address and the names of all employees who were defrauding the company. His decision to migrate all the company machines to Linux nearly 6 months back played to my advantage!</p>
<p>I wrote a simple keylogger in C++ mainly because I wanted to learn C++ and it would perform better without loading the CPUs. Let me make it very clear, that I am comparing python against C++. I still love python!</p>
<p>In Linux, <strong>every device is a file</strong>. So even the keyboard can be accessed just like any ordinary file.
I made use of the generic input drivers for X.org (<a class="reference external" href="http://en.wikipedia.org/wiki/Evdev">evdev</a>) to log the keystrokes into a file and another small utility to decode these keystrokes.</p>
<p>These utilities were cronned and sent the output by email.</p>
<p>No prizes to guess what happened to the employees and that email address!</p>
<p>The code is fairly simple and rudimentary. It is available at <a class="reference external" href="http://github.com/theju/linux-keylogger">github</a>. I plan to refine the code further based on requests. So if you require some help, please contact me.</p>
<p>PS: I would like to dedicate this code to my colleague at Citi and friend, <a class="reference external" href="http://www.linkedin.com/pub/sunwoo-park/5/597/56a">Sunwoo Park</a>. He taught and cleared doubts I had about C++ over IM!</p>
A movie review: Quick Gun Murugan2009-08-30T08:44:20+00:002009-08-30T08:44:20+00:00Thejaswi Puthrayatag:thejaswi.info,2009-08-30:/personal/blog/2009/08/30/a-movie-review-quick-gun-murugan/<p><em>"My name is Murugan...Quick Gun Murugan"</em>. Sounds familiar? No, it's not from a <em>'desi'</em> James Bond flick but from the movie <a class="reference external" href="http://en.wikipedia.org/wiki/Quick_Gun_Murugun">Quick Gun Murugan</a> that released all over India this weekend.</p>
<p>Murugan, played by seasoned actor <a class="reference external" href="http://en.wikipedia.org/wiki/Rajendra_Prasad_(actor)">Rajendra Prasad</a> is a garishly dressed, gun-trotting 'vegan' cowboy out there to save …</p><p><em>"My name is Murugan...Quick Gun Murugan"</em>. Sounds familiar? No, it's not from a <em>'desi'</em> James Bond flick but from the movie <a class="reference external" href="http://en.wikipedia.org/wiki/Quick_Gun_Murugun">Quick Gun Murugan</a> that released all over India this weekend.</p>
<p>Murugan, played by seasoned actor <a class="reference external" href="http://en.wikipedia.org/wiki/Rajendra_Prasad_(actor)">Rajendra Prasad</a> is a garishly dressed, gun-trotting 'vegan' cowboy out there to save the world from the evil 'Rice Plate' Reddy.</p>
<p>Sounds clichéd? Time for another pleasant surprise because the movie happens to be a spoof on Indian cinema and takes digs at the <em>superhero</em> formula depicted in innumerable pictures.</p>
<p>The crispy one-liners and the protagonist's misadventures elicit genuine laughter and you immediately start drawing parallels to the 'superheroes' of Indian cinema.</p>
<p>What makes the movie different from others in the same genre is that the cast has not got carried away and overdone their roles but sincerely stuck to it. The movie runs for a short and uncommon 75 minutes and kudos go to the dialogue writer, editor, producer and director for having taken such a huge risk of introducing this new type of cinema to Indian audiences. Rajendra Prasad and Nasser are the highlights of the flick and deserve an applause. The movie's success clearly reflects the coming of age of the Indian audience and I hope encourages other film makers to step in and experiment.</p>
<p>On the whole, I recommend this movie to all age groups. It's a great way to enjoy your weekend and laugh away your worries.</p>
<p>Signing off in Murugan style...MIND IT!!!</p>
A wiki with a couchdb backend and django2009-08-28T19:49:33+00:002009-08-28T19:49:33+00:00Thejaswi Puthrayatag:thejaswi.info,2009-08-28:/tech/blog/2009/08/28/a-wiki-with-a-couchdb-backend-and-django/<p>Recently, I had a requirement for a personal simple wiki. I checked out various options like <a class="reference external" href="http://www.tiddlywiki.com/">TiddlyWiki</a>, <a class="reference external" href="http://moinmo.in/">MoinMoin</a> and <a class="reference external" href="http://www.media.wiki.org/">MediaWiki</a> but wanted something very simple and something that didn't use a database server or flat files and was portable (and hostable).
So I quickly wrote up a wiki that used …</p><p>Recently, I had a requirement for a personal simple wiki. I checked out various options like <a class="reference external" href="http://www.tiddlywiki.com/">TiddlyWiki</a>, <a class="reference external" href="http://moinmo.in/">MoinMoin</a> and <a class="reference external" href="http://www.media.wiki.org/">MediaWiki</a> but wanted something very simple and something that didn't use a database server or flat files and was portable (and hostable).
So I quickly wrote up a wiki that used <a class="reference external" href="http://couchdb.apache.org/">couchdb</a> as its backend and <a class="reference external" href="http://www.djangoproject.com/">django</a> for the web app.</p>
<p>Couchdb stores the revisions of the edits and so I could always revert to a previous version if required. It also saved me the need of installing an RDBMS.</p>
<p>I released the <a class="reference external" href="http://http://github.com/theju/django-couch-wiki/tree/master">code</a> for the app at <a class="reference external" href="http://github.com/">github</a>. It's quite rudimentary at the stage but should be good enough for personal use. Hopefully, with a little more time and effort, I should be able to achieve what I set out for. (Check a <a class="reference external" href="http://thejaswi.info/wiki/">demo</a>). Just create a page of your choice by directing your browser to it.</p>
<p><strong>Note</strong>: User registration is blocked at the moment. But feel free to edit and create pages anonymously.</p>
<p>Interested in trying out the code on your machine?</p>
<div class="section" id="install">
<h2>INSTALL</h2>
<ul class="simple">
<li>Fetch the <cite>auth</cite> and <cite>sessions</cite> backends for couchdb from <a class="reference external" href="http://github.com/theju/django-couchdb-utils/tree/master">here</a> and add them to the <cite>INSTALLED_APPS</cite> in your project's <cite>settings.py</cite> as per the instructions. Also requires <a class="reference external" href="http://code.google.com/p/couchdb-python/">couchdb-python</a>.</li>
<li>Place the wiki app and reference it too in the <cite>INSTALLED_APPS</cite>.</li>
<li>Append the <cite>wiki/templates</cite> directory (with the absolute path) in the <cite>TEMPLATE_DIRS</cite> attribute of the <cite>settings.py</cite>.</li>
<li>Add a pointer to the wiki URL and account urls in your urls.py like</li>
</ul>
<blockquote>
<div class="highlight"><pre><span></span><span class="p">(</span><span class="sa">r</span><span class="s1">'^wiki/'</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="s1">'wiki.urls'</span><span class="p">))</span>
<span class="p">(</span><span class="sa">r</span><span class="s1">'^accounts/'</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="s1">'django.contrib.auth.urls'</span><span class="p">))</span>
</pre></div>
</blockquote>
<ul>
<li><p class="first">Add the following attributes to your <cite>settings.py</cite>.</p>
<div class="highlight"><pre><span></span><span class="n">COUCHDB_HOST</span> <span class="o">=</span> <span class="s1">'http://path_to_couchdb_server:port_num/'</span>
<span class="c1"># If you don't want unauthenticated users to create</span>
<span class="c1"># pages, then set the below attribute to False</span>
<span class="n">ALLOW_UNAUTH_PAGE_CREATION</span> <span class="o">=</span> <span class="kc">True</span>
<span class="c1"># The below attribute is optional, if not specified</span>
<span class="c1"># it redirects to an empty page.</span>
<span class="n">WELCOME_PAGE</span> <span class="o">=</span> <span class="s1">'/path/to/default/star/up/page/'</span>
</pre></div>
</li>
<li><p class="first">Your wiki is ready!</p>
</li>
</ul>
<p>Please let me know how you feel about this app.</p>
</div>
A healthy fast food recipe for bachelors!2009-08-17T18:39:47+00:002009-08-17T18:39:47+00:00Thejaswi Puthrayatag:thejaswi.info,2009-08-17:/personal/blog/2009/08/17/a-healthy-fast-food-recipe-for-bachelors/<p>Two weeks back, my office work hours changed. It couldn't have been more inconvenient, from 4:30am every morning.</p>
<p>I was really pissed and no matter how much I tried to plead for a slight delay to 6:30am or for a status quo, no one responded.</p>
<p>The first couple …</p><p>Two weeks back, my office work hours changed. It couldn't have been more inconvenient, from 4:30am every morning.</p>
<p>I was really pissed and no matter how much I tried to plead for a slight delay to 6:30am or for a status quo, no one responded.</p>
<p>The first couple of days, I went hungry till 8am when most restaurants opened around office. It was difficult to work on an empty stomach. My mother recommended a healthy and quick recipe. It was <em>"Flattened rice mixed with Curd"</em>. This recipe is very much similar to <a class="reference external" href="http://en.wikipedia.org/wiki/Thayir_sadam">Curd rice</a> but can be prepared within a couple of minutes.</p>
<p>The ingredients for this recipe are:</p>
<ul class="simple">
<li><a class="reference external" href="http://en.wikipedia.org/wiki/Flattened_rice">Flattened rice</a></li>
<li><a class="reference external" href="http://en.wikipedia.org/wiki/Curd">Curd</a></li>
</ul>
<p>If you don't have a refrigerator to store curd, no problem. Here's another tip again from my mother to prevent the curd from fermenting. Just place the curd you purchased/prepared the previous day and place it in a vessel that is partially immersed in water.</p>
<p>Back to the recipe, just soak the flattened rice for two minutes in water. Then take this flattened rice and mix it with curd. Done! Add pickle or salt or any other side dish as per your taste. Healthy and real quick!</p>
<p>Atleast now, I don't have to go hungry till 8am but what about 'lack of sleep' :( ? Does anyone have any tips for this?</p>
Reusable App: Authenticated Comments2009-08-04T19:35:48+00:002009-08-04T19:35:48+00:00Thejaswi Puthrayatag:thejaswi.info,2009-08-04:/tech/blog/2009/08/04/reusable-app-authenticated-comments/<p>This app had been on my todo list for a long time. Today, no matter how much I tried to procrastinate, I could not ignore it and hence decided to scratch my itch and get it done. I swore I wouldn't even get up for a glass of water until …</p><p>This app had been on my todo list for a long time. Today, no matter how much I tried to procrastinate, I could not ignore it and hence decided to scratch my itch and get it done. I swore I wouldn't even get up for a glass of water until it was done. Luckily, this took lesser time than I anticipated and I was spared of breaking my resolve!</p>
<p>There are certain sites that require only authenticated users to post comments, this app specifically targets such cases.</p>
<p>It builds on my previous posts sans the javascript hack. To make the code very condense and easy to use, it uses <strong>"Two-phased template rendering"</strong> that I saw in <a class="reference external" href="http://ellaproject.stdout.cz/">Ella</a> via <a class="reference external" href="http://www.holovaty.com/">Adrian Holovaty's</a> <a class="reference external" href="http://www.holovaty.com/writing/django-two-phased-rendering/">post</a>.
From a security point, it auto-escapes django template code injected in through the comments in the
middleware.</p>
<div class="section" id="how-to-use-it">
<h2>How to use it</h2>
<ul class="simple">
<li>Fetch the source from <a class="reference external" href="http://github.com/theju/django-comments-apps/tree/master">here</a> and copy the <cite>auth_comments</cite> app over to your project and reference it under the <cite>INSTALLED_APPS</cite> in <cite>settings.py</cite></li>
<li>Add the <cite>COMMENTS_APP</cite> attribute in <cite>settings.py</cite> and set the value to <cite>auth_comments</cite></li>
<li>Make sure that you have the following <cite>TEMPLATE_CONTEXT_PROCESSORS</cite> activated in your <cite>settings.py</cite>.</li>
</ul>
<div class="highlight"><pre><span></span><span class="n">TEMPLATE_CONTEXT_PROCESSORS</span><span class="o">=</span><span class="p">(</span>
<span class="s2">"django.core.context_processors.auth"</span><span class="p">,</span>
<span class="s2">"django.core.context_processors.request"</span><span class="p">,</span>
<span class="s2">"django.core.context_processors.media"</span>
<span class="p">)</span>
</pre></div>
<ul class="simple">
<li>Append the <cite>auth_comments/templates</cite> directory in the <cite>TEMPLATE_DIRS</cite> attribute of <cite>settings.py</cite></li>
<li>Activate the comment urls in your project's <cite>urls.py</cite></li>
</ul>
<div class="highlight"><pre><span></span><span class="p">(</span><span class="sa">r</span><span class="s1">'^comment/'</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="s1">'django.contrib.comments.urls'</span><span class="p">)),</span>
</pre></div>
<ul class="simple">
<li>In your templates, when you want to render the authenticated comment form, just use the following code.</li>
</ul>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">load</span> <span class="nv">auth_comments</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">...</span>
<span class="cp">{%</span> <span class="k">render_auth_comment_form</span> <span class="nv">for</span> <span class="nv">app.model</span> <span class="nv">object_pk</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
<p>This code is equivalent to</p>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">request.user.is_authenticated</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">render_comment_form</span> <span class="nv">for</span> <span class="nv">app.model</span> <span class="nv">object_pk</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> Some standard message to be shown if user not logged in.</span>
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
<p>The standard message is picked up from the <cite>DEFAULT_UNAUTH_COMMENT_MESSAGE</cite> attribute of <cite>settings.py</cite> which you can set to override the default message.</p>
<p>If you liked the app, do let me know. Also please fork and improve the code if you wish to improve it.</p>
</div>
Ouch!!! Do they really mean it?2009-07-16T08:43:33+00:002009-07-16T08:43:33+00:00Thejaswi Puthrayatag:thejaswi.info,2009-07-16:/photo/blog/2009/07/16/ouch-do-they-really-mean-it/<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/3724967883/"><img alt="Apollo Hospital Van" class="align-center" src="http://farm3.static.flickr.com/2657/3724967883_3fb2e9357f_m.jpg" /></a>
<p>I <strong>wish</strong> this isn't true!!!</p>
Google Chrome OS: Will David overcome Goliath?2009-07-10T21:26:38+00:002009-07-10T21:26:38+00:00Thejaswi Puthrayatag:thejaswi.info,2009-07-10:/tech/blog/2009/07/10/google-chrome-os-will-david-overcome-goliath/<p>A <a class="reference external" href="http://www.techcrunch.com/2009/07/07/google-drops-a-nuclear-bomb-on-microsoft-and-its-made-of-chrome/">lot</a> has been <a class="reference external" href="http://www.techcrunch.com/2008/09/01/meet-chrome-googles-windows-killer/">said</a> and <a class="reference external" href="http://www.techcrunch.com/2008/09/01/meet-chrome-googles-windows-killer/">written</a> about the <a class="reference external" href="http://googleblog.blogspot.com/2009/07/introducing-google-chrome-os.html">Google Chrome OS</a> even before it has released. Wow!!! Funnily, a majority of the commentators are touting it as a <strong>"Windows Killer"</strong>. Some are quite surprised by Google's decision to release an OS! I guess even an average computer user would …</p><p>A <a class="reference external" href="http://www.techcrunch.com/2009/07/07/google-drops-a-nuclear-bomb-on-microsoft-and-its-made-of-chrome/">lot</a> has been <a class="reference external" href="http://www.techcrunch.com/2008/09/01/meet-chrome-googles-windows-killer/">said</a> and <a class="reference external" href="http://www.techcrunch.com/2008/09/01/meet-chrome-googles-windows-killer/">written</a> about the <a class="reference external" href="http://googleblog.blogspot.com/2009/07/introducing-google-chrome-os.html">Google Chrome OS</a> even before it has released. Wow!!! Funnily, a majority of the commentators are touting it as a <strong>"Windows Killer"</strong>. Some are quite surprised by Google's decision to release an OS! I guess even an average computer user would have been predicting this for quite some time now.</p>
<p>My take is that in the longer run, Chrome OS might nibble into Windows' declining share but I doubt if it is going to get rid of Windows within the next decade as predicted by a handful of <em>"experts"</em>. Before you start waving your hand in disagreement, let me make my case.</p>
<p>I collected Microsoft's annual revenues and various analyst views on their forecasts on the topic and studied them. Most sounded fairly dismissive of a major impact to Microsoft's client business from Chrome OS.</p>
<p>Here are the annual revenues for your interpretation:</p>
<table border="1" class="docutils">
<colgroup>
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="4%" />
<col width="4%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
<col width="5%" />
</colgroup>
<tbody valign="top">
<tr><td colspan="7"><strong>Sales</strong></td>
<td colspan="7"><strong>Income</strong></td>
<td colspan="7"><strong>Operating Profit</strong></td>
</tr>
<tr><td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
<td>08</td>
<td>09</td>
<td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
<td>08</td>
<td>09</td>
<td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
<td>08</td>
<td>09</td>
</tr>
<tr><td>32187</td>
<td>36835</td>
<td>39788</td>
<td>44262</td>
<td>51122</td>
<td>60420</td>
<td>59838</td>
<td>7531</td>
<td>8168</td>
<td>12254</td>
<td>12599</td>
<td>14065</td>
<td>17681</td>
<td>15159</td>
<td>13353</td>
<td>14867</td>
<td>14561</td>
<td>16472</td>
<td>18524</td>
<td>22491</td>
<td>21013</td>
</tr>
</tbody>
</table>
<p>Two points to note from the above data are:</p>
<ul class="simple">
<li>Though the Client Business which accounts for only 25% of the Microsoft's profits seems to be slowly affected by other alternatives (like Linux), the revenue from this division is gradually increasing because of support revenue from enterprises.</li>
<li>The forecast for 2009 is very conservative and can be revised upwards if Windows 7 clicks.</li>
</ul>
<p>So if you are a Microsoft fanboy, you can assure yourself that the current situation isn't going to change overnight.</p>
<div class="section" id="why-does-google-want-to-diversify-from-search">
<h2>Why does Google want to diversify from search?</h2>
<p>That's a good question. I doubt if <a class="reference external" href="http://www.google.com/">Google</a> can monetize the Chrome OS but I believe in the long
term it gives access to the desktop should <a class="reference external" href="http://www.microsoft.com/">Microsoft</a>
tightly integrate <a class="reference external" href="http://www.bing.com/">Bing</a> into their OS. Their
aim would be for the ad-revenues obtained from accessing Google services. The move to diversify
away from the core business is quite risky and might not go down well with the investors.</p>
<p>Another point to note is timing of their announcement. I can think of two reasons why this is significant:</p>
<ul class="simple">
<li>With Windows 7 close to a release, I believe the folks at Mountain View are sending out a message to hardware vendors and OEMs to reconsider an alliance with Microsoft.</li>
<li>Diverting attention away from Bing, as it has been receiving rave reviews.</li>
</ul>
</div>
<div class="section" id="where-does-chrome-os-fit">
<h2>Where does Chrome OS fit?</h2>
<p>The segment where Chrome OS would have maximum impact
is ARM-powered netbooks. On the other hand, it would have the least penetration on the enterprise side.</p>
</div>
<div class="section" id="who-is-likely-to-migrate-to-chrome-os">
<h2>Who is likely to migrate to Chrome OS?</h2>
<ul class="simple">
<li>Netbook buyers towards end of 2010</li>
<li>Google fanboys. Oh boy!!! There are a lot of them</li>
<li>People who don't care about the UI of an OS. All they love using is <a class="reference external" href="http://www.facebook.com/">facebook</a> or <a class="reference external" href="http://www.twitter.com/">twitter</a>. These people wouldn't even care for the browser they use (and most sadly use IE6). They would be attracted to the low cost of the netbooks and might migrate.</li>
</ul>
</div>
<div class="section" id="who-s-not-going-to-migrate-to-chrome-os">
<h2>Who's not going to migrate to Chrome OS?</h2>
<ul class="simple">
<li>Enterprises.</li>
<li>People not comfortable with having their data on the cloud.</li>
<li>High-end users. These folks usually use Photoshop, Flash, Matlab etc.</li>
<li>Folks from countries where an internet connection is still not very usable.</li>
</ul>
</div>
<div class="section" id="my-time-for-a-prediction">
<h2>My time for a prediction</h2>
<p>Almost everyone's made one...why should I be left behind?</p>
<p>Chrome OS validates the Linux kernel hackers efforts of porting the OS to as many architectures as possible. Probably 2011 might be the so far elusive year of <strong>"The Linux Desktop"</strong>.</p>
<p>Chrome OS is going to have a limited impact in the desktop market too. Why live in the browser when <a class="reference external" href="http://en.wikipedia.org/wiki/Moore's_law">Moore's law</a> is at work? It might gain a 10% market share in 5 years and around 40% in the netbook market for the same period. I am projecting a high number in the netbook market because hardware vendors might release lots of ARM powered netbooks and Windows stands no chance in this segment.</p>
<p>So is Microsoft going to keep quite? Probably not, but they are definitely not going to panic. They have a large userbase and can adopt the <strong>"Wait and Watch"</strong> policy. If they believe Chrome OS will be a hit, they'll have a similar offering.</p>
<p>Surprisingly, not many people have talked about how Chrome OS affects either Apple or the Linux Desktop community.</p>
<p>I think there's something cooking in Apple. Lots of rumours are indicating they are probably designing a <a class="reference external" href="http://www.crunchgear.com/2009/04/30/apple-looking-at-building-its-own-chips/">chip</a> for a netbook or an MID? We'll have to wait for an announcement from Apple. The Linux community on the other hand wouldn't be adversely affected because Chrome OS gets added to the zillions of distributions and the users are most likely to be displaced from a few distros to Chrome. So it's bad news for some distros but good news for the Linux Desktop community as a whole.</p>
<p>Google has open-sourced the effort like Android but it has to been seen how transparent the process of making and deploying apps is. The community's reaction and marketing the concept to hardware vendors will be the key to Chrome OS' success.</p>
<p>Has to be seen if Windows ecosystem or Google's brand win eventually!</p>
</div>
Yet another redesign at thejaswi.info2009-07-08T09:16:22+00:002009-07-08T09:16:22+00:00Thejaswi Puthrayatag:thejaswi.info,2009-07-08:/tech/blog/2009/07/08/yet-another-redesign-at-thejaswiinfo/<p>Oh yes!!! You are seeing it right! There's been another redesign of my site.</p>
<p>Technology fascinates me and I cannot get enough of it. This time I wanted my blog powered by the latest and coolest technology. Want to know more?</p>
<p><a class="reference external" href="http://couchdb.apache.org/">CouchDB</a> powers the heart of the blogging engine as …</p><p>Oh yes!!! You are seeing it right! There's been another redesign of my site.</p>
<p>Technology fascinates me and I cannot get enough of it. This time I wanted my blog powered by the latest and coolest technology. Want to know more?</p>
<p><a class="reference external" href="http://couchdb.apache.org/">CouchDB</a> powers the heart of the blogging engine as opposed to an RDBMS. <a class="reference external" href="http://code.google.com/p/couchdb-python/">CouchDB-python</a> talks to the DB and the web app. How on earth could I have left my favourite framework out of this cool stuff! I make use of the <a class="reference external" href="http://www.djangoproject.com/">Django</a> templates and views for the presentation and logic.</p>
<p>CouchDB stores the posts, comments, authentication related data and session data. I have written custom auth and session backends in Django that store the data on the DB. The source has been released and is available <a class="reference external" href="http://github.com/theju/django-couchdb-utils/tree/master">here</a>.</p>
<p>The advantages of using couchDB:</p>
<ul class="simple">
<li>It scales tremendously. Suppose my blog readership touches a few million, all I would need to do is to add more couchDB nodes and voila it scales!!!</li>
<li>Since couchDB uses HTTP as the underlying protocol, it can be cached very easily using standard cache utilities like <a class="reference external" href="http://www.squid-cache.org/">Squid</a> and <a class="reference external" href="http://varnish.projects.linpro.no/">Varnish</a>.</li>
<li>It is schema-less. I could easily add/edit and remove fields from the DB without having to get frightened about it's integrity.</li>
</ul>
<p>The disadvantages of using couchDB:</p>
<ul class="simple">
<li>couchDB is growing fast and still does not have a few features (slated to be released soon) and the API is a moving target.</li>
<li>It can give you a few scares from time to time. I almost lost my data when I made a few cfg changes. After googling around, I figured out that the data was safe but couchDB would require a reinstall.</li>
</ul>
<p>Hope this time, the technology powering my blog is not obsoleted so fast ;-).</p>
<p>PS1: If you have come to the site from a previous bookmark, please update your bookmarks. I am sorry about breaking your results.</p>
<p>PS2: Some services on my blog are still missing, I promise to have them up at the earliest.</p>
<p>PS3: I am in the process of releasing the source code of the site. If you are one of the impatient folks, please ping me.</p>
Updates to safebrowsing-python2009-04-02T00:00:00+00:002009-04-02T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2009-04-02:/tech/blog/2009/04/02/updates-safebrowsing-python/<div class="section" id="id1">
<h2>Updates to Safebrowsing-python</h2>
<p>Two days back, I made quite big changes to <a class="reference external" href="http://code.google.com/p/safebrowsing-python/">safebrowsing-python</a>,
the python library for looking up blacklisted URLs against Google's
updated phishing and malware database.</p>
<p>The changes are:</p>
<ul class="simple">
<li>Added support for databases like Mysql, Postgresql. Previously,
SQLite was the only supported database.</li>
<li>It is quite easy to …</li></ul></div><div class="section" id="id1">
<h2>Updates to Safebrowsing-python</h2>
<p>Two days back, I made quite big changes to <a class="reference external" href="http://code.google.com/p/safebrowsing-python/">safebrowsing-python</a>,
the python library for looking up blacklisted URLs against Google's
updated phishing and malware database.</p>
<p>The changes are:</p>
<ul class="simple">
<li>Added support for databases like Mysql, Postgresql. Previously,
SQLite was the only supported database.</li>
<li>It is quite easy to switch from one database to another. Just
edit the conf.py file under safebrowsing folder and you are done.</li>
<li>As per the HTTP 1.1 RFC, URL fields accept 2048 characters by
default.</li>
</ul>
<p>To check how to use it, visit <a class="reference external" href="http://code.google.com/p/safebrowsing-python/wiki/Usage">this</a>.</p>
<p>I want to thank all the <a class="reference external" href="http://code.google.com/p/safebrowsing-python/source/browse/trunk/CONTRIBUTORS.txt">contributors</a> for their invaluable bug-patches
and suggestions.</p>
</div>
Losing nature to globalization!!!2009-03-25T21:44:00+00:002009-03-25T21:44:00+00:00Thejaswi Puthrayatag:thejaswi.info,2009-03-25:/photo/blog/2009/03/25/losing-nature-to-globalization/<a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/3701731818/"><img alt="Vasavi College bus stop" class="align-center" src="http://farm3.static.flickr.com/2441/3701731818_28c413ae52_m.jpg" /></a>
<p>The bus stop outside Vasavi College of Engineering (my college) after a massive road-widening. I wonder why this area needed a road-widening? The green cover on both sides of the road was cleared.</p>
<p><em>Trivia:</em> A scene from the Telugu super-hit movie <a class="reference external" href="http://www.imdb.com/title/tt1214961/">Happy Days</a> was picturized here. Sadly such things cannot …</p><a class="reference external image-reference" href="http://www.flickr.com/photos/puthraya/3701731818/"><img alt="Vasavi College bus stop" class="align-center" src="http://farm3.static.flickr.com/2441/3701731818_28c413ae52_m.jpg" /></a>
<p>The bus stop outside Vasavi College of Engineering (my college) after a massive road-widening. I wonder why this area needed a road-widening? The green cover on both sides of the road was cleared.</p>
<p><em>Trivia:</em> A scene from the Telugu super-hit movie <a class="reference external" href="http://www.imdb.com/title/tt1214961/">Happy Days</a> was picturized here. Sadly such things cannot happen here after.</p>
Django 1.1 beta released2009-03-24T00:00:00+00:002009-03-24T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2009-03-24:/tech/blog/2009/03/24/django-11-beta-released/<div class="section" id="django-beta-1-1-ship1-released">
<h2>Django Beta 1.1 (ship1) released</h2>
<p>Though slightly behind schedule, Django 1.1 beta was released yesterday.
It offers a lot of new features compared to the last stable release 1.0.
A few of the notable ones are:</p>
<ul class="simple">
<li>Model Aggregation</li>
<li>Query Expressions</li>
<li>Fast Tests</li>
<li>Unmananaged & Proxy Models</li>
<li>Deferred Fields …</li></ul></div><div class="section" id="django-beta-1-1-ship1-released">
<h2>Django Beta 1.1 (ship1) released</h2>
<p>Though slightly behind schedule, Django 1.1 beta was released yesterday.
It offers a lot of new features compared to the last stable release 1.0.
A few of the notable ones are:</p>
<ul class="simple">
<li>Model Aggregation</li>
<li>Query Expressions</li>
<li>Fast Tests</li>
<li>Unmananaged & Proxy Models</li>
<li>Deferred Fields</li>
<li>Batch functionality in Admin (like bulk edit etc)</li>
<li>Host of CSRF related changes</li>
</ul>
<p>The two changes that I was personally interested in were:</p>
<ul class="simple">
<li>Extensibililty of the comments framework</li>
<li>Integration of Comment-utils</li>
</ul>
<p>I would like to thank <a class="reference external" href="http://jacobian.org/">Jacob Kaplan-Moss</a>, <a class="reference external" href="http://leidel.info/">Jannis Leidel</a>, Carl JM,
<a class="reference external" href="http://www.b-list.org/">James Bennett</a> and all others involved for the previous two changes.</p>
<p>A special thanks to <a class="reference external" href="http://www.pointy-stick.com/blog/">Malcolm Tredinnick</a>, <a class="reference external" href="http://cecinestpasun.com/">Russell Keith-Magee</a> and
others for the huge improvements to the ORM.</p>
<p>My thanks also goes to <a class="reference external" href="http://www.holovaty.com/">Adrian Holovaty</a> for releasing <a class="reference external" href="http://www.djangobook.com/en/2.0/">Django Book 2.0</a>
to the community.</p>
<p>I would make a big mistake if I forget to thank the wonderful <a class="reference external" href="http://www.djangoproject.com/">Django</a>
community that uses, supports and contributes to the wonderful
project. Thanks guys.</p>
<p>Django Project rocks!!!</p>
</div>
(Hopefully) Storm after lull2009-03-23T00:00:00+00:002009-03-23T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2009-03-23:/personal/blog/2009/03/23/hopefully-storm-after-lull/<div class="section" id="id1">
<h2>(Hopefully) Storm after lull</h2>
<p>I have been very silent on the blogging front for over
three months. I attribute it to two reasons:</p>
<ul class="simple">
<li>Work</li>
<li>My inability to rise early or stay late :(</li>
</ul>
<p>Since changing schedule at work is out of the question,
I have decided to rise early and blog …</p></div><div class="section" id="id1">
<h2>(Hopefully) Storm after lull</h2>
<p>I have been very silent on the blogging front for over
three months. I attribute it to two reasons:</p>
<ul class="simple">
<li>Work</li>
<li>My inability to rise early or stay late :(</li>
</ul>
<p>Since changing schedule at work is out of the question,
I have decided to rise early and blog. It is not a big
motivation, but there's a lot that I have learnt in the
past few months and I have been dying to share them with
all of you. Not just code or software but also a lot of
updates on the personal front.</p>
<p>So wishing myself luck with my endeavour of regaining my
early rising habits...</p>
</div>
Yet another threaded comments app2009-01-10T00:00:00+00:002009-01-10T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2009-01-10:/tech/blog/2009/01/10/yet-another-threaded-comments-app/<div class="section" id="a-reusable-threaded-comments-app">
<h2>A reusable threaded comments app</h2>
<p>This week I am releasing code for yet another reusable app and yet
another threaded-comments app. There are quite a few threaded comment
apps around but the best one being <a class="reference external" href="http://code.google.com/p/django-threadedcomments/">this</a> by <a class="reference external" href="http://www.eflorenzano.com/">Eric Florenzano</a>.</p>
<p>The motive of releasing this code is not to compete with …</p></div><div class="section" id="a-reusable-threaded-comments-app">
<h2>A reusable threaded comments app</h2>
<p>This week I am releasing code for yet another reusable app and yet
another threaded-comments app. There are quite a few threaded comment
apps around but the best one being <a class="reference external" href="http://code.google.com/p/django-threadedcomments/">this</a> by <a class="reference external" href="http://www.eflorenzano.com/">Eric Florenzano</a>.</p>
<p>The motive of releasing this code is not to compete with any of the
apps available but as a proof of how portable django and it's apps
(here I am referring to the comments app, but the statement holds
true for most third-party apps) can be.</p>
<p>Probably with some work this app should be as good as other apps.</p>
<div class="section" id="procedure-to-use-it">
<h3>Procedure to use it</h3>
<blockquote>
<ul>
<li><p class="first">Download the source from <a class="reference external" href="http://github.com/theju/django-comments-apps/tree/master">here</a> and place the <cite>threaded_comments</cite>
app in your django project.</p>
</li>
<li><p class="first">Patch your django source with the latest patch from <a class="reference external" href="http://code.djangoproject.com/ticket/8630">#8630</a>.</p>
</li>
<li><p class="first">Add the following attributes in the <cite>settings.py</cite>.</p>
<div class="highlight"><pre><span></span><span class="n">COMMENTS_APP</span> <span class="o">=</span> <span class="s2">"threaded_comments"</span>
</pre></div>
</li>
<li><p class="first">Make use of the new comment tags that are available to help with
the threaded support. Here's an example template:</p>
<div class="highlight"><pre><span></span> {% extends "test_app/base.html" %}
{% block head %}
<span class="p"><</span><span class="nt">script</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/javascript"</span><span class="p">></span>
<span class="kd">function</span> <span class="nx">showCommentForm</span><span class="p">(</span><span class="nx">id</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">commentForm</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'commentForm'</span><span class="o">+</span><span class="nx">id</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">linkHolder</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'linkReply'</span><span class="o">+</span><span class="nx">id</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">commentForm</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">display</span> <span class="o">==</span> <span class="s2">"none"</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">commentForm</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">"block"</span><span class="p">;</span>
<span class="nx">linkHolder</span><span class="p">.</span><span class="nx">innerHTML</span><span class="o">=</span><span class="s2">"Hide Reply"</span><span class="p">;</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">commentForm</span><span class="p">.</span><span class="nx">style</span><span class="p">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">"none"</span><span class="p">;</span>
<span class="nx">linkHolder</span><span class="p">.</span><span class="nx">innerHTML</span><span class="o">=</span><span class="s2">"Reply"</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p"></</span><span class="nt">script</span><span class="p">></span>
{% endblock %}
{% block content %}
{% load threaded_comments %}
{% get_comment_list for app.model object.pk as comment_list order_by thread %}
{# To order comments by date use order_by date #}
{% if comment_list %}
<span class="p"><</span><span class="nt">h2</span><span class="p">></span>Comments<span class="p"></</span><span class="nt">h2</span><span class="p">></span>
{% for comment in comment_list %}
<span class="p"><</span><span class="nt">div</span> <span class="na">id</span><span class="o">=</span><span class="s">"c{{ comment.id }}"</span> <span class="na">style</span><span class="o">=</span><span class="s">"margin-left: {{ comment.level }}0px;"</span><span class="p">></span>
<span class="p"><</span><span class="nt">h4</span><span class="p">></span>{{ comment.name|escape }}
{% if comment.parent %}
in reply to
<span class="p"><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"#c{{ comment.parent_id }}"</span><span class="p">></span>{{ comment.parent_id }}<span class="p"></</span><span class="nt">a</span><span class="p">></span>
{% endif %}
at {{ comment.submit_date|date:"r"}}<span class="p"></</span><span class="nt">h4</span><span class="p">></span>
<span class="p"><</span><span class="nt">p</span><span class="p">></span>{{ comment.comment|escape|urlizetrunc:"100"|linebreaks }}<span class="p"></</span><span class="nt">p</span><span class="p">></span>
<span class="p"><</span><span class="nt">p</span><span class="p">><</span><span class="nt">a</span> <span class="na">id</span><span class="o">=</span><span class="s">"linkReply{{ comment.id }}"</span> <span class="na">href</span><span class="o">=</span><span class="s">"#"</span>
<span class="na">onclick</span><span class="o">=</span><span class="s">"showCommentForm({{ comment.id }});"</span><span class="p">></span>Reply<span class="p"></</span><span class="nt">a</span><span class="p">></</span><span class="nt">p</span><span class="p">></span>
<span class="p"><</span><span class="nt">div</span> <span class="na">id</span><span class="o">=</span><span class="s">"commentForm{{ comment.id }}"</span> <span class="na">style</span><span class="o">=</span><span class="s">"display: none"</span><span class="p">></span>
<span class="p"><</span><span class="nt">h4</span><span class="p">></span>Reply to the above comment ({{ comment.id }})<span class="p"></</span><span class="nt">h4</span><span class="p">></span>
{% render_comment_form for app.model object.pk with comment.id %}
{# Alternatively use #}
{# {% get_comment_form for app.model object.pk as form with parent_id %} #}
<span class="p"></</span><span class="nt">div</span><span class="p">></span>
<span class="p"></</span><span class="nt">div</span><span class="p">></span>
<span class="p"><</span><span class="nt">hr</span><span class="p">></span>
{% endfor %}
{% endif %}
<span class="p"><</span><span class="nt">h2</span><span class="p">></span>Leave a comment<span class="p"></</span><span class="nt">h2</span><span class="p">></span>
{% render_comment_form for app.model object.pk %}
{% endblock %}
</pre></div>
</li>
<li><p class="first">Most of the code is unchanged except for the comment tags which now take
additional arguments and some optional javascript.</p>
</li>
</ul>
</blockquote>
<p>As mentioned in my <a class="reference external" href="http://thejaswi.info/blog/2009/01/03/reusable-recaptcha-comments-app/">previous post</a>, the toughest decision is to patch
<a class="reference external" href="http://www.djangoproject.com/">Django</a> because people don't like to pollute their code bases (don't even
ask about organizations, they get hysterical when you want to patch any
code base).</p>
<p>Please let me know how you find this app and suggest ways to make it DRYer
and better.</p>
</div>
</div>
Reusable recaptcha comments app2009-01-03T00:00:00+00:002009-01-03T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2009-01-03:/tech/blog/2009/01/03/reusable-recaptcha-comments-app/<div class="section" id="id1">
<h2>Reusable recaptcha comments app</h2>
<p>One aim of <a class="reference external" href="http://www.jacobian.org/">Jacob's</a> code for the comments framework in <a class="reference external" href="http://www.djangoproject.com/">Django</a> 1.0
was to make it as extensible as possible. At the same time
this process should be quite generic and as <a class="reference external" href="http://en.wikipedia.org/wiki/Don't_repeat_yourself">DRY</a> as possible.</p>
<p>It is here that I worked for a very long …</p></div><div class="section" id="id1">
<h2>Reusable recaptcha comments app</h2>
<p>One aim of <a class="reference external" href="http://www.jacobian.org/">Jacob's</a> code for the comments framework in <a class="reference external" href="http://www.djangoproject.com/">Django</a> 1.0
was to make it as extensible as possible. At the same time
this process should be quite generic and as <a class="reference external" href="http://en.wikipedia.org/wiki/Don't_repeat_yourself">DRY</a> as possible.</p>
<p>It is here that I worked for a very long time but in last minute
goof-ups could not push these changes to be included in 1.0.</p>
<p>Well anyways, I opened a <a class="reference external" href="http://code.djangoproject.com/ticket/8630">ticket</a> quick enough so that this feature didn't
fade off with time. I attached an initial patch and soon there was a lot
of activity and within no time people contributed tests and docs for the
patches. I want to thank all those people who contributed or are interested
in the ticket. Luckily this ticket will be in trunk by 1.1 championed by
Jacob himself (See <a class="reference external" href="http://code.djangoproject.com/wiki/Version1.1Roadmap">roadmap</a>).</p>
<p>So in this blog post I announce a reusable app called <a class="reference external" href="http://github.com/theju/django-comments-apps/tree/master">recaptcha-django-comments</a>
It is a very simple app that appends a <a class="reference external" href="http://recaptcha.net/">Recaptcha</a> field to the comment form.</p>
<div class="section" id="procedure-to-use-it">
<h3>Procedure to use it</h3>
<blockquote>
<ul>
<li><p class="first">Fetch the source from <a class="reference external" href="http://github.com/theju/django-comments-apps/tree/master">here</a> and place the <cite>recaptcha_comments</cite> app
in your django project.</p>
</li>
<li><p class="first">Patch your django source with the latest patch from <a class="reference external" href="http://code.djangoproject.com/ticket/8630">#8630</a>.</p>
</li>
<li><p class="first">Update the <cite>INSTALLED_APPS</cite> in the <cite>settings.py</cite> to reflect this app.</p>
</li>
<li><p class="first">Add the following attributes in the <cite>settings.py</cite>.</p>
<blockquote>
<div class="highlight"><pre><span></span><span class="n">COMMENTS_APP</span> <span class="o">=</span> <span class="s2">"recaptcha_comments"</span>
<span class="n">RECAPTCHA_PUBLIC_KEY</span> <span class="o">=</span> <span class="s2">"xyz....."</span>
<span class="n">RECAPTCHA_PRIVATE_KEY</span> <span class="o">=</span> <span class="s2">"abc...."</span>
</pre></div>
</blockquote>
</li>
<li><p class="first">Add the <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/middleware/#reverse-proxy-middleware">following</a> middleware to the <cite>settings.py</cite>. It will help pass on
the IP Address to recaptcha if you are behind a reverse proxy. This
step is not required if you are not behind a reverse proxy.</p>
<blockquote>
<div class="highlight"><pre><span></span><span class="n">MIDDLEWARE_CLASSES</span><span class="o">=</span> <span class="p">(</span><span class="s1">'...'</span><span class="p">,</span>
<span class="s1">'django.middleware.http.SetRemoteAddrFromForwardedFor'</span><span class="p">,</span>
<span class="p">)</span>
</pre></div>
</blockquote>
</li>
<li><p class="first">Copy the <cite>comments/</cite> directory from <cite>recaptcha_comments/templates</cite>
into your <cite>templates</cite> directory as referenced by your <cite>settings.py</cite>.</p>
</li>
<li><p class="first">Edit the project's <cite>urls.py</cite> to have the following line.</p>
<blockquote>
<div class="highlight"><pre><span></span><span class="p">(</span><span class="sa">r</span><span class="s1">'^comments/'</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="s1">'recaptcha_comments.urls'</span><span class="p">)),</span>
</pre></div>
</blockquote>
</li>
</ul>
</blockquote>
<p>That's it!!!</p>
<p>Well, the toughest part in the procedure is to patch the django source
(by difficult I mean the decision to patch django).</p>
<p>Please let me know your opinions about this app.</p>
<p>Stay tuned for more and oops I forgot...**HAPPY NEW YEAR**!!!</p>
</div>
</div>
Split a large CSV into smaller CSVs2008-12-29T00:00:00+00:002008-12-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-12-29:/tech/blog/2008/12/29/split-large-csv-smaller-csvs/<div class="section" id="split-a-large-csv-file-into-smaller-csvs">
<h2>Split a large CSV file into smaller CSVs</h2>
<p>At work, we sometimes have to deal with huge CSV files and it is difficult
to open these files in memory because there is a limit of the buffer size.</p>
<p>So the best way would be to split the file into smaller …</p></div><div class="section" id="split-a-large-csv-file-into-smaller-csvs">
<h2>Split a large CSV file into smaller CSVs</h2>
<p>At work, we sometimes have to deal with huge CSV files and it is difficult
to open these files in memory because there is a limit of the buffer size.</p>
<p>So the best way would be to split the file into smaller chunks so that they
can be easily read.</p>
<p>So here is the bash script that does the job (split_csv):</p>
<div class="highlight"><pre><span></span><span class="ch">#!/bin/bash</span>
<span class="nv">num_lines</span><span class="o">=</span><span class="nv">$1</span>
<span class="nv">num_digits</span><span class="o">=</span><span class="nv">$2</span>
<span class="nv">input_file</span><span class="o">=</span><span class="nv">$3</span>
<span class="nv">output_pattern</span><span class="o">=</span><span class="nv">$4</span>
split -d -l <span class="nv">$num_lines</span> -a <span class="nv">$num_digits</span> <span class="nv">$input_file</span> <span class="nv">$output_pattern</span>
<span class="nv">i</span><span class="o">=</span><span class="m">0</span>
<span class="k">while</span> <span class="o">[</span> <span class="nv">$i</span> -lt <span class="nv">$num_digits</span> <span class="o">]</span>
<span class="k">do</span>
<span class="k">if</span> <span class="o">[</span> <span class="nv">$i</span> -eq <span class="m">0</span> <span class="o">]</span>
<span class="k">then</span>
<span class="nv">idx</span><span class="o">=</span><span class="m">0</span>
<span class="k">else</span>
<span class="nv">idx</span><span class="o">=</span><span class="s2">"0</span><span class="nv">$idx</span><span class="s2">"</span>
<span class="k">fi</span>
<span class="nv">i</span><span class="o">=</span><span class="k">$((</span> i+1 <span class="k">))</span>
<span class="k">done</span>
<span class="nv">first_file</span><span class="o">=</span><span class="s2">"</span><span class="nv">$output_pattern$idx</span><span class="s2">"</span>
<span class="nv">header</span><span class="o">=</span><span class="sb">`</span>head -1 <span class="nv">$first_file</span><span class="sb">`</span>
<span class="k">for</span> i in <span class="k">$(</span> ls <span class="nv">$output_pattern</span>* <span class="k">)</span>
<span class="k">do</span>
<span class="k">if</span> <span class="o">[</span> <span class="s2">"</span><span class="nv">$i</span><span class="s2">"</span> !<span class="o">=</span> <span class="s2">"</span><span class="nv">$first_file</span><span class="s2">"</span> <span class="o">]</span>
<span class="k">then</span>
<span class="nb">echo</span> <span class="nv">$header</span> <span class="p">|</span> cat - <span class="nv">$i</span> > temp_file
mv temp_file <span class="nv">$i</span>
rm -rf temp_file
<span class="k">fi</span>
<span class="k">done</span>
</pre></div>
<p>A simple usage would be:</p>
<div class="highlight"><pre><span></span>split_csv <span class="m">10000</span> <span class="m">3</span> input.csv test-
</pre></div>
<p>The usage is similar to that of the <cite>split</cite> utility.</p>
</div>
Install Fedora from a USB disk without a DVD2008-12-26T00:00:00+00:002008-12-26T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-12-26:/tech/blog/2008/12/26/install-fedora-usb-disk-without-dvd/<div class="section" id="id1">
<h2>Install Fedora from a USB disk without a DVD</h2>
<p><a class="reference external" href="http://www.fedoraproject.org/">Fedora</a> has a release schedule of 6 months ie they release a new
version every 6 months. 6 months is too short but there are a lot
of new features that are packed into every release that it makes
it very …</p></div><div class="section" id="id1">
<h2>Install Fedora from a USB disk without a DVD</h2>
<p><a class="reference external" href="http://www.fedoraproject.org/">Fedora</a> has a release schedule of 6 months ie they release a new
version every 6 months. 6 months is too short but there are a lot
of new features that are packed into every release that it makes
it very tempting to upgrade or re-install the new version.</p>
<p>Till recently I used to burn the ISO images that I downloaded from
the torrents onto a DVD and install. After that the DVD was virtually
useless. I tried using DVD-RWs but I felt that it was a waste of
time especially when cheap high-capacity USB disks are easily
available.</p>
<p>I searched around for a solution and found a promising <a class="reference external" href="http://forums.fedoraforum.org/showthread.php?t=205596">post</a>
on the <a class="reference external" href="http://www.fedoraforum.org/">Fedora Forum</a>.</p>
<p>I am writing it for my personal archival reasons but if you find it
useful please send a thanks mail to the poster (sideways).</p>
<p>The solution works if you are using Fedora only but shouldn't be
difficult to tailor for other distros.</p>
<p>First install the livecd-tools package that gives us the ability
to create custom livecds from the images.</p>
<div class="highlight"><pre><span></span><span class="c1"># yum install livecd-tools</span>
</pre></div>
<p>Then you mount the Fedora ISO image that you downloaded onto a
directory and copy the <cite>boot.iso</cite> to your USB disk. Remember to
keep your USB disk in an unmounted state.</p>
<div class="highlight"><pre><span></span><span class="c1"># mkdir /mnt/iso</span>
<span class="c1"># mount -o loop <path to>/Fedora-10-i386-DVD/Fedora-10-i386-DVD.iso /mnt/iso</span>
<span class="c1"># livecd-iso-to-disk /mnt/iso/images/boot.iso /dev/sdb1</span>
</pre></div>
<p>Mark your USB disk as bootable.</p>
<div class="highlight"><pre><span></span><span class="c1"># /sbin/parted /dev/sdb</span>
<span class="o">(</span>parted<span class="o">)</span> toggle <span class="m">1</span> boot
<span class="o">(</span>parted<span class="o">)</span> quit
</pre></div>
<p>Next mount your USB disk and copy the <cite>install.img</cite> file to
your USB disk.</p>
<div class="highlight"><pre><span></span><span class="c1"># mkdir /media/<usb disk>/images</span>
<span class="c1"># cp /mnt/iso/images/install.img /media/<usb disk>/images/</span>
<span class="c1"># cp <path to>/Fedora-10-i386-DVD/Fedora-10-i386-DVD.iso /media/<usb disk>/</span>
</pre></div>
<p>That's it...just boot off your USB disk (older motherboards might not support
this feature). When you are asked for the location of the installation files
point to <em>Hard-disk</em> and then to your USB disk.</p>
<p>Voila...you can easily install off the USB disk. No need to waste a DVD
and you can do your bit for the environment by reducing garbage.</p>
<p>All credits go to <em>Sideways</em> for this fantastic method.</p>
</div>
Handle ACPI events in Linux2008-12-25T00:00:00+00:002008-12-25T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-12-25:/tech/blog/2008/12/25/handle-acpi-events-linux/<div class="section" id="id1">
<h2>Handle ACPI Events in Linux</h2>
<p>Off late, I have been working totally in runlevel 3 to replicate
the setup and feel at work. The only grudge I have with runlevel
3 is that there is no easy way to figure out the battery level
of the laptop.</p>
<p>So I googled …</p></div><div class="section" id="id1">
<h2>Handle ACPI Events in Linux</h2>
<p>Off late, I have been working totally in runlevel 3 to replicate
the setup and feel at work. The only grudge I have with runlevel
3 is that there is no easy way to figure out the battery level
of the laptop.</p>
<p>So I googled around and realized that <a class="reference external" href="http://www.acpi.info/">ACPI</a> was the answer to my
question.</p>
<p>To figure out all the statistics that are related to ACPI,
<cite>/proc/acpi</cite> is the place to head.</p>
<p>So to check the battery power level all one has to do is read the
<cite>/proc/acpi/battery/BAT0/state</cite> file and it gives all the necessary
statistics.</p>
<p>Later I realized that it would be wonderful if I was able to handle
events like <cite>battery fully charged</cite>, <cite>battery level low</cite>,
<cite>laptop lid closed</cite> etc. This too is handled by ACPI.</p>
<p>I dug around this topic deeper and could not come up with a decent
solution. Some suggested looking around the ACPI kernel module. I
tried this but could not get it to work.</p>
<p>Then I read about the <cite>acpid</cite> daemon that runs in userspace and
listens to various ACPI events and runs user-defined scripts when
a particular ACPI event is triggered. The man page for acpid is really
helpful and gives all the required info on events and how to handle
them.</p>
<p>Here is an example script that I use to trigger events when the
battery is fully charged and when the battery level reaches the
pre-defined alarm level.</p>
<p>In <cite>/etc/acpi/actions/</cite></p>
<div class="highlight"><pre><span></span><span class="ch">#!/bin/sh</span>
<span class="c1"># /etc/acpi/actions/battery.sh</span>
<span class="nv">PATH</span><span class="o">=</span>/sbin:/bin:/usr/bin:/usr/local/bin
<span class="nv">alarm_level</span><span class="o">=</span><span class="sb">`</span>cat /proc/acpi/battery/BAT0/alarm <span class="p">|</span>awk <span class="s1">'/^alarm/ { print $2 }'</span><span class="sb">`</span>
<span class="nv">remaining_capacity</span><span class="o">=</span><span class="sb">`</span>cat /proc/acpi/battery/BAT0/state<span class="p">|</span>awk <span class="s1">'/^remaining/ { print $3 }'</span><span class="sb">`</span>
<span class="nv">last_full_capacity</span><span class="o">=</span><span class="sb">`</span>cat /proc/acpi/battery/BAT0/info<span class="p">|</span>awk <span class="s1">'/^last/ { print $4 }'</span><span class="sb">`</span>
<span class="k">if</span> <span class="o">[</span> <span class="nv">$remaining_capacity</span> -eq <span class="nv">$alarm_level</span> <span class="o">]</span>
<span class="k">then</span>
<span class="c1"># Send an email</span>
<span class="c1"># or play a tone or do whatever</span>
mplayer /home/theju/tones/battery_low.ogg
<span class="k">fi</span>
<span class="k">if</span> <span class="o">[</span> <span class="nv">$remaining_capacity</span> -eq <span class="nv">$last_full_capacity</span> <span class="o">]</span>
<span class="k">then</span>
mplayer /home/theju/fully_charged.ogg
<span class="k">fi</span>
</pre></div>
<p>In <cite>/etc/acpi/events/battery.conf</cite></p>
<div class="highlight"><pre><span></span><span class="nv">event</span><span class="o">=</span>battery/*
<span class="nv">action</span><span class="o">=</span>/etc/acpi/actions/battery.sh
</pre></div>
<p>For Thinkpad owners, there is a very good wiki article on <a class="reference external" href="http://www.thinkwiki.org/">Thinkwiki</a> that also gives
various other <a class="reference external" href="http://www.thinkwiki.org/wiki/Category:Scripts">things</a> you could do with ACPI.</p>
</div>
6 months with Citigroup2008-12-02T00:00:00+00:002008-12-02T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-12-02:/personal/blog/2008/12/02/6-months-citigroup/<div class="section" id="id1">
<h2>6 months with Citigroup</h2>
<p>With today, I will be completing 6 months with <a class="reference external" href="http://en.wikipedia.org/wiki/Citigroup">Citigroup</a>. Here are my observations
like in my <a class="reference external" href="/blog/2008/12/01/6-months-chennai/">previous</a> post:</p>
<blockquote>
<ul>
<li><p class="first">I really love work, it is challenging and I get to work in something
that I am passionate about.</p>
</li>
<li><p class="first">Love working with the fantastic team and awesome …</p></li></ul></blockquote></div><div class="section" id="id1">
<h2>6 months with Citigroup</h2>
<p>With today, I will be completing 6 months with <a class="reference external" href="http://en.wikipedia.org/wiki/Citigroup">Citigroup</a>. Here are my observations
like in my <a class="reference external" href="/blog/2008/12/01/6-months-chennai/">previous</a> post:</p>
<blockquote>
<ul>
<li><p class="first">I really love work, it is challenging and I get to work in something
that I am passionate about.</p>
</li>
<li><p class="first">Love working with the fantastic team and awesome manager that I have.
The team members have varied skill-sets yet work closely and have a great
sense of humour. They are all willing to share and learn.</p>
</li>
<li><p class="first">Learnt a little about programming, best practices, financial concepts etc.</p>
</li>
<li><p class="first">I have got questions from friends and relatives on why I still am working
with a financial services company that's been in the news almost every
other day. Here's my answer:</p>
<p><em>"This is the best time to work for a financial services company because
it would be tough and very challenging. Since the pressure is on the
company and it's employees, it gets the best out of everyone."</em></p>
</li>
</ul>
</blockquote>
</div>
6 months in Chennai2008-12-01T00:00:00+00:002008-12-01T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-12-01:/personal/blog/2008/12/01/6-months-chennai/<div class="section" id="id1">
<h2>6 months in Chennai</h2>
<p>With today, I will be completing 6 months in <a class="reference external" href="http://en.wikipedia.org/wiki/Chennai">Chennai</a>. I came to Chennai to
join my first job after college and here are few one-liners to recap this
period:</p>
<blockquote>
<ul class="simple">
<li>I really hate the coastal weather where you sweat at any and
every point of the …</li></ul></blockquote></div><div class="section" id="id1">
<h2>6 months in Chennai</h2>
<p>With today, I will be completing 6 months in <a class="reference external" href="http://en.wikipedia.org/wiki/Chennai">Chennai</a>. I came to Chennai to
join my first job after college and here are few one-liners to recap this
period:</p>
<blockquote>
<ul class="simple">
<li>I really hate the coastal weather where you sweat at any and
every point of the day. I don't mind warm weather but sweat really
drains me.</li>
<li>Haven't seen places in and around Chennai, blame it on my workaholism ;-)</li>
<li>Being a veggie is tough here and I have learnt to cook.</li>
<li>People who have lived most of their lives elsewhere wouldn't find
Chennai enjoyable but it isn't bad. It has it's shares of pros and
cons.</li>
<li>Learnt to speak some <a class="reference external" href="http://en.wikipedia.org/wiki/Tamil">Tamil</a> and watched a few Tamil movies.</li>
<li>Have escaped most of the weekends to <a class="reference external" href="http://en.wikipedia.org/wiki/Hyderabad">Hyderabad</a> to spend time with
my parents.</li>
<li>Living alone is quite depressing...it slowly drives you to stay at
workplace for longer which leaves a good impression on your manager :)</li>
<li>Missing parents and Hyderabad a lot but am also enjoying work immensely.</li>
</ul>
</blockquote>
</div>
Shocked by the terror strikes in Mumbai2008-11-29T00:00:00+00:002008-11-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-11-29:/personal/blog/2008/11/29/shocked-terror-strikes-mumbai/<div class="section" id="id1">
<h2>Shocked by the terror strikes in Mumbai</h2>
<p>It's been a harrowing 60 odd hours for the Mumbaikars and they have shown great
resilience through this period. Now that the operation of neutralizing the
terrorists is officially over, the finger-pointing by politicians will soon
start.</p>
<p>We are tired off this, every …</p></div><div class="section" id="id1">
<h2>Shocked by the terror strikes in Mumbai</h2>
<p>It's been a harrowing 60 odd hours for the Mumbaikars and they have shown great
resilience through this period. Now that the operation of neutralizing the
terrorists is officially over, the finger-pointing by politicians will soon
start.</p>
<p>We are tired off this, every political party has already done a lot of this
and this futile exercise hasn't benefitted either them or the common man.
For God's sake, please stop treating us as <strong>vote banks</strong> and listen to our
real needs and problems.</p>
<p>So who owns up for the failure to avert this attack? Oh, as the home minister
clearly mentioned a day after the attack that it was an "intelligence failure".
Doesn't he head the intelligence department, so isn't he responsible? And he
can't keep escaping all the time with the same lame excuse. He has got to own up
and resign. He has shamed all Indians across the globe and if he has
any respect for democracy and people's opinions he should put in his papers
immediately. He is already guilty of too many lapses during his tenure and this
can't go on further!!!</p>
<p>Mr. Inept Home Minister, you haven't become a minister by contesting an election
but by getting yourself nominated in the Rajya Sabha. Try contesting an election
in any of the cities where the attacks took place and you will not even be
able to hold your deposit.</p>
<p>I really would like to thank all Indians for staying together throughout this
whole tragedy and not giving this event communal colours.</p>
<p>My sincere congratulations to the armed forces and the police for handling this
situation professionally and my heart goes out to all the casualities on their
side. Their sacrifices will not go in vain, they are martyrs and shall be
remembered forever.</p>
<p>I also want to condole the death of civilians, Indians and foreigners alike.</p>
<p>We have got to show the terrorists that we will get back to our lives as soon
as possible and make progress on all fronts. We are not cowards and will show
them what we are!!!</p>
<p>Jai Hind.</p>
<p><strong>Update:</strong> As mentioned there was enough mudslinging and heads have rolled,
Shivraj Patil has resigned. Though I loathe BJP and it's ideologies, I concur
with them that Shivraj Patil's action is <strong>"too little and too late.</strong> And what
more can you expect from political parties that are already in election-mode.</p>
</div>
Another Method: Comments for Authenticated Users2008-11-21T00:00:00+00:002008-11-21T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-11-21:/tech/blog/2008/11/21/another-method-comments-authenticated-users/<div class="section" id="id1">
<h2>Another Method: Comments for Authenticated Users</h2>
<p>In my <a class="reference external" href="/blog/2008/11/20/part-2-django-comments-authenticated-users/">previous post</a>, I got a <a class="reference external" href="http://thejaswi.info/blog/2008/11/20/part-2-django-comments-authenticated-users/#c11">comment</a> from <a class="reference external" href="http://www.worksology.com/">Joshua Works</a> who gave an
interesting suggestion of not constructing fields for the name, email and
url in the form as opposed to my method of using javascript to populate
them. Each method has it's …</p></div><div class="section" id="id1">
<h2>Another Method: Comments for Authenticated Users</h2>
<p>In my <a class="reference external" href="/blog/2008/11/20/part-2-django-comments-authenticated-users/">previous post</a>, I got a <a class="reference external" href="http://thejaswi.info/blog/2008/11/20/part-2-django-comments-authenticated-users/#c11">comment</a> from <a class="reference external" href="http://www.worksology.com/">Joshua Works</a> who gave an
interesting suggestion of not constructing fields for the name, email and
url in the form as opposed to my method of using javascript to populate
them. Each method has it's use cases and I like both of them.</p>
<p>So how do we get this method done?</p>
<p>In the <cite>photo_gallery_detail.html</cite>, make the following changes.</p>
<ul class="simple">
<li>Replace the <cite>render_comment_form</cite> tag with the <cite>get_comment_form</cite>
and contruct the form for all the fields you require.</li>
</ul>
<div class="highlight"><pre><span></span>{% get_comment_form for object as form %}
<span class="p"><</span><span class="nt">form</span> <span class="na">action</span><span class="o">=</span><span class="s">"{% comment_form_target %}"</span> <span class="na">method</span><span class="o">=</span><span class="s">"POST"</span><span class="p">></span>
{{ form.comment }}
{{ form.content_type }}
{{ form.object_pk }}
{{ form.timestamp }}
{{ form.security_hash }}
<span class="p"><</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">"submit"</span> <span class="na">value</span><span class="o">=</span><span class="s">"Add comment"</span> <span class="na">id</span><span class="o">=</span><span class="s">"id_submit"</span> <span class="p">/></span>
<span class="p"></</span><span class="nt">form</span><span class="p">></span>
</pre></div>
<ul class="simple">
<li>You don't need the javascript that we added to populate the
data in the <cite>base.html</cite> under the <cite>templates/test_app</cite> directory.</li>
<li>The wrapper remains as it is. You might ask me why I still have
the wrapper in place even though the field for the name isn't
available and that it would be automatically filled. The reason
is that a spoofer can force a different name (user_name) and
email address (user_email) to the database.</li>
</ul>
<p>Credit goes to <a class="reference external" href="http://www.worksology.com/">Joshua Works</a> for suggesting this idea. This is a
lot better than the hidden fields idea that I suggested as a
passing reference at the very end of previous blog post.</p>
</div>
Part 2: Django Comments for Authenticated Users2008-11-20T00:00:00+00:002008-11-20T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-11-20:/tech/blog/2008/11/20/part-2-django-comments-authenticated-users/<div class="section" id="id1">
<h2>Part 2: Django Comments for Authenticated Users</h2>
<p>In the <a class="reference external" href="/blog/2008/11/19/part-1-django-comments-authenticated-users/">previous part</a>, we had seen how to setup the basic portions of
the project. In this part, we are going to build on that and achieve
using the comments framework to accept comments from registered users only.</p>
<div class="section" id="step-2-getting-templates-ready">
<h3>Step - 2: Getting templates …</h3></div></div><div class="section" id="id1">
<h2>Part 2: Django Comments for Authenticated Users</h2>
<p>In the <a class="reference external" href="/blog/2008/11/19/part-1-django-comments-authenticated-users/">previous part</a>, we had seen how to setup the basic portions of
the project. In this part, we are going to build on that and achieve
using the comments framework to accept comments from registered users only.</p>
<div class="section" id="step-2-getting-templates-ready">
<h3>Step - 2: Getting templates ready</h3>
<p>The comments are bound to different apps through the use of <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#ref-contrib-contenttypes">content_type</a>
and <cite>object_pk</cite> in the templates. If you check up the stock templates in
the <cite>django.contrib.comments</cite> templates directory you will see how the
binding is done.</p>
<p>Create a directory called <cite>test_app</cite> under your <cite>templates</cite> directory and
create 3 files and name them <cite>base.html</cite>, <cite>photo_gallery_list.html</cite> and
<cite>photo_gallery_detail.html</cite>.</p>
<div class="section" id="contents-of-base-html">
<h4>Contents of base.html</h4>
<div class="highlight"><pre><span></span><span class="cp"><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"></span>
<span class="p"><</span><span class="nt">html</span> <span class="na">lang</span><span class="o">=</span><span class="s">"en"</span><span class="p">></span>
<span class="p"><</span><span class="nt">head</span><span class="p">></span>
<span class="p"><</span><span class="nt">meta</span> <span class="na">http-equiv</span><span class="o">=</span><span class="s">"Content-Type"</span> <span class="na">content</span><span class="o">=</span><span class="s">"text/html; charset=utf-8"</span><span class="p">></span>
<span class="p"><</span><span class="nt">title</span><span class="p">></span>Comment demo<span class="p"></</span><span class="nt">title</span><span class="p">></span>
{% block head %}
{% endblock %}
<span class="p"></</span><span class="nt">head</span><span class="p">></span>
<span class="p"><</span><span class="nt">body</span><span class="p">></span>
{% block content %}
{% endblock %}
<span class="p"></</span><span class="nt">body</span><span class="p">></span>
<span class="p"></</span><span class="nt">html</span><span class="p">></span>
</pre></div>
</div>
<div class="section" id="contents-of-photo-gallery-list-html">
<h4>Contents of photo_gallery_list.html</h4>
<div class="highlight"><pre><span></span>{% extends "test_app/base.html" %}
{% block content %}
{% load comments %}
<span class="p"><</span><span class="nt">h1</span><span class="p">></span>Comment on your favourite photo<span class="p"></</span><span class="nt">h1</span><span class="p">></span>
<span class="p"><</span><span class="nt">ul</span><span class="p">></span>
{% for a in object_list %}
{% get_comment_count for test_app.photo_gallery a.pk as cc %}
<span class="p"><</span><span class="nt">li</span><span class="p">><</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">"{{ a.pk }}/"</span><span class="p">></span>{{ a }}<span class="p"></</span><span class="nt">a</span><span class="p">></span> ({{ cc }} comment{{ cc|pluralize }})<span class="p"></</span><span class="nt">li</span><span class="p">></span>
{% endfor %}
<span class="p"></</span><span class="nt">ul</span><span class="p">></span>
{% endblock %}
</pre></div>
<p>The <cite>get_comment_count</cite> tag fetches the number of comments for each object (photo)
of the <cite>photo_gallery</cite> model.</p>
</div>
<div class="section" id="contents-of-photo-gallery-detail-html">
<h4>Contents of photo_gallery_detail.html</h4>
<div class="highlight"><pre><span></span>{% extends "test_app/base.html" %}
{% block content %}
{% load comments %}
<span class="p"><</span><span class="nt">h1</span><span class="p">></span>Give feedback/comments for your favourite photo<span class="p"></</span><span class="nt">h1</span><span class="p">></span>
<span class="p"><</span><span class="nt">p</span><span class="p">><</span><span class="nt">strong</span><span class="p">></span>{{ object.name }}<span class="p"></</span><span class="nt">strong</span><span class="p">></</span><span class="nt">p</span><span class="p">></span>
<span class="p"><</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">'{{ SITE_MEDIA }}/images/{{ object.pic.url }}'</span> <span class="na">alt</span><span class="o">=</span><span class="s">'{{ object.name }}'</span> <span class="na">width</span><span class="o">=</span><span class="s">"30%"</span> <span class="p">/></span>
{% get_comment_list for test_app.photo_gallery object.pk as comment_list %}
{% if comment_list %}
<span class="p"><</span><span class="nt">h2</span><span class="p">></span>Comments<span class="p"></</span><span class="nt">h2</span><span class="p">></span>
{% for comment in comment_list %}
<span class="p"><</span><span class="nt">h4</span><span class="p">></span>{{ comment.name|escape }} at {{ comment.submit_date|date:"r"}}<span class="p"></</span><span class="nt">h4</span><span class="p">></span>
<span class="p"><</span><span class="nt">p</span><span class="p">></span>{{ comment.comment|escape|urlizetrunc:"100"|linebreaks }}<span class="p"></</span><span class="nt">p</span><span class="p">></span>
<span class="p"><</span><span class="nt">hr</span><span class="p">></span>
{% endfor %}
{% endif %}
{% if request.user.is_authenticated %}
<span class="p"><</span><span class="nt">h2</span><span class="p">></span>Leave a comment<span class="p"></</span><span class="nt">h2</span><span class="p">></span>
{% render_comment_form for test_app.photo_gallery object.pk %}
{% endif %}
{% endblock %}
</pre></div>
<p>The <cite>get_comment_list</cite> tag fetches all the comments bound to a particular object
(photo) based on it's primary key (<cite>pk</cite>). Most of this is almost stock comment
based except for the <cite>request.user.is_authenticated</cite>.</p>
<p>Since we added <cite>TEMPLATE_CONTEXT_PROCESSORS</cite> in our <cite>settings.py</cite>, it gives us
the functionality to access the request object in our templates.</p>
<p>We check if the user is authenticated and display the comment form accordingly.
The <cite>render_comment_form</cite> tag displays the form by rendering the <cite>comments/form.html</cite>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Without the <cite>request.user.is_authenticated</cite> functionality, we can accept
comments from anonymous users also.</p>
</div>
</div>
</div>
<div class="section" id="step-3-getting-your-admin-ready-to-upload-photos">
<h3>Step-3: Getting your admin ready to upload photos</h3>
<p>Django's admin is one of the umpteen reasons it is so popular. It makes some
<a class="reference external" href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete">CRUD</a> part very easy.</p>
<p>Create a new file in <cite>test_app</cite> called <cite>admin.py</cite>.</p>
<div class="section" id="contents-of-admin-py">
<h4>Contents of admin.py</h4>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.contrib</span> <span class="kn">import</span> <span class="n">admin</span>
<span class="kn">from</span> <span class="nn">test_app.models</span> <span class="kn">import</span> <span class="n">Photo_Gallery</span>
<span class="k">class</span> <span class="nc">Photo_Gallery_Admin</span><span class="p">(</span><span class="n">admin</span><span class="o">.</span><span class="n">ModelAdmin</span><span class="p">):</span>
<span class="n">list_display</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"name"</span><span class="p">,</span><span class="s2">"pic"</span><span class="p">]</span>
<span class="n">admin</span><span class="o">.</span><span class="n">site</span><span class="o">.</span><span class="n">register</span><span class="p">(</span><span class="n">Photo_Gallery</span><span class="p">,</span> <span class="n">Photo_Gallery_Admin</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="step-4-fire-up-your-dev-server">
<h3>Step-4: Fire up your dev-server</h3>
<p>You might have a question if we are done yet...and the answer to that would
be a NO!!! We are just firing up the server to check if we have done
everything right until here.</p>
<p>Make sure to sync your tables before you fire up your dev-server.</p>
<div class="highlight"><pre><span></span><span class="o">[</span>theju@localhost comments_reg_users<span class="o">]</span>$ python manage.py syncdb
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table django_comments
Creating table django_comment_flags
Creating table test_app_photo_gallery
You just installed Django<span class="s1">'s auth system, which means you don'</span>t have any superusers defined.
Would you like to create one now? <span class="o">(</span>yes/no<span class="o">)</span>: yes
Username <span class="o">(</span>Leave blank to use <span class="s1">'theju'</span><span class="o">)</span>: admin
E-mail address: admin@vce.ac.in
Password:
Password <span class="o">(</span>again<span class="o">)</span>:
Superuser created successfully.
Installing index <span class="k">for</span> auth.Permission model
Installing index <span class="k">for</span> auth.Message model
Installing index <span class="k">for</span> admin.LogEntry model
Installing index <span class="k">for</span> comments.Comment model
Installing index <span class="k">for</span> comments.CommentFlag model
</pre></div>
<p>and then fire your dev server</p>
<div class="highlight"><pre><span></span><span class="o">[</span>theju@localhost comments_reg_users<span class="o">]</span>$ python manage.py runserver
Validating models...
<span class="m">0</span> errors found
Django version <span class="m">1</span>.1 pre-alpha, using settings <span class="s1">'comments_reg_users.settings'</span>
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
</pre></div>
<p>Open your browser and direct it to <cite>http://127.0.0.1:8000/admin/</cite>. Open the
<cite>Photo Gallery</cite> tab and add a few photos. Open a new tab (don't
log out from the admin) on your browser and check out
<cite>http://127.0.0.1:8000/names/</cite>. Then click on any photo object and you'll
see the comments form. Log out from the admin tab and refresh this page
and you'll see it vanish.</p>
<p>All happy till now??? But you might ask "Does the registered user have to
go through the pain of entering his name and email id everytime?" and
"What is the guarantee that this form cannot be spoofed?" My reply to these
questions would be "Hey, I didn't tell this was done yet!!!"</p>
<p>The answer to the first question would be to override the <cite>comments/form.html</cite>.</p>
</div>
<div class="section" id="step-5-slightly-customize-your-comments-form">
<h3>Step-5: Slightly customize your comments form</h3>
<p>Edit the <cite>base.html</cite> under <cite>templates/test_app</cite> to look like below:</p>
<div class="highlight"><pre><span></span> <span class="cp"><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"></span>
<span class="p"><</span><span class="nt">html</span> <span class="na">lang</span><span class="o">=</span><span class="s">"en"</span><span class="p">></span>
<span class="p"><</span><span class="nt">head</span><span class="p">></span>
<span class="p"><</span><span class="nt">meta</span> <span class="na">http-equiv</span><span class="o">=</span><span class="s">"Content-Type"</span> <span class="na">content</span><span class="o">=</span><span class="s">"text/html; charset=utf-8"</span><span class="p">></span>
<span class="p"><</span><span class="nt">title</span><span class="p">></span>Comment demo<span class="p"></</span><span class="nt">title</span><span class="p">></span>
<span class="p"><</span><span class="nt">script</span> <span class="na">type</span><span class="o">=</span><span class="s">"text/javascript"</span><span class="p">></span>
<span class="kd">function</span> <span class="nx">disableReqdInputs</span><span class="p">(){</span>
<span class="kd">var</span> <span class="nx">nameInput</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'id_name'</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">nameInput</span><span class="p">){</span>
<span class="nx">nameInput</span><span class="p">.</span><span class="nx">value</span> <span class="o">=</span> <span class="s2">"{{ request.user.get_full_name }}"</span><span class="p">;</span>
<span class="nx">nameInput</span><span class="p">.</span><span class="nx">readOnly</span><span class="o">=</span><span class="kc">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="kd">var</span> <span class="nx">emailInput</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'id_email'</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">emailInput</span><span class="p">){</span>
<span class="nx">emailInput</span><span class="p">.</span><span class="nx">value</span> <span class="o">=</span> <span class="s2">"{{ request.user.email }}"</span><span class="p">;</span>
<span class="nx">emailInput</span><span class="p">.</span><span class="nx">readOnly</span><span class="o">=</span><span class="kc">true</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p"></</span><span class="nt">script</span><span class="p">></span>
{% block head %}
{% endblock %}
<span class="p"></</span><span class="nt">head</span><span class="p">></span>
<span class="p"><</span><span class="nt">body</span> <span class="na">onload</span><span class="o">=</span><span class="s">"disableReqdInputs();"</span><span class="p">></span>
{% block content %}
{% endblock %}
<span class="p"></</span><span class="nt">body</span><span class="p">></span>
<span class="p"></</span><span class="nt">html</span><span class="p">></span>
</pre></div>
<p>The above javascript will make the name and email inputs readonly and also
autofill the names as mentioned in the <cite>django.contrib.auth</cite>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">You can also use <a class="reference external" href="http://www.jquery.org/">jQuery</a> to get most of your javascript work done too.</p>
</div>
<p>Now we need to answer the second question regarding form-spoofing. For this
we need to write a wrapper around the default <cite>post_comment</cite> that will
prevent invalid data or changed data (like name or email).</p>
</div>
<div class="section" id="step-6-writing-a-wrapper-around-post-comment">
<h3>Step-6: Writing a wrapper around <cite>post_comment</cite></h3>
<p>When the comment gets posted we need to make sure that it is redirected first
to our wrapper.</p>
<p>For this add the following line in the <cite>urls.py</cite> and make sure this line always
comes above the <cite>^comments/</cite> line. The reason is that django's urlresolvers
match URLs from top-to-bottom.</p>
<div class="highlight"><pre><span></span><span class="p">(</span><span class="sa">r</span><span class="s1">'^comments/post/'</span><span class="p">,</span> <span class="s1">'test_app.views.comment_post_wrapper'</span><span class="p">),</span>
</pre></div>
<p>Next open the <cite>test_app.views</cite> file and write the wrapper like below:</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.contrib.comments.views.comments</span> <span class="kn">import</span> <span class="n">post_comment</span>
<span class="kn">from</span> <span class="nn">django.http</span> <span class="kn">import</span> <span class="n">HttpResponse</span>
<span class="k">def</span> <span class="nf">comment_post_wrapper</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="c1"># Clean the request to prevent form spoofing</span>
<span class="k">if</span> <span class="n">request</span><span class="o">.</span><span class="n">user</span><span class="o">.</span><span class="n">is_authenticated</span><span class="p">():</span>
<span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">user</span><span class="o">.</span><span class="n">get_full_name</span><span class="p">()</span> <span class="o">==</span> <span class="n">request</span><span class="o">.</span><span class="n">POST</span><span class="p">[</span><span class="s1">'name'</span><span class="p">]</span> <span class="ow">or</span> \
<span class="n">request</span><span class="o">.</span><span class="n">user</span><span class="o">.</span><span class="n">email</span> <span class="o">==</span> <span class="n">request</span><span class="o">.</span><span class="n">POST</span><span class="p">[</span><span class="s1">'email'</span><span class="p">]):</span>
<span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="s2">"You registered user...trying to spoof a form...eh?"</span><span class="p">)</span>
<span class="k">return</span> <span class="n">post_comment</span><span class="p">(</span><span class="n">request</span><span class="p">)</span>
<span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="s2">"You anonymous cheater...trying to spoof a form?"</span><span class="p">)</span>
</pre></div>
<p>That's it, we are done...just test out your application now and it should work.
If you don't like your inputs to be readonly, you can always make them hidden by
altering the <cite>comments/form.html</cite>. The wrapper still remains the same.</p>
</div>
<div class="section" id="conclusions">
<h3>Conclusions</h3>
<p>There is a very interesting ticket <a class="reference external" href="http://code.djangoproject.com/ticket/8630">#8630</a> that deals with the customization
of comments. The ticket has some nice docs courtesy of <cite>Carljm</cite> and is slated
to be in by Django 1.1.</p>
<p>With that ticket, the inbuilt comments should become much more easier to customize.</p>
</div>
</div>
Part 1: Django Comments for Authenticated Users2008-11-19T00:00:00+00:002008-11-19T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-11-19:/tech/blog/2008/11/19/part-1-django-comments-authenticated-users/<div class="section" id="id1">
<h2>Part 1: Django Comments for Authenticated Users</h2>
<p>Off late, I have not been hanging in the <a class="reference external" href="irc://irc.freenode.net/django">#django</a> channel...but got an
opportunity to do so a couple of days back. A user (I forgot his IRC nick),
wanted to use <cite>django.contrib.comments</cite> to accept comments from authenticated
users only …</p></div><div class="section" id="id1">
<h2>Part 1: Django Comments for Authenticated Users</h2>
<p>Off late, I have not been hanging in the <a class="reference external" href="irc://irc.freenode.net/django">#django</a> channel...but got an
opportunity to do so a couple of days back. A user (I forgot his IRC nick),
wanted to use <cite>django.contrib.comments</cite> to accept comments from authenticated
users only.</p>
<p>I suggested that he write his own form template that used the
<cite>request.user.is_authenticated</cite> in an <cite>if</cite> tag. He was ok with it but
didn't want the user to enter his name and email id again. Then I
suggested he use hidden fields and he started talking of form spoofing and
other advanced techniques. Almost giving up hope (I wonder how <a class="reference external" href="http://collingrady.wordpress.com/">Magus-</a>
manages to keep his cool), I asked him to write a wrapper for <cite>post_comment</cite>
that would get his job done. The user finally dropped the bomb by telling
he was new to <a class="reference external" href="http://www.python.org/">python</a> and didn't know what a wrapper was.</p>
<p>Realizing that many folks use django because it makes their life easy
and let's them get away without knowing too much of python, I decided to
write a step-by-step procedure for accepting comments from authenticated
users only.</p>
<p>I am writing this post as a series so that each post is not too boring or
intimidating.</p>
<div class="section" id="first-few-steps">
<h3>First few steps:</h3>
<p>The first few steps are mundane and you can ignore these if you know how
to setup a django project, the database and a test application.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">I use Fedora as my operating system and some steps and applications
might not be available in your setup.</p>
</div>
<ul class="simple">
<li>Start a django project.</li>
</ul>
<div class="highlight"><pre><span></span><span class="o">[</span>theju@localhost ~<span class="o">]</span>$ django-admin.py startproject comments_reg_users
<span class="o">[</span>theju@localhost ~<span class="o">]</span>$ <span class="nb">cd</span> comments_reg_users
</pre></div>
<ul class="simple">
<li>Set the database by editing the settings.py in the comments_reg_users
directory.</li>
</ul>
<div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span>
<span class="n">DATABASE_ENGINE</span> <span class="o">=</span> <span class="s1">'sqlite3'</span>
<span class="n">DATABASE_NAME</span> <span class="o">=</span> <span class="s1">'abc.db'</span>
<span class="n">MEDIA_ROOT</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">getcwd</span><span class="p">(),</span><span class="s1">'site_media'</span><span class="p">)</span>
<span class="n">TEMPLATE_DIRS</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">getcwd</span><span class="p">(),</span><span class="s1">'templates'</span><span class="p">),</span>
<span class="p">)</span>
<span class="n">TEMPLATE_CONTEXT_PROCESSORS</span><span class="o">=</span><span class="p">(</span>
<span class="s2">"django.core.context_processors.auth"</span><span class="p">,</span>
<span class="s2">"django.core.context_processors.request"</span><span class="p">,</span>
<span class="s2">"django.core.context_processors.media"</span>
<span class="p">)</span>
</pre></div>
<ul class="simple">
<li>Add the following to the <cite>INSTALLED_APPS</cite> in the <cite>settings.py</cite>.</li>
</ul>
<div class="highlight"><pre><span></span><span class="s1">'django.contrib.admin'</span><span class="p">,</span>
<span class="s1">'django.contrib.comments'</span><span class="p">,</span>
<span class="s1">'test_app'</span><span class="p">,</span>
</pre></div>
<ul class="simple">
<li>Create two directories namely <cite>templates</cite> and <cite>site_media</cite> in the <cite>comments_reg_users</cite>
directory.</li>
<li>Create a new application (or use an existing one if you have).</li>
</ul>
<div class="highlight"><pre><span></span><span class="o">[</span>theju@localhost comments_reg_users<span class="o">]</span>$ python manage.py startapp test_app
<span class="o">[</span>theju@localhost comments_reg_users<span class="o">]</span>$ <span class="nb">cd</span> test_app/
<span class="o">[</span>theju@localhost test_app<span class="o">]</span>$ ls
__init__.py models.py views.py
</pre></div>
<ul class="simple">
<li>Create a model against which the comments will be tied. Let's do a mini
photo gallery.</li>
</ul>
<div class="highlight"><pre><span></span><span class="o">[</span>theju@localhost test_app<span class="o">]</span>$ emacs models.py
</pre></div>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.db</span> <span class="kn">import</span> <span class="n">models</span>
<span class="c1"># Create your models here.</span>
<span class="k">class</span> <span class="nc">Photo_Gallery</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
<span class="n">name</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">50</span><span class="p">)</span>
<span class="n">pic</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">ImageField</span><span class="p">(</span><span class="n">upload_to</span><span class="o">=</span><span class="s1">'pics'</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">__unicode__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>
</pre></div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If you don't understand what we've done so far, it is recommended
that you go through the <a class="reference external" href="http://docs.djangoproject.com/en/dev/">django docs</a>.</p>
</div>
<ul class="simple">
<li>Edit the urls.py in the <cite>comments_reg_users</cite> directory like below.</li>
</ul>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.conf.urls.defaults</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">from</span> <span class="nn">django.contrib</span> <span class="kn">import</span> <span class="n">admin</span>
<span class="n">admin</span><span class="o">.</span><span class="n">autodiscover</span><span class="p">()</span>
<span class="n">urlpatterns</span> <span class="o">=</span> <span class="n">patterns</span><span class="p">(</span><span class="s1">''</span><span class="p">,</span>
<span class="p">(</span><span class="sa">r</span><span class="s1">'^admin/(.*)'</span><span class="p">,</span> <span class="n">admin</span><span class="o">.</span><span class="n">site</span><span class="o">.</span><span class="n">root</span><span class="p">),</span>
<span class="p">(</span><span class="sa">r</span><span class="s1">'^comments/'</span><span class="p">,</span> <span class="n">include</span><span class="p">(</span><span class="s1">'django.contrib.comments.urls'</span><span class="p">)),</span>
<span class="p">(</span><span class="sa">r</span><span class="s1">'^names/$'</span><span class="p">,</span> <span class="n">list_detail</span><span class="o">.</span><span class="n">object_list</span><span class="p">,</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">queryset</span><span class="o">=</span><span class="n">Photo_Gallery</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">())),</span>
<span class="p">(</span><span class="sa">r</span><span class="s1">'^names/(?P<object_id>\d+)/$'</span><span class="p">,</span> <span class="n">list_detail</span><span class="o">.</span><span class="n">object_detail</span><span class="p">,</span>
<span class="nb">dict</span><span class="p">(</span><span class="n">queryset</span><span class="o">=</span><span class="n">Photo_Gallery</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">())),</span>
<span class="p">(</span><span class="sa">r</span><span class="s1">'^images/(?P<path>.*)$'</span><span class="p">,</span> <span class="s1">'django.views.static.serve'</span><span class="p">,</span>
<span class="p">{</span><span class="s1">'document_root'</span><span class="p">:</span> \
<span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="vm">__file__</span><span class="p">),</span><span class="s1">'site_media/'</span><span class="p">)}),</span>
<span class="p">)</span>
</pre></div>
<p>We will be using <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/generic-views/">generic views</a> to display the data bound to the models ie the
photos in our mini photo gallery. Nothing extra to be written. With this we are
done with the first few steps.</p>
<p>Read the next part <a class="reference external" href="http://thejaswi.info/blog/2008/11/20/part-2-django-comments-authenticated-users/">here</a>.</p>
</div>
</div>
Inotify, watch your filesystem2008-11-05T00:00:00+00:002008-11-05T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-11-05:/tech/blog/2008/11/05/inotify-watch-your-filesystem/<div class="section" id="id1">
<h2>Inotify, watch your filesystem</h2>
<p><a class="reference external" href="http://en.wikipedia.org/wiki/Inotify">Inotify</a>, is a Linux kernel system call that helps you monitor
the file system for various events.</p>
<p>Here is how I use it:</p>
<ul>
<li><p class="first">My blog basically consists of <a class="reference external" href="http://docutils.sourceforge.net/rst.html">Restructured Text</a> files in a
particular directory. I use the <a class="reference external" href="http://www.xapian.org/">Xapian</a> indexer to provide
the <a class="reference external" href="http://thejaswi.info/search/?q=django">search</a> facility on …</p></li></ul></div><div class="section" id="id1">
<h2>Inotify, watch your filesystem</h2>
<p><a class="reference external" href="http://en.wikipedia.org/wiki/Inotify">Inotify</a>, is a Linux kernel system call that helps you monitor
the file system for various events.</p>
<p>Here is how I use it:</p>
<ul>
<li><p class="first">My blog basically consists of <a class="reference external" href="http://docutils.sourceforge.net/rst.html">Restructured Text</a> files in a
particular directory. I use the <a class="reference external" href="http://www.xapian.org/">Xapian</a> indexer to provide
the <a class="reference external" href="http://thejaswi.info/search/?q=django">search</a> facility on my site. Whenever a particular file
is uploaded to the directory, the search index has to be
rebuilt and the new blog post has to be updated. Also a ping
request has to be sent to Google.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<ul class="last simple">
<li>All these are possible within <a class="reference external" href="http://www.djangoproject.com/">Django</a> using <a class="reference external" href="http://docs.djangoproject.com/en/dev/topics/signals/#topics-signals">signals</a> and
the <a class="reference external" href="http://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/#ref-contrib-sitemaps">sitemaps</a> plugin, but my site doesn't use Django for
uploading the files to the blog.</li>
</ul>
</div>
</li>
</ul>
<p>I could use cron to run periodically but it is going to have
the following drawbacks:</p>
<ul class="simple">
<li>Not going to update the index instantaneously.</li>
<li>If there's no change in the blogs, the index keeps getting
updated unnecessarily.</li>
</ul>
<p>Inotify keeps monitoring the blogs directory for a file-system
event. When that occurs, it triggers the search index to be
rebuilt and pings google that the blog has been updated.</p>
<p>Here's a sample script that uses Epoll (an IO notification
facility).</p>
<div class="highlight"><pre><span></span> <span class="cp">#include</span> <span class="cpf"><sys/inotify.h></span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf"><sys/epoll.h></span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf"><unistd.h></span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf"><stdio.h></span><span class="cp"></span>
<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span>
<span class="p">{</span>
<span class="kt">int</span> <span class="n">fd</span><span class="p">,</span> <span class="n">wd</span><span class="p">,</span> <span class="n">efd</span><span class="p">,</span> <span class="n">cfg</span><span class="p">,</span> <span class="n">ret</span><span class="p">,</span> <span class="n">shret</span><span class="p">;</span>
<span class="kt">pid_t</span> <span class="n">pid</span><span class="p">;</span>
<span class="k">struct</span> <span class="n">epoll_event</span> <span class="n">ev</span><span class="p">;</span>
<span class="n">fd</span> <span class="o">=</span> <span class="n">inotify_init</span><span class="p">();</span>
<span class="k">if</span> <span class="p">(</span><span class="n">fd</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">perror</span><span class="p">(</span><span class="s">"Could not initialize inotify"</span><span class="p">);</span>
<span class="n">wd</span> <span class="o">=</span> <span class="n">inotify_add_watch</span><span class="p">(</span><span class="n">fd</span><span class="p">,</span> <span class="s">"/path/to/monitored/"</span><span class="p">,</span> <span class="n">IN_MODIFY</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">wd</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">perror</span><span class="p">(</span><span class="s">"Could not initialize the watch descriptor"</span><span class="p">);</span>
<span class="n">efd</span> <span class="o">=</span> <span class="n">epoll_create</span><span class="p">(</span><span class="k">sizeof</span><span class="p">(</span><span class="n">fd</span><span class="p">));</span>
<span class="k">if</span> <span class="p">(</span><span class="n">efd</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">perror</span><span class="p">(</span><span class="s">"Could not initialized epoll file descriptor"</span><span class="p">);</span>
<span class="n">ev</span><span class="p">.</span><span class="n">events</span> <span class="o">=</span> <span class="n">EPOLLIN</span><span class="o">|</span><span class="n">EPOLLOUT</span><span class="o">|</span><span class="n">EPOLLET</span><span class="p">;</span>
<span class="n">cfg</span> <span class="o">=</span> <span class="n">epoll_ctl</span><span class="p">(</span><span class="n">efd</span><span class="p">,</span> <span class="n">EPOLL_CTL_ADD</span><span class="p">,</span> <span class="n">fd</span><span class="p">,</span> <span class="o">&</span><span class="n">ev</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">cfg</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">perror</span><span class="p">(</span><span class="s">"Could not configure the epoll interface"</span><span class="p">);</span>
<span class="k">while</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">ret</span> <span class="o">=</span> <span class="n">epoll_wait</span><span class="p">(</span><span class="n">efd</span><span class="p">,</span> <span class="o">&</span><span class="n">ev</span><span class="p">,</span> <span class="mi">100</span><span class="p">,</span> <span class="mi">86400000</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">ret</span> <span class="o">></span> <span class="mi">0</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">shret</span> <span class="o">=</span> <span class="n">execv</span><span class="p">(</span><span class="s">"/path/to/the/indexer"</span><span class="p">,</span> <span class="nb">NULL</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">shret</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">perror</span><span class="p">(</span><span class="s">"Feed Generator Script execution failed"</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">ret</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">perror</span><span class="p">(</span><span class="s">"Error in the polling"</span><span class="p">);</span>
<span class="k">break</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">else</span>
<span class="p">{</span>
<span class="n">perror</span><span class="p">(</span><span class="s">"Timed Out"</span><span class="p">);</span>
<span class="k">break</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>This C program is run once a day (as against periodically every couple of hours)
through cron and it keeps listening all the day for changes in the filesystem.
If there was no change, the script times out else it triggers the indexer.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<ul class="last simple">
<li>I have come across the <a class="reference external" href="http://inotify-tools.sourceforge.net/">inotify-tools</a> project only recently
and is really awesome.</li>
</ul>
</div>
</div>
GNU Screen : A must for remote developers2008-11-02T00:00:00+00:002008-11-02T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-11-02:/tech/blog/2008/11/02/gnu-screen-must-remote-developers/<div class="section" id="id1">
<h2>GNU Screen : A must for remote developers</h2>
<p>Did you ever come across a scenario where you were in the middle of
some important work on the terminal and realized that you were
out of time and wished you could continue it say from home or from
another machine?</p>
<p>Or another …</p></div><div class="section" id="id1">
<h2>GNU Screen : A must for remote developers</h2>
<p>Did you ever come across a scenario where you were in the middle of
some important work on the terminal and realized that you were
out of time and wished you could continue it say from home or from
another machine?</p>
<p>Or another scenario, where you could do a show-and-tell with some
of your code and collaborate with other users?</p>
<p><a class="reference external" href="http://www.gnu.org/software/screen/">GNU Screen</a> helps you in both cases. I recommend it to all remote
developers.</p>
<p>Here's how I use it:</p>
<ul class="simple">
<li>When at work, I use multiple screen sessions instead of opening
multiple terminals. So you have a cleaner toolbar.
I detach screens with long running processes and reconnect to
them at a much later stage to look at their output.</li>
<li>While I was in Hyderabad a couple of weeks back I was updating
my VPS and it was taking a long time, so I just detached the
screen. After I was back at Chennai, I reattached the screen
to check the status of the update.</li>
<li>I do a show-and-tell of my code to co-workers using Screen.
They join the screen session started by me and I give them
a guided tour.</li>
</ul>
<p>Check out a neat <a class="reference external" href="http://linuxhacks.org/tutorials/jakes_gnu_screen_tutorial.php">tutorial</a> on how to use it.</p>
</div>
Thejaswi.info bids adieu to Webfaction2008-10-29T00:00:00+00:002008-10-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-10-29:/tech/blog/2008/10/29/thejaswiinfo-bids-adieu-webfaction/<div class="section" id="id1">
<h2>Thejaswi.info bids adieu to Webfaction</h2>
<p>As some of you might have observed (or even if you didn't observe), <a class="reference external" href="http://thejaswi.info/">my</a> site now
isn't hosted with <a class="reference external" href="http://www.webfaction.com/">Webfaction</a> anymore. I have moved to <a class="reference external" href="http://www.gandi.net/hosting">Gandi's</a> <a class="reference external" href="http://en.wikipedia.org/wiki/Virtual_private_server">VPS</a> service.
The VPS service by Gandi is quite cheap and reliable. I have been using it ever …</p></div><div class="section" id="id1">
<h2>Thejaswi.info bids adieu to Webfaction</h2>
<p>As some of you might have observed (or even if you didn't observe), <a class="reference external" href="http://thejaswi.info/">my</a> site now
isn't hosted with <a class="reference external" href="http://www.webfaction.com/">Webfaction</a> anymore. I have moved to <a class="reference external" href="http://www.gandi.net/hosting">Gandi's</a> <a class="reference external" href="http://en.wikipedia.org/wiki/Virtual_private_server">VPS</a> service.
The VPS service by Gandi is quite cheap and reliable. I have been using it ever
since the beta stage and recommend it.</p>
<p>For people wondering the motive behind my move, here are a few advantages and
disadvantages of a VPS over shared hosting.</p>
<div class="section" id="advantages">
<h3>Advantages</h3>
<ul class="simple">
<li>You have the root (superuser) password, so you can make or break your system.</li>
<li>Usually VPS' have more memory than shared hosting.</li>
</ul>
</div>
<div class="section" id="disadvantages">
<h3>Disadvantages</h3>
<ul class="simple">
<li>A VPS has to be configured and secured before you start hosting your apps. This
step is not for the lazy or for the hasties (if I can call them so!). If you
have no idea of system administration, stick to a shared hosting.</li>
</ul>
<p>I was with webfaction for more than 1.5 years and enjoyed every single day with
them. They have the easiest and most intuitive control panel that helps you
host your apps within a few minutes of signing up and their customer service
rocks!!! The saddest part is the memory limit they impose on the long-running
processes (servers and other software if you have). And the pain taken to install
other custom software (if they don't have it) is not worth it.</p>
<p>Bye bye webfaction, I will miss you. But the day you open a VPS (I hope you do)...
I will be back!!!</p>
</div>
</div>
Create an ISO from a CD/DVD Device2008-10-28T00:00:00+00:002008-10-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-10-28:/tech/blog/2008/10/28/create-iso-cddvd-device/<div class="section" id="id1">
<h2>Create an ISO from a CD/DVD Device</h2>
<p>In GNU/Linux, it is very easy to create an ISO image which can be used to be
written later on to CD/DVDs.</p>
<div class="highlight"><pre><span></span>dd <span class="k">if</span><span class="o">=</span>/dev/cdrom-device <span class="nv">of</span><span class="o">=</span>/path/to/image.iso
</pre></div>
<p>Really simple and awesome!!!</p>
</div>
Foss.in needs a relook2008-10-26T00:00:00+00:002008-10-26T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-10-26:/tech/blog/2008/10/26/foss-needs-relook/<div class="section" id="my-viewpoint-of-foss-in-2008">
<h2>My viewpoint of Foss.in:2008</h2>
<p>A <a class="reference external" href="http://lawgon.livejournal.com/47399.html">lot</a> <a class="reference external" href="http://vamsee.blogspot.com/2008/10/what-fck-is-wrong-with-fossin.html">has</a> <a class="reference external" href="http://www.kix.in/blog/2008/10/the-fossin08-omelette/">been</a> <a class="reference external" href="http://www.perrier.eu.org/weblog/2008/10/04#foss-in">said</a> and <a class="reference external" href="http://www.svaksha.com/post/2008/vegetarian-contributors-musings">written</a> about <a class="reference external" href="http://foss.in/">Foss.in:2008</a>. I don't have much
to add because these folks have already written quite a few convincing things.
I really appreciate their views though some of them are very radical and personal.</p>
<p>I would …</p></div><div class="section" id="my-viewpoint-of-foss-in-2008">
<h2>My viewpoint of Foss.in:2008</h2>
<p>A <a class="reference external" href="http://lawgon.livejournal.com/47399.html">lot</a> <a class="reference external" href="http://vamsee.blogspot.com/2008/10/what-fck-is-wrong-with-fossin.html">has</a> <a class="reference external" href="http://www.kix.in/blog/2008/10/the-fossin08-omelette/">been</a> <a class="reference external" href="http://www.perrier.eu.org/weblog/2008/10/04#foss-in">said</a> and <a class="reference external" href="http://www.svaksha.com/post/2008/vegetarian-contributors-musings">written</a> about <a class="reference external" href="http://foss.in/">Foss.in:2008</a>. I don't have much
to add because these folks have already written quite a few convincing things.
I really appreciate their views though some of them are very radical and personal.</p>
<p>I would support any initiative that tries to inspire people to start contributing
to free software but would discourage if there is discrimination based on the type
of contribution.</p>
<p>All the different contributors to free software are indispensable. They help a
project survive and flourish.</p>
<ul class="simple">
<li><strong>Bug fixers/triagers</strong>: Ask any humble free software developer and he will
profusely thank these folks who reduce their burden and help maintain sanity on
the bug-lists.</li>
<li><strong>Translators</strong>: Many people think this is a very trivial aspect of free software
but they are wrong. Free software is very popular in Latin American and other
non-English countries. If you really want to promote free software worldwide,
then you need the help of these folks. Translation is not a very easy task and
it's tougher to collaborate when working for a translation team.</li>
<li><strong>Artwork</strong>: Don't you love your free software to have a neat UI that is accessible
and also pleasing. These are the folks who struggle to get this thankless work done.</li>
<li><strong>Packagers</strong>: Ever wished your packages found itself into every distribution
and you could install your favourite software in a jiffy. These folks are the ones
who are behind the painless installs.</li>
<li><strong>Users</strong>: They are the most important part of any software project (free or
proprietary). They play an important role by helping propagate the software,
they can give good feedback and improve your userbase or they could rant about
it (potential bug reports or missing features). Most potential developers come
from this category. You really would not want to piss them off!!! India lacks
these folks. Compare the number of users of free software in other countries
to ours and the number of developers from those countries to ours. Do you see
a relation? Absolutely. They are directly proportional.</li>
</ul>
<p>Only when all the four categories work together with developers do you get that
beautiful free software.</p>
<p>I have no problems with Foss.in being a <em>specialized conference</em>, but the
justifications given are wrong.</p>
<ul class="simple">
<li><strong>Low hanging fruit</strong> is a very unprofessional word to use against contributors.</li>
<li><strong>Five days going to change the way the world perceives India in the context of FOSS</strong>.
Is there any way to tell how much code or how many people from a country are
contributing to free software? It is almost impossible, most development takes
place over the internet, a fairly anonymous medium. And who really cares for which
country you belong as long as you are supporting the cause. Please don't get
chauvinism into the picture.</li>
<li><strong>Spotlight on Indian Contributors</strong>. How are you going to quantify a contributor's
contribution to free software and how many are you going to throw a spotlight on?</li>
<li><strong>Foss workouts</strong>. How many projects are you going to highlight and start working on?
No modalities mentioned, just eloquent statements. Why doesn't Foss.in think of
adopting one (or many) <a class="reference external" href="http://www.fsf.org/campaigns/priority.html">priority software projects</a> from GNU and work on them
through out the year till the next edition?</li>
<li>Some foss.in team members have mentioned that there are too many <em>general</em> FOSS
events being conducted all over India, so they wanted a specialized one. Not a
good enough reason. Suppose, Foss.in decided to target government enterprises
or educational institutes and enouraged them to adopt FOSS, it would have justified
their stance for a specialized conference. <strong>Being a very large conference, they have
a potential to increase adoption of free software, developers are only a by-product!!!</strong>.
And the reason why many FOSS events have sprung across the country are because they
want to generate visibility to FOSS and help people who can't afford (either in terms
of the money or the time) to make it to FOSS.in.</li>
</ul>
<p>Probably, the event requires a relook. Since the organizers project it as a pan-India
conference, there needs to be a committee that should compromise people from every
aspect of the Free Software movement and from every part of the country. Let there be
democracy and more transparency in the event management and have the venue changed
every year, so that more people get a chance to be part of it.</p>
<p>My concluding words:</p>
<ul class="simple">
<li>First, to all the people who are ranting about the event. Lets not give any sort of
publicity (negative or positive) to the event. Let's keep silent and it will be forgotten.</li>
<li>To the organizers, it's better to be late than never.</li>
</ul>
<p>In it's current avatar, I am not going to attend FOSS.in.</p>
</div>
Sad state of politics...2008-10-25T00:00:00+00:002008-10-25T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-10-25:/personal/blog/2008/10/25/sad-state-politics/<div class="section" id="id1">
<h2>Sad state of politics...</h2>
<p>First let me talk about politicians in my own state of
<a class="reference external" href="http://en.wikipedia.org/wiki/Andhra_Pradesh">Andhra Pradesh</a>. For the past few years, the <a class="reference external" href="http://en.wikipedia.org/wiki/Telugu_Desam_Party">Telugu
Desam Party</a> (TDP) had been supporting the cause for the
united state of Andhra Pradesh. While the <a class="reference external" href="http://en.wikipedia.org/wiki/Indian_National_Congress">Congress</a>, being an
opportunistic party, went into a pre-poll …</p></div><div class="section" id="id1">
<h2>Sad state of politics...</h2>
<p>First let me talk about politicians in my own state of
<a class="reference external" href="http://en.wikipedia.org/wiki/Andhra_Pradesh">Andhra Pradesh</a>. For the past few years, the <a class="reference external" href="http://en.wikipedia.org/wiki/Telugu_Desam_Party">Telugu
Desam Party</a> (TDP) had been supporting the cause for the
united state of Andhra Pradesh. While the <a class="reference external" href="http://en.wikipedia.org/wiki/Indian_National_Congress">Congress</a>, being an
opportunistic party, went into a pre-poll alliance
with a separatist party <a class="reference external" href="http://en.wikipedia.org/wiki/Telangana_Rashtra_Samithi">Telangana Rashtra Samithi</a> (TRS),
promising a <a class="reference external" href="http://en.wikipedia.org/wiki/Telangana">separate state</a> if the State Reorganization
Committee (<a class="reference external" href="http://en.wikipedia.org/wiki/States_Reorganisation_Act">SRC</a>) favoured the formation of a state
after they came into power. But with no consensus, the
Congress couldn't do much and the TRS pulled out of the
government. Then we saw people from various parties
pulling out to form smaller splinter parties for the
cause of statehood. Recently, the TDP did a volte-face
and decided to support the creation of a separate state.
I believed the TDP was a far more disciplined party than
the rest of the parties, but by supporting such a decision,
the TDP has lost the supporter in me. The party doesn't
appeal any more. It needs democracy within it's ranks,
needs more people with a vision and lot of second-rung leaders
who should mostly be educated and responsible youth. So does
that mean, I am going to shift loyalties to <a class="reference external" href="http://en.wikipedia.org/wiki/Prajarajyam">Praja Rajyam</a>?
Well, not exactly. First, I don't think you've to enter politics
to serve the people, there are a lot of ways you can do that
and <a class="reference external" href="http://en.wikipedia.org/wiki/Chiranjeevi">Chiranjeevi</a> was doing that quite successfully.
The party does not have clear policy decisions on many issues or
is populistic on a lot others. And also, Mr.Chiranjeevi does not
seem to be in the driver seat (there seems to be some one driving
him). If the party really comes up with good policies, then I
might consider it...but till then there is a void of statesmen
and good political parties in Andhra Pradesh. And very clearly,
I am not going to support any party that wants to play divisive
politics.</p>
<p>Next let me come to <a class="reference external" href="http://en.wikipedia.org/wiki/India">India</a> in general, no statesmen here too...
There is a slugfest in the parliament over no or a very trivial
issue. No one wants to punish people who want to divide India based
on region, caste or religion. A bigger diversion nowadays is
the global financial crisis. Major issues like lack of infrastructure,
poverty have taken a back seat and all one talks of nowadays is the
<a class="reference external" href="http://en.wikipedia.org/wiki/BSE_Sensex">SENSEX</a> (which many people mistake for the exchange).</p>
<p>Now let's talk about global politicians. Never did I expect such
dirty politics to be played in the US election campaign and the
comparitively lukewarm action by most governments in reassuring their
people about the global financial crisis.</p>
<p>You might wonder why I wrote such a tangential post. Read on...</p>
<p>Recently, I was having a discussion with my colleague
about the state of politics and statesmanship in India and soon
he too connected very well with the issue and started giving
parallels in his country. We continued the discussion for hours
but none of this was productive for us or for our countries...</p>
<p><strong>PS:</strong> The next time you want to start a conversation, it's best you
pick politics and lament about it's sorryful state and you will have
a very lively discussion. Great conversation starter!!! (sic)</p>
</div>
Long time, no post...2008-10-24T00:00:00+00:002008-10-24T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-10-24:/personal/blog/2008/10/24/long-time-no-post/<div class="section" id="id1">
<h2>Long time, no post...</h2>
<p>It's been a long time, since I posted content in the <a class="reference external" href="http://thejaswi.info/blog/">blog</a>. There have been
quite a few reasons for that and I primarily blame <strong>laziness</strong>.</p>
<p>Just a quick update of what has been going on in my life:</p>
<ul class="simple">
<li>Completed work on my <a class="reference external" href="http://code.google.com/soc/">Google Summer of …</a></li></ul></div><div class="section" id="id1">
<h2>Long time, no post...</h2>
<p>It's been a long time, since I posted content in the <a class="reference external" href="http://thejaswi.info/blog/">blog</a>. There have been
quite a few reasons for that and I primarily blame <strong>laziness</strong>.</p>
<p>Just a quick update of what has been going on in my life:</p>
<ul class="simple">
<li>Completed work on my <a class="reference external" href="http://code.google.com/soc/">Google Summer of Code Project</a> and was happy
to see it in trunk. Work on it is never complete, I plan to continue
my work on it.</li>
<li>Joined <a class="reference external" href="http://www.citigroup.com/">Citigroup</a> as a Financial Analyst and am enjoying working with
a fantastic team, learning lots of cool stuff.</li>
<li>Finding <a class="reference external" href="http://en.wikipedia.org/wiki/Chennai">Chennai</a> quite a pain. The transition might take longer than
I thought, but I hope to get settled in soon...</li>
</ul>
<p>I hope to continue blogging more regularly and hopefully lots of <a class="reference external" href="http://www.djangoproject.com/">django</a>.</p>
</div>
Off to Chennai...life's calling2008-05-31T00:00:00+00:002008-05-31T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-05-31:/personal/blog/2008/05/31/chennailifes-calling/<div class="section" id="id1">
<h2>Off to Chennai....Life's calling</h2>
<p>The blog title says it all. I am moving to Chennai to take up a job with a subsidiary of <a class="reference external" href="http://en.wikipedia.org/wiki/Citigroup">Citigroup</a>. So for now, it is <em>Aadab</em> <a class="reference external" href="http://en.wikipedia.org/wiki/Hyderabad">Hyderabad</a> and <em>Vanakkam</em> <a class="reference external" href="http://en.wikipedia.org/wiki/Chennai">Chennai</a>. If you want to contact me check out the <a class="reference external" href="http://thejaswi.info/contact/">contact</a> page or the <a class="reference external" href="http://thejaswi.info/about/">about …</a></p></div><div class="section" id="id1">
<h2>Off to Chennai....Life's calling</h2>
<p>The blog title says it all. I am moving to Chennai to take up a job with a subsidiary of <a class="reference external" href="http://en.wikipedia.org/wiki/Citigroup">Citigroup</a>. So for now, it is <em>Aadab</em> <a class="reference external" href="http://en.wikipedia.org/wiki/Hyderabad">Hyderabad</a> and <em>Vanakkam</em> <a class="reference external" href="http://en.wikipedia.org/wiki/Chennai">Chennai</a>. If you want to contact me check out the <a class="reference external" href="http://thejaswi.info/contact/">contact</a> page or the <a class="reference external" href="http://thejaswi.info/about/">about</a> page for more details.</p>
<p>This also calls for adding a disclaimer to the footer of my blog.</p>
<p><strong>Disclaimer: All views, rants and ramblings expressed on this blog are solely mine and should not be attributed to either my employer or any third-party.</strong></p>
</div>
Enable/Disable CPUs dynamically in Linux2008-05-09T00:00:00+00:002008-05-09T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-05-09:/tech/blog/2008/05/09/enabledisable-cpus-dynamically-linux/<div class="section" id="enable-disable-multi-cpus-in-gnu-linux">
<h2>Enable/Disable Multi CPUs in GNU/Linux</h2>
<p>This is a wonderful feature of the <a class="reference external" href="http://kernel.org/">Linux</a> kernel. Being able to dynamically enable and disable multiple CPUs (all this without rebooting).</p>
<p>To check if you have multiple CPUs</p>
<div class="highlight"><pre><span></span>$ cat /proc/cpuinfo
processor : <span class="m">0</span>
vendor_id : GenuineIntel
cpu family : <span class="m">6</span>
model : <span class="m">15</span>
model name …</pre></div></div><div class="section" id="enable-disable-multi-cpus-in-gnu-linux">
<h2>Enable/Disable Multi CPUs in GNU/Linux</h2>
<p>This is a wonderful feature of the <a class="reference external" href="http://kernel.org/">Linux</a> kernel. Being able to dynamically enable and disable multiple CPUs (all this without rebooting).</p>
<p>To check if you have multiple CPUs</p>
<div class="highlight"><pre><span></span>$ cat /proc/cpuinfo
processor : <span class="m">0</span>
vendor_id : GenuineIntel
cpu family : <span class="m">6</span>
model : <span class="m">15</span>
model name : Intel<span class="o">(</span>R<span class="o">)</span> Core<span class="o">(</span>TM<span class="o">)</span><span class="m">2</span> Duo CPU T7100 @ <span class="m">1</span>.80GHz
stepping : <span class="m">13</span>
cpu MHz : <span class="m">1795</span>.675
cache size : <span class="m">2048</span> KB
physical id : <span class="m">0</span>
siblings : <span class="m">2</span>
core id : <span class="m">0</span>
cpu cores : <span class="m">2</span>
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : <span class="m">10</span>
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe
nx lm constant_tsc arch_perfmon pebs bts pni monitor ds_cpl
vmx est tm2 ssse3 cx16 xtpr lahf_lm ida
bogomips : <span class="m">3596</span>.78
clflush size : <span class="m">64</span>
processor : <span class="m">1</span>
vendor_id : GenuineIntel
cpu family : <span class="m">6</span>
model : <span class="m">15</span>
model name : Intel<span class="o">(</span>R<span class="o">)</span> Core<span class="o">(</span>TM<span class="o">)</span><span class="m">2</span> Duo CPU T7100 @ <span class="m">1</span>.80GHz
stepping : <span class="m">13</span>
cpu MHz : <span class="m">1795</span>.675
cache size : <span class="m">2048</span> KB
physical id : <span class="m">0</span>
siblings : <span class="m">2</span>
core id : <span class="m">1</span>
cpu cores : <span class="m">2</span>
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : <span class="m">10</span>
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe
nx lm constant_tsc arch_perfmon pebs bts pni monitor ds_cpl
vmx est tm2 ssse3 cx16 xtpr lahf_lm ida
bogomips : <span class="m">3591</span>.16
clflush size : <span class="m">64</span>
</pre></div>
<p>So I have two cpus. Now to dynamically disable the second CPU.</p>
<div class="highlight"><pre><span></span><span class="c1"># echo 0 > /sys/devices/system/cpu/cpuX/online</span>
</pre></div>
<p>Here X is any number between 1 and the maximum number of CPUs. Observe the output of cpuinfo to check if the previous step worked.</p>
<p>To dynamically enable it,</p>
<div class="highlight"><pre><span></span><span class="c1"># echo 1 > /sys/devices/system/cpu/cpuX/online</span>
</pre></div>
<p><strong>Note:</strong> Not all CPU architectures have support for this feature.</p>
<p>There are a lot of advantages of this feature:</p>
<ul class="simple">
<li>Helps in benchmark tests (when you want to know the performance of your code over multiple and single cpus).</li>
<li>Helps you save that extra bit of power (esp on battery) in desparate situations.</li>
</ul>
</div>
WPA2 on Linux2008-05-08T00:00:00+00:002008-05-08T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-05-08:/tech/blog/2008/05/08/wpa2-linux/<div class="section" id="setting-up-wpa2-on-linux">
<h2>Setting up WPA2 on Linux</h2>
<p>Recently <a class="reference external" href="http://www.linkedin.com/in/binand">Binand</a> pointed me to <a class="reference external" href="http://www.dd-wrt.com/">DD-WRT</a> (free Linux based firmware for Linksys' WRT54G Series). Since I owned that series of the router, I installed it on my router. It looks really very cool especially with those awesome javascript effects. It also came with support for …</p></div><div class="section" id="setting-up-wpa2-on-linux">
<h2>Setting up WPA2 on Linux</h2>
<p>Recently <a class="reference external" href="http://www.linkedin.com/in/binand">Binand</a> pointed me to <a class="reference external" href="http://www.dd-wrt.com/">DD-WRT</a> (free Linux based firmware for Linksys' WRT54G Series). Since I owned that series of the router, I installed it on my router. It looks really very cool especially with those awesome javascript effects. It also came with support for <a class="reference external" href="http://en.wikipedia.org/wiki/RADIUS">RADIUS</a>.</p>
<p>For the first time, I decided to close my network to outsiders and hence used <a class="reference external" href="http://en.wikipedia.org/wiki/Wired_Equivalent_Privacy">WEP</a> authentication. During a discussion with <a class="reference external" href="http://www.linkedin.com/in/binand">Binand</a> later on, he told me that <a class="reference external" href="http://en.wikipedia.org/wiki/Wired_Equivalent_Privacy">WEP</a> was almost obsolete and insecure. He asked me to go in for <a class="reference external" href="http://en.wikipedia.org/wiki/Wi-Fi_Protected_Access">WPA-PSK</a>.</p>
<p>Here's the step by step process of setting up WPA on GNU/Linux. (I am blogging about this as a personal archive, but if you find it useful do let me know :)</p>
<ul class="simple">
<li><strong>Setup your router to accept WPA</strong>:</li>
</ul>
<a class="reference external image-reference" href="http://media.thejaswi.info/images/blog_posts/router_wireless_auth.jpg"><img alt="Linksys Router Wireless Authentication Setup" class="align-center" src="http://media.thejaswi.info/images/blog_posts/router_wireless_auth_thumb.jpg" /></a>
<p>This part is the easiest. Just select a passphrase and the router is all set to use WPA.</p>
<ul>
<li><p class="first"><strong>Setup your laptop to communicate with router through WPA</strong>:</p>
<p>Quite an easy process. First run the <tt class="docutils literal">wpa_passphrase</tt> command-line utility and provide it the <a class="reference external" href="http://en.wikipedia.org/wiki/SSID">SSID</a> of the router and the password provided in the router.</p>
</li>
</ul>
<div class="highlight"><pre><span></span><span class="o">[</span>theju@localhost Desktop<span class="o">]</span>$ /usr/sbin/wpa_passphrase linksys password
<span class="nv">network</span><span class="o">={</span>
<span class="nv">ssid</span><span class="o">=</span><span class="s2">"linksys"</span>
<span class="c1">#psk="password"</span>
<span class="nv">psk</span><span class="o">=</span>ecc9991e3cfb1b117bdbbd00deb407f0232944b56821647e2349139d02fd2bfb
<span class="o">}</span>
<span class="o">[</span>theju@localhost Desktop<span class="o">]</span>$
</pre></div>
<p>Just copy this output and paste it in your <tt class="docutils literal">wpa_supplicant.conf</tt> (mine was located in <tt class="docutils literal">/etc/wpa_supplicant/wpa_supplicant.conf</tt>).</p>
<ul>
<li><p class="first"><strong>Run your WPA Client</strong>:</p>
<p>Run the client to start the authentication.</p>
</li>
</ul>
<div class="highlight"><pre><span></span><span class="o">[</span>root@localhost theju<span class="o">]</span><span class="c1"># /usr/sbin/wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf -d</span>
</pre></div>
<p>The above line specifies the interface, the path of the configuration file and directs the client to run in debug mode. If all goes well, you can run the client in the background.</p>
<div class="highlight"><pre><span></span><span class="o">[</span>root@localhost theju<span class="o">]</span><span class="c1"># /usr/sbin/wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf -B</span>
</pre></div>
<p>If you want to go a step further by enabling WPA at bootup, write a script and place it in <tt class="docutils literal">/etc/rc.d/init.d/</tt>.</p>
</div>
Thejaswi.info revamped2008-04-17T00:00:00+00:002008-04-17T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-04-17:/tech/blog/2008/04/17/thejaswi.info-revamped/<div class="section" id="id1">
<h2>Thejaswi.info revamped</h2>
<p><a class="reference external" href="http://www.djangoproject.com/">Django</a> has been evolving quietly but steadily. 6 months back when I deployed my site, I gambled and used <a class="reference external" href="http://code.djangoproject.com/wiki/NewformsAdminBranch">newforms-admin</a> to be able to experiment. Later, I realized that my blog had a few readers and experimentation would piss them off. Despite this, I managed to redesign …</p></div><div class="section" id="id1">
<h2>Thejaswi.info revamped</h2>
<p><a class="reference external" href="http://www.djangoproject.com/">Django</a> has been evolving quietly but steadily. 6 months back when I deployed my site, I gambled and used <a class="reference external" href="http://code.djangoproject.com/wiki/NewformsAdminBranch">newforms-admin</a> to be able to experiment. Later, I realized that my blog had a few readers and experimentation would piss them off. Despite this, I managed to redesign the look of the site twice. This time, the site has been written, designed and deployed from scratch taking benefit of a lot of new features of django and other technologies. For the first time, I have managed to stick to certain <strong>"best practices"</strong> while developing and deploying the site. I keep my <em>"fingers crossed"</em> and hope the site is future proof.</p>
<p>The new features of the site are:</p>
<ul class="simple">
<li>Support for <a class="reference external" href="http://www.djangoproject.com/documentation/model-api/#slugfield">SlugField</a> in the Blog.</li>
<li>Search support brought to you by <a class="reference external" href="http://www.xapian.org/">xapian</a>.</li>
<li>Refactored blog code to make it faster.</li>
<li>Removed loads of crap features.</li>
<li>Media and static files are handled by <a class="reference external" href="http://nginx.net/">Nginx</a>.</li>
<li>The site is deployed on <a class="reference external" href="http://httpd.apache.org/">Apache</a> + <a class="reference external" href="http://www.modwsgi.org/">Mod-Wsgi</a>. Thanks <a class="reference external" href="http://blog.dscpl.com.au/">Graham Dumpleton</a></li>
<li>No...I have not moved the site to another hosting provider, I still use <a class="reference external" href="http://www.webfaction.com/">Webfaction</a>. I love their service but only wish they provide VPS support and help people like me avoid the pain of compiling packages from scratch.</li>
<li>New UI inspired heavily from <a class="reference external" href="http://code.macournoyer.com/thin/">Thin's</a> site.</li>
<li>Dynamic feeds. No more feed generation through cron jobs.</li>
</ul>
</div>
Learning Python 12008-04-08T00:00:00+00:002008-04-08T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-04-08:/tech/blog/2008/04/08/learning-python-1/<div class="section" id="interesting-aspect-of-python-1">
<h2>Interesting aspect of Python : 1</h2>
<p>Yesterday I learnt an interesting aspect of <a class="reference external" href="http://www.python.org/">python</a> called <a class="reference external" href="http://en.wikipedia.org/wiki/Python_syntax_and_semantics">closures</a>.</p>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">a</span><span class="p">(</span><span class="n">aa1</span><span class="p">,</span> <span class="n">aa2</span><span class="o">=</span><span class="mi">10</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">b</span><span class="p">(</span><span class="n">bb1</span><span class="p">,</span> <span class="n">bb2</span><span class="o">=</span><span class="n">aa2</span><span class="p">):</span>
<span class="nb">print</span> <span class="n">aa1</span><span class="p">,</span> <span class="n">aa2</span><span class="p">,</span> <span class="n">bb1</span><span class="p">,</span> <span class="n">bb2</span>
<span class="n">aa1</span><span class="o">+=</span><span class="mi">100</span>
<span class="n">aa2</span><span class="o">+=</span><span class="mi">100</span>
<span class="k">return</span> <span class="n">b</span>
<span class="o">>>></span> <span class="n">a</span><span class="p">(</span><span class="mi">20</span><span class="p">)(</span><span class="mi">5</span><span class="p">)</span>
</pre></div>
<p><em>What is the output?</em></p>
<p>The answer by intuition would have been …</p></div><div class="section" id="interesting-aspect-of-python-1">
<h2>Interesting aspect of Python : 1</h2>
<p>Yesterday I learnt an interesting aspect of <a class="reference external" href="http://www.python.org/">python</a> called <a class="reference external" href="http://en.wikipedia.org/wiki/Python_syntax_and_semantics">closures</a>.</p>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">a</span><span class="p">(</span><span class="n">aa1</span><span class="p">,</span> <span class="n">aa2</span><span class="o">=</span><span class="mi">10</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">b</span><span class="p">(</span><span class="n">bb1</span><span class="p">,</span> <span class="n">bb2</span><span class="o">=</span><span class="n">aa2</span><span class="p">):</span>
<span class="nb">print</span> <span class="n">aa1</span><span class="p">,</span> <span class="n">aa2</span><span class="p">,</span> <span class="n">bb1</span><span class="p">,</span> <span class="n">bb2</span>
<span class="n">aa1</span><span class="o">+=</span><span class="mi">100</span>
<span class="n">aa2</span><span class="o">+=</span><span class="mi">100</span>
<span class="k">return</span> <span class="n">b</span>
<span class="o">>>></span> <span class="n">a</span><span class="p">(</span><span class="mi">20</span><span class="p">)(</span><span class="mi">5</span><span class="p">)</span>
</pre></div>
<p><em>What is the output?</em></p>
<p>The answer by intuition would have been 20 10 5 10. The answer however is 120 110 5 10.</p>
<p>I was amazed by this result and wanted to figure out how this works. I ran pdb on this function using</p>
<div class="highlight"><pre><span></span>$ python -m pdb test_fn.py
</pre></div>
<p>The result of it was:</p>
<div class="highlight"><pre><span></span><span class="o">></span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">theju</span><span class="o">/</span><span class="n">test_fn</span><span class="o">.</span><span class="n">py</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o"><</span><span class="n">module</span><span class="o">></span><span class="p">()</span>
<span class="o">-></span> <span class="k">def</span> <span class="nf">a</span><span class="p">(</span><span class="n">aa1</span><span class="p">,</span> <span class="n">aa2</span><span class="o">=</span><span class="mi">10</span><span class="p">):</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span> <span class="n">s</span>
<span class="o">></span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">theju</span><span class="o">/</span><span class="n">test_fn</span><span class="o">.</span><span class="n">py</span><span class="p">(</span><span class="mi">8</span><span class="p">)</span><span class="o"><</span><span class="n">module</span><span class="o">></span><span class="p">()</span>
<span class="o">-></span> <span class="n">a</span><span class="p">(</span><span class="mi">20</span><span class="p">)(</span><span class="mi">5</span><span class="p">)</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span>
<span class="o">--</span><span class="n">Call</span><span class="o">--</span>
<span class="o">></span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">theju</span><span class="o">/</span><span class="n">test_fn</span><span class="o">.</span><span class="n">py</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="n">a</span><span class="p">()</span>
<span class="o">-></span> <span class="k">def</span> <span class="nf">a</span><span class="p">(</span><span class="n">aa1</span><span class="p">,</span> <span class="n">aa2</span><span class="o">=</span><span class="mi">10</span><span class="p">):</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span>
<span class="o">></span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">theju</span><span class="o">/</span><span class="n">test_fn</span><span class="o">.</span><span class="n">py</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="n">a</span><span class="p">()</span>
<span class="o">-></span> <span class="k">def</span> <span class="nf">b</span><span class="p">(</span><span class="n">bb1</span><span class="p">,</span> <span class="n">bb2</span><span class="o">=</span><span class="n">aa2</span><span class="p">):</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span> <span class="nb">dir</span><span class="p">()</span>
<span class="p">[</span><span class="s1">'aa1'</span><span class="p">,</span><span class="s1">'aa2'</span><span class="p">]</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span> <span class="n">s</span>
<span class="o">></span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">theju</span><span class="o">/</span><span class="n">test_fn</span><span class="o">.</span><span class="n">py</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span><span class="n">a</span><span class="p">()</span>
<span class="o">-></span> <span class="n">aa1</span><span class="o">+=</span><span class="mi">100</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span> <span class="nb">dir</span><span class="p">()</span>
<span class="p">[</span><span class="s1">'aa1'</span><span class="p">,</span> <span class="s1">'aa2'</span><span class="p">,</span> <span class="s1">'b'</span><span class="p">]</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span> <span class="nb">dir</span><span class="p">(</span><span class="n">b</span><span class="p">)</span>
<span class="p">[</span><span class="s1">'__call__'</span><span class="p">,</span> <span class="s1">'__class__'</span><span class="p">,</span> <span class="s1">'__delattr__'</span><span class="p">,</span> <span class="s1">'__dict__'</span><span class="p">,</span> <span class="s1">'__doc__'</span><span class="p">,</span> <span class="s1">'__get__'</span><span class="p">,</span> <span class="s1">'__getattribute__'</span><span class="p">,</span> <span class="s1">'__hash__'</span><span class="p">,</span> <span class="s1">'__init__'</span><span class="p">,</span>
<span class="s1">'__module__'</span><span class="p">,</span> <span class="s1">'__name__'</span><span class="p">,</span> <span class="s1">'__new__'</span><span class="p">,</span> <span class="s1">'__reduce__'</span><span class="p">,</span> <span class="s1">'__reduce_ex__'</span><span class="p">,</span> <span class="s1">'__repr__'</span><span class="p">,</span> <span class="s1">'__setattr__'</span><span class="p">,</span> <span class="s1">'__str__'</span><span class="p">,</span> <span class="s1">'func_closure'</span><span class="p">,</span>
<span class="s1">'func_code'</span><span class="p">,</span> <span class="s1">'func_defaults'</span><span class="p">,</span> <span class="s1">'func_dict'</span><span class="p">,</span> <span class="s1">'func_doc'</span><span class="p">,</span> <span class="s1">'func_globals'</span><span class="p">,</span> <span class="s1">'func_name'</span><span class="p">]</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span> <span class="n">p</span> <span class="n">b</span><span class="o">.</span><span class="n">func_defaults</span>
<span class="p">(</span><span class="mi">10</span><span class="p">,)</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span> <span class="n">s</span>
<span class="o">></span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">theju</span><span class="o">/</span><span class="n">test_fn</span><span class="o">.</span><span class="n">py</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span><span class="n">a</span><span class="p">()</span>
<span class="o">-></span> <span class="n">aa2</span><span class="o">+=</span><span class="mi">100</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span>
<span class="o">></span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">theju</span><span class="o">/</span><span class="n">test_fn</span><span class="o">.</span><span class="n">py</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="n">a</span><span class="p">()</span>
<span class="o">-></span> <span class="k">return</span> <span class="n">b</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span>
<span class="o">--</span><span class="n">Return</span><span class="o">--</span>
<span class="o">></span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">theju</span><span class="o">/</span><span class="n">test_fn</span><span class="o">.</span><span class="n">py</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="n">a</span><span class="p">()</span><span class="o">-><</span><span class="n">functio</span><span class="o">...</span><span class="n">b7c6adbc</span><span class="o">></span>
<span class="o">-></span> <span class="k">return</span> <span class="n">b</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span>
<span class="o">--</span><span class="n">Call</span><span class="o">--</span>
<span class="o">></span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">theju</span><span class="o">/</span><span class="n">test_fn</span><span class="o">.</span><span class="n">py</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="n">b</span><span class="p">()</span>
<span class="o">-></span> <span class="k">def</span> <span class="nf">b</span><span class="p">(</span><span class="n">bb1</span><span class="p">,</span> <span class="n">bb2</span><span class="o">=</span><span class="n">aa2</span><span class="p">):</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span>
<span class="o">></span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">theju</span><span class="o">/</span><span class="n">test_fn</span><span class="o">.</span><span class="n">py</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="n">b</span><span class="p">()</span>
<span class="o">-></span> <span class="nb">print</span> <span class="n">aa1</span><span class="p">,</span> <span class="n">aa2</span><span class="p">,</span> <span class="n">bb1</span><span class="p">,</span> <span class="n">bb2</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span>
<span class="mi">120</span> <span class="mi">110</span> <span class="mi">5</span> <span class="mi">10</span>
<span class="o">--</span><span class="n">Return</span><span class="o">--</span>
<span class="o">></span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">theju</span><span class="o">/</span><span class="n">test_fn</span><span class="o">.</span><span class="n">py</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="n">b</span><span class="p">()</span><span class="o">-></span><span class="kc">None</span>
<span class="o">-></span> <span class="nb">print</span> <span class="n">aa1</span><span class="p">,</span> <span class="n">aa2</span><span class="p">,</span> <span class="n">bb1</span><span class="p">,</span> <span class="n">bb2</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span>
<span class="o">--</span><span class="n">Return</span><span class="o">--</span>
<span class="o">></span> <span class="o">/</span><span class="n">home</span><span class="o">/</span><span class="n">theju</span><span class="o">/</span><span class="n">test_fn</span><span class="o">.</span><span class="n">py</span><span class="p">(</span><span class="mi">8</span><span class="p">)</span><span class="o"><</span><span class="n">module</span><span class="o">></span><span class="p">()</span><span class="o">-></span><span class="kc">None</span>
<span class="o">-></span> <span class="n">a</span><span class="p">(</span><span class="mi">20</span><span class="p">)(</span><span class="mi">5</span><span class="p">)</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span>
<span class="o">--</span><span class="n">Return</span><span class="o">--</span>
<span class="o">></span> <span class="o"><</span><span class="n">string</span><span class="o">></span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o"><</span><span class="n">module</span><span class="o">></span><span class="p">()</span><span class="o">-></span><span class="kc">None</span>
<span class="p">(</span><span class="n">Pdb</span><span class="p">)</span>
</pre></div>
<p>The default parameter values are evaluated when the function definition is executed. See <a class="reference external" href="http://docs.python.org/ref/function.html#l2h-634">this</a> for more details.</p>
<p>Thanks to <a class="reference external" href="http://gopi-goswami.net/">Gopi</a> for helping me learn this concept and more.</p>
</div>
Useful yet underutilized commands2008-03-30T00:00:00+00:002008-03-30T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-03-30:/tech/blog/2008/03/30/useful-yet-underutilized-commands/<div class="section" id="id1">
<h2>Useful yet underutilized commands</h2>
<p>Recently, I have started looking towards system programming (thanks to my arm processor project). While I was glancing through the manual pages, I noticed these commands that are extremely useful but rarely used (or probably implicity used).</p>
<p>Here they are:</p>
<ul class="simple">
<li>csplit: split a file into sections …</li></ul></div><div class="section" id="id1">
<h2>Useful yet underutilized commands</h2>
<p>Recently, I have started looking towards system programming (thanks to my arm processor project). While I was glancing through the manual pages, I noticed these commands that are extremely useful but rarely used (or probably implicity used).</p>
<p>Here they are:</p>
<ul class="simple">
<li>csplit: split a file into sections determined by context lines</li>
</ul>
<p>Very useful command. Helps breaking a file according to regexps, number of lines etc.</p>
<ul class="simple">
<li>expand: convert tabs to spaces</li>
</ul>
<p>Another useful command especially in the python world where they specifically discourage the use of tabs and prefer 4 spaces.</p>
<ul class="simple">
<li>fold: wrap each input line to fit in specified width</li>
</ul>
<p>Useful while getting your code to fit the terminal window or to fit PEP 8.</p>
<ul class="simple">
<li>fuser: identify processes using files or sockets</li>
</ul>
<p>Had used this command earlier but didn't know that it could be used for TCP sockets also.</p>
<ul class="simple">
<li>iconv: Convert encoding of given files from one encoding to another</li>
</ul>
<p>Very useful. Recently this came handy coverting ISO88952 to UTF8.</p>
<ul class="simple">
<li>join: join lines of two files on a common field</li>
</ul>
<p>A life-saver sometimes.</p>
<ul class="simple">
<li>nl: number lines of files</li>
</ul>
<p>A super sexy utility that prints the line number to the left of the code.</p>
<p>Will write about more commands as I come across them.</p>
</div>
A USB Drive full of viruses2008-03-03T00:00:00+00:002008-03-03T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-03-03:/tech/blog/2008/03/03/a-usb-drive-full-of-viruses/<div class="section" id="id1">
<h2>A USB Drive Full of Viruses</h2>
<p>Yesterday, when I plugged in my usb stick onto a <a class="reference external" href="http://vce.ac.in/">college</a> computer little did I realize that it would get infected with hundreds of viruses. Not that I am bothered by these viruses because I use <a class="reference external" href="http://www.gnu.org/gnu/linux-and-gnu.html">GNU/Linux</a>. I just wanted to safeguard my …</p></div><div class="section" id="id1">
<h2>A USB Drive Full of Viruses</h2>
<p>Yesterday, when I plugged in my usb stick onto a <a class="reference external" href="http://vce.ac.in/">college</a> computer little did I realize that it would get infected with hundreds of viruses. Not that I am bothered by these viruses because I use <a class="reference external" href="http://www.gnu.org/gnu/linux-and-gnu.html">GNU/Linux</a>. I just wanted to safeguard my friends (no prizes for guessing which operating system they use ;-) ) who would share the USB disk. The stupid virus created an EXE file under every folder with the name of the parent folder. I could have written a small python script to have deleted the EXEs. But I decided to format it and get rid of all the viruses.</p>
<p>So here is what I did:</p>
<ul class="simple">
<li>First tried to figure out what was the exact device name of the USB drive. I plugged in the usb device and had a look at the dmesg output.</li>
</ul>
<div class="highlight"><pre><span></span>$ dmesg<span class="p">|</span>tail
</pre></div>
<p>The output that I got was</p>
<div class="highlight"><pre><span></span>sd <span class="m">3</span>:0:0:0: <span class="o">[</span>sdb<span class="o">]</span> Assuming drive cache: write through
sdb: sdb1
</pre></div>
<ul class="simple">
<li>Next I logged in as root and unmounted the drive and used the mkdosfs utility to format it.</li>
</ul>
<div class="highlight"><pre><span></span><span class="c1"># umount /dev/sdb1</span>
<span class="c1"># mkdosfs -F32 -I -c -v /dev/sdb1</span>
</pre></div>
<p>Once the process was completed, I unplugged it and plugged it back. The virginity (excuse the pun ;-) ) of the USB drive was restored.</p>
</div>
Mod-Wsgi or Mod-Python?2008-02-25T00:00:00+00:002008-02-25T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-02-25:/tech/blog/2008/02/25/mod-wsgi-or-mod-python/<div class="section" id="id1">
<h2>Mod_WSGI or Mod_Python?</h2>
<p><a class="reference external" href="http://thejaswi.info/blog/2008/02/23/">Recently</a>, I had the opportunity of <a class="reference external" href="http://www.djangobook.com/en/1.0/chapter20/">deploying django apps</a> that would receive heavy traffic and yet be lite on the memory because I was using a 256 MB virtual private server.</p>
<p><a class="reference external" href="http://www.djangoproject.com/">Django</a> has two options:</p>
<ul class="simple">
<li><a class="reference external" href="http://www.modpython.org/">Mod_Python</a></li>
<li><a class="reference external" href="http://www.modwsgi.org/">Mod_WSGI</a></li>
</ul>
<p>I have had bad experiences with Mod_Python with issues ranging …</p></div><div class="section" id="id1">
<h2>Mod_WSGI or Mod_Python?</h2>
<p><a class="reference external" href="http://thejaswi.info/blog/2008/02/23/">Recently</a>, I had the opportunity of <a class="reference external" href="http://www.djangobook.com/en/1.0/chapter20/">deploying django apps</a> that would receive heavy traffic and yet be lite on the memory because I was using a 256 MB virtual private server.</p>
<p><a class="reference external" href="http://www.djangoproject.com/">Django</a> has two options:</p>
<ul class="simple">
<li><a class="reference external" href="http://www.modpython.org/">Mod_Python</a></li>
<li><a class="reference external" href="http://www.modwsgi.org/">Mod_WSGI</a></li>
</ul>
<p>I have had bad experiences with Mod_Python with issues ranging from memory leaks to difficult configuration. Off late there has been lots of talk about Mod_Wsgi and it's performance.</p>
<p>I decided to do a benchmark test to figure out the truth. For the benchmark test I used Apache 2.2.8 with prefork MPM. I used apache's inbuilt benchamark analyzer <a class="reference external" href="http://httpd.apache.org/docs/2.0/programs/ab.html">ab</a> for the test. The single media file that was being served was a single SWF file with a size of 350KB. The multiple media files being images from a gallery app. Here are the results of a 1000 non-concurrent requests being served:</p>
<div class="section" id="mod-python-serving-media">
<h3>Mod-Python serving media</h3>
<div class="section" id="single-media-file">
<h4>Single media file</h4>
<pre class="code literal-block">
Total transferred: 4515000 bytes
HTML transferred: 4335000 bytes
Requests per second: 140.90 [#/sec] (mean)
Time per request: 7.097 [ms] (mean)
Time per request: 7.097 [ms] (mean, across all concurrent requests)
Transfer rate: 621.21 [Kbytes/sec] received
</pre>
</div>
<div class="section" id="multiple-media-files">
<h4>Multiple media files</h4>
<pre class="code literal-block">
Total transferred: 6789000 bytes
HTML transferred: 6595000 bytes
Requests per second: 10.95 [#/sec] (mean)
Time per request: 91.294 [ms] (mean)
Time per request: 91.294 [ms] (mean, across all concurrent requests)
Transfer rate: 72.61 [Kbytes/sec] received
</pre>
</div>
</div>
<div class="section" id="mod-wsgi-serving-media">
<h3>Mod-WSGI serving media</h3>
<div class="section" id="id2">
<h4>Single media file</h4>
<pre class="code literal-block">
Total transferred: 4513000 bytes
HTML transferred: 4335000 bytes
Requests per second: 158.71 [#/sec] (mean)
Time per request: 6.301 [ms] (mean)
Time per request: 6.301 [ms] (mean, across all concurrent requests)
Transfer rate: 699.43 [Kbytes/sec] received
</pre>
</div>
<div class="section" id="id3">
<h4>Multiple media files</h4>
<pre class="code literal-block">
Total transferred: 6787000 bytes
HTML transferred: 6595000 bytes
Requests per second: 11.05 [#/sec] (mean)
Time per request: 90.487 [ms] (mean)
Time per request: 90.487 [ms] (mean, across all concurrent requests)
Transfer rate: 73.24 [Kbytes/sec] received
</pre>
</div>
</div>
<div class="section" id="mod-python-with-apache-serving-media">
<h3>Mod-Python with Apache serving media</h3>
<div class="section" id="id4">
<h4>Single media file</h4>
<pre class="code literal-block">
Total transferred: 4515000 bytes
HTML transferred: 4335000 bytes
Requests per second: 141.61 [#/sec] (mean)
Time per request: 7.061 [ms] (mean)
Time per request: 7.061 [ms] (mean, across all concurrent requests)
Transfer rate: 624.37 [Kbytes/sec] received
</pre>
</div>
<div class="section" id="id5">
<h4>Multiple media files</h4>
<pre class="code literal-block">
Total transferred: 6789000 bytes
HTML transferred: 6595000 bytes
Requests per second: 10.93 [#/sec] (mean)
Time per request: 91.470 [ms] (mean)
Time per request: 91.470 [ms] (mean, across all concurrent requests)
Transfer rate: 72.47 [Kbytes/sec] received
</pre>
</div>
</div>
<div class="section" id="mod-wsgi-with-apache-serving-media">
<h3>Mod-WSGI with Apache serving media</h3>
<div class="section" id="id6">
<h4>Single media file</h4>
<pre class="code literal-block">
Total transferred: 4513000 bytes
HTML transferred: 4335000 bytes
Requests per second: 159.35 [#/sec] (mean)
Time per request: 6.275 [ms] (mean)
Time per request: 6.275 [ms] (mean, across all concurrent requests)
Transfer rate: 702.27 [Kbytes/sec] received
</pre>
</div>
<div class="section" id="id7">
<h4>Multiple media files</h4>
<pre class="code literal-block">
Total transferred: 6787000 bytes
HTML transferred: 6595000 bytes
Requests per second: 11.12 [#/sec] (mean)
Time per request: 89.922 [ms] (mean)
Time per request: 89.922 [ms] (mean, across all concurrent requests)
Transfer rate: 73.70 [Kbytes/sec] received
</pre>
</div>
</div>
<div class="section" id="mod-wsgi-with-nginx-serving-media">
<h3>Mod-WSGI with Nginx serving media</h3>
<div class="section" id="id8">
<h4>Single media file</h4>
<pre class="code literal-block">
Total transferred: 4472000 bytes
HTML transferred: 4335000 bytes
Requests per second: 344.56 [#/sec] (mean)
Time per request: 2.902 [ms] (mean)
Time per request: 2.902 [ms] (mean, across all concurrent requests)
Transfer rate: 1504.68 [Kbytes/sec] received
</pre>
</div>
<div class="section" id="id9">
<h4>Multiple media files</h4>
<pre class="code literal-block">
Total transferred: 6746000 bytes
HTML transferred: 6595000 bytes
Requests per second: 28.77 [#/sec] (mean)
Time per request: 34.760 [ms] (mean)
Time per request: 34.760 [ms] (mean, across all concurrent requests)
Transfer rate: 189.50 [Kbytes/sec] received
</pre>
</div>
</div>
<div class="section" id="conclusion">
<h3>Conclusion</h3>
<p>Mod-WSGI gives a 12.5% improvement in performance while serving a single media file while it gives a mere 1% improvement while serving multiple media files. Not much change is seen while apache is made to serve the media, the figures show a small performance improvement. When Nginx comes into the picture it blows away apache to bits. It gives a 116% improvement while serving a single media file and 160% improvement while serving multiple media files. Use <a class="reference external" href="http://nginx.net/">Nginx</a> to serve static media (and for <a class="reference external" href="http://en.wikipedia.org/wiki/Reverse_proxy">reverse proxying</a>) and notice the performance difference.</p>
</div>
</div>
Some Latest Projects2008-02-23T00:00:00+00:002008-02-23T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-02-23:/tech/blog/2008/02/23/some-latest-projects/<div class="section" id="id1">
<h2>Some latest projects</h2>
<p>I have been mum over the past couple of weeks because I have been busy with (sigh!!! repetitive) work. I have been involved with the websites of <a class="reference external" href="http://euphoria08.com/">Euphoria</a> (the cultural fest of my <a class="reference external" href="http://vce.ac.in/">college</a>) and <a class="reference external" href="http://csfest08.org/">CSFest</a> (the technical fest of the CSE Department). Both the sites use …</p></div><div class="section" id="id1">
<h2>Some latest projects</h2>
<p>I have been mum over the past couple of weeks because I have been busy with (sigh!!! repetitive) work. I have been involved with the websites of <a class="reference external" href="http://euphoria08.com/">Euphoria</a> (the cultural fest of my <a class="reference external" href="http://vce.ac.in/">college</a>) and <a class="reference external" href="http://csfest08.org/">CSFest</a> (the technical fest of the CSE Department). Both the sites use <a class="reference external" href="http://www.adobe.com/products/flex/">Adobe Flex</a> for the presentation layer and <a class="reference external" href="http://www.djangoproject.com/">Django</a> at the backend. The sites run on <cite>Apache HTTP</cite> server with <a class="reference external" href="http://www.modwsgi.org/">Mod_wsgi</a> and use <a class="reference external" href="http://nginx.net/">nginx</a> to serve static media and as a <a class="reference external" href="http://en.wikipedia.org/wiki/Reverse_proxy">reverse proxy</a>.</p>
</div>
Ramblings on Fossconf 082008-02-05T00:00:00+00:002008-02-05T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-02-05:/tech/blog/2008/02/05/ramblings-on-fossconf-08/<div class="section" id="ramblings-on-fossconf-chennai-08">
<h2>Ramblings on Fossconf Chennai'08</h2>
<p>Went to <a class="reference external" href="http://en.wikipedia.org/wiki/Chennai">Chennai</a> to attend my second <a class="reference external" href="http://en.wikipedia.org/wiki/FOSS">FOSS</a> conference. Though <a class="reference external" href="http://fossconf.in/">Fossconf 08</a> did not live up to my expectations, it was a perfect conference for first time speakers and absolute newbies who had no idea of what Foss was. I was really impressed by the project …</p></div><div class="section" id="ramblings-on-fossconf-chennai-08">
<h2>Ramblings on Fossconf Chennai'08</h2>
<p>Went to <a class="reference external" href="http://en.wikipedia.org/wiki/Chennai">Chennai</a> to attend my second <a class="reference external" href="http://en.wikipedia.org/wiki/FOSS">FOSS</a> conference. Though <a class="reference external" href="http://fossconf.in/">Fossconf 08</a> did not live up to my expectations, it was a perfect conference for first time speakers and absolute newbies who had no idea of what Foss was. I was really impressed by the project showcase. 10 engineering colleges from all over Tamil Nadu showcased their projects.</p>
<p>One thing that I could observe was that the <a class="reference external" href="http://www.chennailug.org/">ILUGC</a> members worked perfectly hand in hand with <a class="reference external" href="http://nrcfoss.org.in/">NRCFOSS</a> folks and did a beautiful job. I haven't seen such a wonderful community anywhere. I guess the <a class="reference external" href="http://www.ilughyd.org.in/">ILUGHyd</a> folks need to learn from them.</p>
<p>On the whole I would give the conference a 3/5 rating. The next year I am sure Fossconf will be better organized and the common man will still not be disappointed.</p>
</div>
Rename tables in SQLite2008-01-28T00:00:00+00:002008-01-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-01-28:/tech/blog/2008/01/28/rename-tables-in-sqlite/<div class="section" id="rename-tables-easily-in-sqlite">
<h2>Rename tables easily in SQLite</h2>
<p><a class="reference external" href="http://code.google.com/p/django-tagging/">Django-Tagging</a> recently moved to version 0.2 and introduced certain <a class="reference external" href="http://code.google.com/p/django-tagging/wiki/BackwardsIncompatibleChanges">backward-incompatible</a> changes. Due to these changes the tagging support for my blog had broken. The remedy as per the wiki was renaming the tables:</p>
<ul class="simple">
<li>tag to tagging_tag</li>
<li>tagged_item to tagging_taggeditem</li>
</ul>
<p><a class="reference external" href="http://www.sqlite.org/">SQLite</a> does not have a …</p></div><div class="section" id="rename-tables-easily-in-sqlite">
<h2>Rename tables easily in SQLite</h2>
<p><a class="reference external" href="http://code.google.com/p/django-tagging/">Django-Tagging</a> recently moved to version 0.2 and introduced certain <a class="reference external" href="http://code.google.com/p/django-tagging/wiki/BackwardsIncompatibleChanges">backward-incompatible</a> changes. Due to these changes the tagging support for my blog had broken. The remedy as per the wiki was renaming the tables:</p>
<ul class="simple">
<li>tag to tagging_tag</li>
<li>tagged_item to tagging_taggeditem</li>
</ul>
<p><a class="reference external" href="http://www.sqlite.org/">SQLite</a> does not have a rename command, so here is what I did to rename the tables.</p>
<div class="highlight"><pre><span></span><span class="k">alter</span> <span class="k">table</span> <span class="n">tag</span> <span class="k">rename</span> <span class="k">to</span> <span class="n">tagging_tag</span><span class="p">;</span>
<span class="k">alter</span> <span class="k">table</span> <span class="n">tagged_item</span> <span class="k">rename</span> <span class="k">to</span> <span class="n">tagging_taggeditem</span><span class="p">;</span>
</pre></div>
<p>The other change was to change the keyword argument for a generic view tagged_object_list from model to queryset_or_model.</p>
<p>A special thanks to <a class="reference external" href="http://insin.webfactional.com/">Jonathan Buchanan</a> for the great tagging library. Tagging Support back into action!!!</p>
</div>
Flex and Django: Partners in Crime2008-01-26T00:00:00+00:002008-01-26T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-01-26:/tech/blog/2008/01/26/flex-and-django:-partners-in-crime/<div class="section" id="id1">
<h2>Flex and Django: Partners in Crime</h2>
<p>I have an interesting project coming up which requires a heady mix of <a class="reference external" href="http://www.adobe.com/products/flex/">Flex</a> and <a class="reference external" href="http://www.djangoproject.com/">Django</a>. If you are wondering how the two are being mixed, here is the simple answer. Flex will be used at the presentation level and Django at the application …</p></div><div class="section" id="id1">
<h2>Flex and Django: Partners in Crime</h2>
<p>I have an interesting project coming up which requires a heady mix of <a class="reference external" href="http://www.adobe.com/products/flex/">Flex</a> and <a class="reference external" href="http://www.djangoproject.com/">Django</a>. If you are wondering how the two are being mixed, here is the simple answer. Flex will be used at the presentation level and Django at the application level. This requires that the webapplication built with django, serialize all it's data to xml so that it can be easily fed to the flex app. The flex app has to parse this xml and render it accordingly.</p>
<p>Here are the sample apps that I wrote to test the integration.</p>
<div class="section" id="using-the-django-xml-serializer-to-communicate-with-the-flex-app">
<h3>Using the Django XML Serializer to communicate with the Flex App</h3>
</div>
<div class="section" id="the-flex-code">
<h3>The Flex Code</h3>
<div class="highlight"><pre><span></span><span class="cp"><?xml version="1.0" encoding="utf-8"?></span>
<span class="nt"><mx:Application</span> <span class="na">xmlns:mx=</span><span class="s">"http://www.adobe.com/2006/mxml"</span><span class="nt">></span>
<span class="nt"><mx:HttpService</span>
<span class="na">id=</span><span class="s">"fetchData"</span>
<span class="na">url=</span><span class="s">"http://127.0.0.1:8001/fetch/"</span>
<span class="nt">></span>
<span class="nt"></mx:HttpService></span>
<span class="nt"><mx:Panel</span>
<span class="na">layout=</span><span class="s">"vertical"</span>
<span class="na">title=</span><span class="s">"Button Test"</span>
<span class="nt">></span>
<span class="nt"><mx:Button</span>
<span class="na">id=</span><span class="s">"testBtn"</span>
<span class="na">click=</span><span class="s">"fetchData.send();"</span>
<span class="na">label=</span><span class="s">"{fetchData.lastResult.childNodes}"</span>
<span class="nt">></span>
<span class="nt"></mx:Button></span>
<span class="nt"></mx:Panel></span>
<span class="nt"></mx:Application></span>
</pre></div>
</div>
<div class="section" id="the-django-code">
<h3>The Django Code</h3>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">fetch</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="n">response</span> <span class="o">=</span> <span class="n">HttpResponse</span><span class="p">()</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">SimplerXMLGenerator</span><span class="p">(</span><span class="n">out</span><span class="o">=</span><span class="n">response</span><span class="p">,</span><span class="n">encoding</span><span class="o">=</span><span class="s2">"utf-8"</span><span class="p">)</span>
<span class="n">s</span><span class="o">.</span><span class="n">startDocument</span><span class="p">()</span>
<span class="n">s</span><span class="o">.</span><span class="n">addQuickElement</span><span class="p">(</span><span class="s2">"objects"</span><span class="p">,</span><span class="s2">"Hello"</span><span class="p">)</span>
<span class="n">s</span><span class="o">.</span><span class="n">endDocument</span><span class="p">()</span>
<span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="n">response</span><span class="p">,</span> <span class="n">mimetype</span><span class="o">=</span><span class="s2">"text/xml"</span><span class="p">)</span>
</pre></div>
<p>When the testBtn is clicked its label gets assigned as Hello.</p>
</div>
<div class="section" id="posting-data-from-a-flex-form-to-be-handled-by-the-server">
<h3>Posting data from a flex form to be handled by the server.</h3>
<p>Here is a simple example of how a form built in Flex can post the data to the web application.</p>
</div>
<div class="section" id="id2">
<h3>The Flex Code</h3>
<div class="highlight"><pre><span></span> <span class="cp"><?xml version="1.0" encoding="utf-8"?></span>
<span class="nt"><mx:Application</span> <span class="na">xmlns:mx=</span><span class="s">"http://www.adobe.com/2006/mxml"</span><span class="nt">></span>
<span class="nt"><mx:Script></span>
<span class="cp"><![CDATA[</span>
<span class="cp"> private function sendData():void {</span>
<span class="cp"> var args:URLVariables = new URLVariables();</span>
<span class="cp"> args.first_name = firstName.text;</span>
<span class="cp"> args.last_name = lastName.text;</span>
<span class="cp"> args.age = age.text;</span>
<span class="cp"> var url:URLRequest = new URLRequest("/get_record/");</span>
<span class="cp"> url.method = "POST";</span>
<span class="cp"> url.data = args;</span>
<span class="cp"> navigateToURL(url);</span>
<span class="cp"> }</span>
<span class="cp"></mx:Script></span>
<span class="nt"><mx:Panel</span>
<span class="na">layout=</span><span class="s">"vertical"</span>
<span class="na">title=</span><span class="s">"Showing the Form"</span>
<span class="nt">></span>
<span class="nt"><mx:Form</span> <span class="na">id=</span><span class="s">"testForm"</span><span class="nt">></span>
<span class="nt"><mx:FormHeading</span> <span class="na">label=</span><span class="s">"Enter the details below."</span><span class="nt">/></span>
<span class="nt"><mx:FormItem</span> <span class="na">label=</span><span class="s">"First name"</span><span class="nt">></span>
<span class="nt"><mx:TextInput</span> <span class="na">id=</span><span class="s">"firstName"</span> <span class="na">width=</span><span class="s">"200"</span><span class="nt">/></span>
<span class="nt"></mx:FormItem></span>
<span class="nt"><mx:FormItem</span> <span class="na">label=</span><span class="s">"Last name"</span><span class="nt">></span>
<span class="nt"><mx:TextInput</span> <span class="na">id=</span><span class="s">"lastName"</span> <span class="na">width=</span><span class="s">"200"</span><span class="nt">/></span>
<span class="nt"></mx:FormItem></span>
<span class="nt"><mx:FormItem</span> <span class="na">label=</span><span class="s">"Age"</span><span class="nt">></span>
<span class="nt"><mx:TextInput</span> <span class="na">id=</span><span class="s">"age"</span> <span class="na">width=</span><span class="s">"25"</span><span class="nt">/></span>
<span class="nt"></mx:FormItem></span>
<span class="nt"><mx:FormItem></span>
<span class="nt"><mx:Button</span>
<span class="na">id=</span><span class="s">"btnSubmit"</span>
<span class="na">label=</span><span class="s">"Submit"</span>
<span class="na">click=</span><span class="s">"sendData();"</span>
<span class="nt">></span>
<span class="nt"></mx:Button></span>
<span class="nt"></mx:FormItem></span>
<span class="nt"></mx:Form></span>
<span class="nt"></mx:Panel></span>
<span class="nt"></mx:Application></span>
</pre></div>
</div>
<div class="section" id="id3">
<h3>The Django Code</h3>
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">get_record</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="n">post_data</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">POST</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
<span class="c1"># Process the data, raise errors if any and</span>
<span class="c1"># return whatever you want.</span>
<span class="c1"># Errors can be raised in actionscript in the</span>
<span class="c1"># flex code.</span>
</pre></div>
<p>This snippet when executed posts the Flex form data to the webapplication which can be handled accordingly.</p>
<p>So far this exercise of looking at the integration of Flex and Django has been quite easy. Only time will tell how much easy this will go on to be and how my project (if it goes beyond the bureaucratic hurdles) will progress.</p>
</div>
</div>
My new companion2008-01-25T00:00:00+00:002008-01-25T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-01-25:/personal/blog/2008/01/25/my-new-companion/<div class="section" id="id1">
<h2>My new companion</h2>
<p>Today, I purchased a notebook computer. (the <a class="reference external" href="http://www.thinkpad.com/">IBM ThinkPad</a> R61 <a class="reference external" href="http://www-307.ibm.com/pc/support/site.wss/quickPath.do?quickPathEntry=7733AE1">7733-AE1</a>).</p>
<a class="reference external image-reference" href="http://media.thejaswi.info/images/blog_posts/thinkpad_front_view.jpg"><img alt="IBM R-61 Front View Thumb" src="http://media.thejaswi.info/images/blog_posts/thinkpad_front_view_thumb.png" /></a>
<a class="reference external image-reference" href="http://media.thejaswi.info/images/blog_posts/thinkpad_back_view.jpg"><img alt="IBM-R61 Back View Thumb" src="http://media.thejaswi.info/images/blog_posts/thinkpad_back_view_thumb.png" /></a>
<a class="reference external image-reference" href="http://media.thejaswi.info/images/blog_posts/thinkpad_side_view.jpg"><img alt="IBM-R61 Side View Thumb" src="http://media.thejaswi.info/images/blog_posts/thinkpad_side_view_thumb.png" /></a>
<p>I am thoroughly impressed with the build quality of the machine. This notebook fit my requirements perfectly and I didn't have to shell out a rupee to <a class="reference external" href="http://www.microsoft.com/">Microsoft</a> because it came only with PC-Dos. I took …</p></div><div class="section" id="id1">
<h2>My new companion</h2>
<p>Today, I purchased a notebook computer. (the <a class="reference external" href="http://www.thinkpad.com/">IBM ThinkPad</a> R61 <a class="reference external" href="http://www-307.ibm.com/pc/support/site.wss/quickPath.do?quickPathEntry=7733AE1">7733-AE1</a>).</p>
<a class="reference external image-reference" href="http://media.thejaswi.info/images/blog_posts/thinkpad_front_view.jpg"><img alt="IBM R-61 Front View Thumb" src="http://media.thejaswi.info/images/blog_posts/thinkpad_front_view_thumb.png" /></a>
<a class="reference external image-reference" href="http://media.thejaswi.info/images/blog_posts/thinkpad_back_view.jpg"><img alt="IBM-R61 Back View Thumb" src="http://media.thejaswi.info/images/blog_posts/thinkpad_back_view_thumb.png" /></a>
<a class="reference external image-reference" href="http://media.thejaswi.info/images/blog_posts/thinkpad_side_view.jpg"><img alt="IBM-R61 Side View Thumb" src="http://media.thejaswi.info/images/blog_posts/thinkpad_side_view_thumb.png" /></a>
<p>I am thoroughly impressed with the build quality of the machine. This notebook fit my requirements perfectly and I didn't have to shell out a rupee to <a class="reference external" href="http://www.microsoft.com/">Microsoft</a> because it came only with PC-Dos. I took a live-cd of <a class="reference external" href="http://www.ubuntu.com/">Ubuntu</a> along to the <a class="reference external" href="http://local.google.co.in/?hl=en&q=pc+world&near=Secunderabad,+Hyderabad,+Andhra+Pradesh&fb=1&view=text&latlng=17478446,78414947,12920003221769108064">store</a> and checked up if all the peripherals would get detected. After booting in I had a look at the <a class="reference external" href="http://en.wikipedia.org/wiki/Dmesg">dmesg</a> log and figured out that this notebook was perfect for <a class="reference external" href="http://www.linux.org/">Linux</a>. Back home, I installed <a class="reference external" href="http://www.fedoraproject.org/">Fedora</a> and tried out a few test threaded programs with two cpus and a solo cpu.</p>
<p><strong>Conclusion</strong>: Threaded applications perform better off on multiple cpus but the programming becomes slightly cumbersome and needs lots of care.</p>
</div>
Launch of Safebrowsing-python2008-01-17T00:00:00+00:002008-01-17T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-01-17:/tech/blog/2008/01/17/launch-of-safebrowsing-python/<div class="section" id="id1">
<h2>Launch of Safebrowsing-python</h2>
<p>Today I launched my second project online after <a class="reference external" href="http://code.google.com/p/django-check-constraints/">django-check-constraints</a>, <a class="reference external" href="http://code.google.com/p/safebrowsing-python/">safebrowsing-python</a>. The project is based on the Google <a class="reference external" href="http://code.google.com/apis/safebrowsing/">Safebrowsing API</a>. Check out the announcement on the <a class="reference external" href="http://groups.google.com/group/google-safe-browsing-api">google-safebrowsing-api</a> mailing list and also the <a class="reference external" href="http://code.google.com/p/safebrowsing-python/wiki/Usage">usage</a> wiki page at the project home.</p>
<p>Wish you a happy and safe browsing on the …</p></div><div class="section" id="id1">
<h2>Launch of Safebrowsing-python</h2>
<p>Today I launched my second project online after <a class="reference external" href="http://code.google.com/p/django-check-constraints/">django-check-constraints</a>, <a class="reference external" href="http://code.google.com/p/safebrowsing-python/">safebrowsing-python</a>. The project is based on the Google <a class="reference external" href="http://code.google.com/apis/safebrowsing/">Safebrowsing API</a>. Check out the announcement on the <a class="reference external" href="http://groups.google.com/group/google-safe-browsing-api">google-safebrowsing-api</a> mailing list and also the <a class="reference external" href="http://code.google.com/p/safebrowsing-python/wiki/Usage">usage</a> wiki page at the project home.</p>
<p>Wish you a happy and safe browsing on the Web.</p>
</div>
An Idle Mind is a Devil's Workshop2008-01-12T00:00:00+00:002008-01-12T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-01-12:/tech/blog/2008/01/12/an-idle-mind-is-a-devil's-workshop/<div class="section" id="id1">
<h2>An idle mind is a devil's workshop</h2>
<p>On thursday, my previous semester results were out. I logged on to the site and checked out my result. My result was anything but surprising. Then I thought to myself, "Why not give people the freedom to compare their marks with their peers' …</p></div><div class="section" id="id1">
<h2>An idle mind is a devil's workshop</h2>
<p>On thursday, my previous semester results were out. I logged on to the site and checked out my result. My result was anything but surprising. Then I thought to myself, "Why not give people the freedom to compare their marks with their peers'".</p>
<p>This idea excited me and I wrote a <a class="reference external" href="http://www.python.org">python</a> script that used <a class="reference external" href="http://www.crummy.com/software/BeautifulSoup/">BeautifulSoup</a> to soup everyone's marks and then create an HTML table that would use <a class="reference external" href="http://developer.yahoo.com/yui/">YUI</a> for the ajaxy effect.</p>
<p>Thanks to Python's ultra simplicity and sheer power, my script was done in one and half hour after the results were out.</p>
<p>Check out the results at <a class="reference external" href="http://puthraya.webfactional.com/results.html">http://puthraya.webfactional.com/results.html</a> and <a class="reference external" href="http://puthraya.webfactional.com/consolidated_results.html">http://puthraya.webfactional.com/consolidated_results.html</a></p>
</div>
Rendevouz with Firefox 3 beta 22008-01-06T00:00:00+00:002008-01-06T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-01-06:/tech/blog/2008/01/06/rendevouz-with-firefox-3-beta-2/<div class="section" id="rendevouz-with-firefox3">
<h2>Rendevouz with Firefox3</h2>
<p>I have been using Firefox2 for quite a long time and had a hell lot of complaints about it. One was with its memory hogging nature and the other one was with its rendering capabilities.</p>
<p>I decided to try on Firefox 3 (beta 2) after hearing some …</p></div><div class="section" id="rendevouz-with-firefox3">
<h2>Rendevouz with Firefox3</h2>
<p>I have been using Firefox2 for quite a long time and had a hell lot of complaints about it. One was with its memory hogging nature and the other one was with its rendering capabilities.</p>
<p>I decided to try on Firefox 3 (beta 2) after hearing some rave reviews and here is my observation (not a research though). Firefox 3 has slimmed down to look svelte. To test it, I left the browser on for 18 hours without closing it for one second and I periodically kept loading <a class="reference external" href="http://www.gmail.com/">gmail</a> and <a class="reference external" href="http://www.digg.com/">digg</a> through a python script (that used the <a class="reference external" href="http://docs.python.org/lib/module-webbrowser.html">webbrowser</a> module). The browser survived and I noticed after the test that it had eaten only 76 MB of my memory. Not bad from what I have seen from Firefox2. Another joyful news is that Firefox 3 (beta 2) passes the <a class="reference external" href="http://www.webstandards.org/action/acid2/">Acid2</a> test.</p>
<p>Here's a proof to that.</p>
<a class="reference external image-reference" href="http://media.thejaswi.info/images/blog_posts/firefox_3_beta_acid2_test.png"><img alt="Firefox 3 beta 2 passes the Acid2 test" src="http://media.thejaswi.info/images/blog_posts/firefox_3_beta_acid2_test_thumb.png" /></a>
<p>An impact of passing the Acid2 test.</p>
<a class="reference external image-reference" href="http://media.thejaswi.info/images/blog_posts/my_site_firefox2.png"><img alt="Thejaswi.info using Firefox 2" src="http://media.thejaswi.info/images/blog_posts/my_site_firefox2_thumb.png" /></a>
<a class="reference external image-reference" href="http://media.thejaswi.info/images/blog_posts/my_site_firefox3.png"><img alt="Thejaswi.info using Firefox 3 beta 2" src="http://media.thejaswi.info/images/blog_posts/my_site_firefox3_thumb.png" /></a>
<p>Currently most plugins and extensions don't work properly but the browser is still in development and I am sure by the time the browser is released all such minor issues would be sorted out.</p>
<p>Well done Firefox devs!!!</p>
</div>
Javascript Code Colorizer2008-01-05T00:00:00+00:002008-01-05T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2008-01-05:/tech/blog/2008/01/05/javascript-code-colorizer/<div class="section" id="id1">
<h2>Javascript Code Colorizer</h2>
<p>Recently, I came across <a class="reference external" href="http://pygments.org/">Pygments</a> based Javacript code colorizer called <em>Pygments Code Colorizer</em> <a class="reference external" href="http://pygments.com/">here</a>. Very easy to use and supports lots of languages.</p>
<p>Just add the</p>
<div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">script</span> <span class="nx">src</span><span class="o">=</span><span class="s2">"http://www.pygments.com/js/init.js"</span><span class="o">><</span><span class="err">/script></span>
</pre></div>
<p>and a pre tag that contains the code to be highlighted …</p></div><div class="section" id="id1">
<h2>Javascript Code Colorizer</h2>
<p>Recently, I came across <a class="reference external" href="http://pygments.org/">Pygments</a> based Javacript code colorizer called <em>Pygments Code Colorizer</em> <a class="reference external" href="http://pygments.com/">here</a>. Very easy to use and supports lots of languages.</p>
<p>Just add the</p>
<div class="highlight"><pre><span></span><span class="o"><</span><span class="nx">script</span> <span class="nx">src</span><span class="o">=</span><span class="s2">"http://www.pygments.com/js/init.js"</span><span class="o">><</span><span class="err">/script></span>
</pre></div>
<p>and a pre tag that contains the code to be highlighted. That's it!!! Code highlighting on the fly using the power of <a class="reference external" href="http://pygments.org/">Pygments</a>. Another reason to rejoice is that Pygments.com is powered by <a class="reference external" href="http://www.djangoproject.com/">Django</a>.</p>
</div>
Day 1 of project2007-12-24T00:00:00+00:002007-12-24T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-12-24:/tech/blog/2007/12/24/day-1-of-project/<div class="section" id="id1">
<h2>Day 1 of Project</h2>
<p>Every final year student has to undertake a project and today was my first day. My project is to <strong>"Interface Flash ADCs and DACs with the ARM9 Processor"</strong>. The project guide gave us the <a class="reference external" href="http://www.arm.com/products/CPUs/families/ARM9Family.html">ARM9</a> target board user manual and asked us to read the instructions …</p></div><div class="section" id="id1">
<h2>Day 1 of Project</h2>
<p>Every final year student has to undertake a project and today was my first day. My project is to <strong>"Interface Flash ADCs and DACs with the ARM9 Processor"</strong>. The project guide gave us the <a class="reference external" href="http://www.arm.com/products/CPUs/families/ARM9Family.html">ARM9</a> target board user manual and asked us to read the instructions. Once done we tried getting the target board's monitor program appear on hyperterminal (hyperterminal sucks and <a class="reference external" href="http://en.wikipedia.org/wiki/Minicom">minicom</a> rocks). We were unlucky today but will try once again next week.</p>
<p>Here is a photograph of the board that I managed to click with my mobile phone without anyone noticing :).</p>
<img alt="ARM 920T Board" src="http://media.thejaswi.info/images/blog_posts/arm_920t_board.jpg" />
</div>
Django Book Online Update2007-12-17T00:00:00+00:002007-12-17T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-12-17:/tech/blog/2007/12/17/django-book-online-update/<div class="section" id="django-book-online-released">
<h2>Django Book Online Released</h2>
<p>A hearty congratulations to <a class="reference external" href="http://holovaty.com">Adrian Holovaty</a>, <a class="reference external" href="http://jacobian.org">Jacob Kaplan-Moss</a> and the and the <a class="reference external" href="http://www.djangoproject.com/community/">Django Community</a> for the release of the <a class="reference external" href="http://www.djangobook.com/en/1.0/">Django Book</a> online.</p>
<p>The book is an excellent read but there a few missing pieces. The in-built (and least documented) <a class="reference external" href="http://code.djangoproject.com/wiki/UsingFreeComment">comments</a> framework is missing from the <a class="reference external" href="http://www.djangobook.com/en/1.0/">Django …</a></p></div><div class="section" id="django-book-online-released">
<h2>Django Book Online Released</h2>
<p>A hearty congratulations to <a class="reference external" href="http://holovaty.com">Adrian Holovaty</a>, <a class="reference external" href="http://jacobian.org">Jacob Kaplan-Moss</a> and the and the <a class="reference external" href="http://www.djangoproject.com/community/">Django Community</a> for the release of the <a class="reference external" href="http://www.djangobook.com/en/1.0/">Django Book</a> online.</p>
<p>The book is an excellent read but there a few missing pieces. The in-built (and least documented) <a class="reference external" href="http://code.djangoproject.com/wiki/UsingFreeComment">comments</a> framework is missing from the <a class="reference external" href="http://www.djangobook.com/en/1.0/">Django Book</a>.</p>
<p>A review of the book after I have read it cover to cover. Check out this space for more updates regarding the book.</p>
</div>
Ramblings on Foss.in 20072007-12-08T00:00:00+00:002007-12-08T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-12-08:/tech/blog/2007/12/08/ramblings-on-foss.in-2007/<div class="section" id="my-ramblings-on-foss-in-2007">
<h2>My ramblings on Foss.in 2007</h2>
<p>I was quite excited to be attending my first <a class="reference external" href="http://www.fsf.org/">free software</a> conference. The excitement doubled when I heard a lot about <a class="reference external" href="http://foss.in/2007/">Foss.in</a> from previous attendees. Though the hype this time was low, I expected it to hold a lot for newbies like me …</p></div><div class="section" id="my-ramblings-on-foss-in-2007">
<h2>My ramblings on Foss.in 2007</h2>
<p>I was quite excited to be attending my first <a class="reference external" href="http://www.fsf.org/">free software</a> conference. The excitement doubled when I heard a lot about <a class="reference external" href="http://foss.in/2007/">Foss.in</a> from previous attendees. Though the hype this time was low, I expected it to hold a lot for newbies like me.</p>
<p>The organizers left not just me but a lot of others disappointed. This time <a class="reference external" href="http://foss.in/2007/">Foss.in</a> adopted the theme <strong>"How to contribute to Foss projects"</strong>. Sadly they did not realize that there are so few users of Foss software in India and it did not make sense to theme it. I would agree that contributors are very important but dedicating a whole conference for contributors at the cost of users is insane.</p>
<div class="section" id="developers-are-a-by-product-of-users">
<h3>Developers are a by-product of users</h3>
<p>When awareness is created about free software and people start using it, a small percentage of them might contribute to the movement. If a user is <strong>hell-bent</strong> on contributing, he will go to any ends to satsify that craving.</p>
<p>By expecting newbies (most of whom have not used or sparingly used free software) to sit through such talks will only boomerang.</p>
<p>I am sure there will be detractors to my previous statement. I challenge them to show data that shows newbies contributing after attending such events.</p>
</div>
<div class="section" id="dry-is-important">
<h3>DRY is important</h3>
<p>Most talks were centered around <a class="reference external" href="http://en.wikipedia.org/wiki/L10n">l10n</a> or <a class="reference external" href="http://en.wikipedia.org/wiki/I18n">i18n</a>. Again I have to agree with the organizers that l10n and i18n are crucial for wider adoption of free software but having so many (very similar) talks can really be painful.</p>
</div>
<div class="section" id="the-pros">
<h3>The pros</h3>
<p>Well I guess I had enough of ranting on the cons of Foss.in. But there were a couple of pros (which still couldn't overshadow the cons).</p>
<ul class="simple">
<li>One was the surprising inclusion of an accessibility talk at the Mozilla project days. The talk was given by <a class="reference external" href="http://foss.in/2007/register/speakers/talkdetailspub.php?talkid=546">Krishnakant Mane</a>. In this talk, he gave an overview of the need for accessibility and a small case study of how blind people (like him) can easily install GNU/Linux unassisted but can't even dream to do so with Windows.</li>
<li>The other was the felicitation of Naba Kumar and his wife (and the name of his pet project) Anjuta. Naba was the keynote speaker. Though his talk was slightly subdued (thanks to the theme of the conference) he did make it a point to give an overview of the <a class="reference external" href="http://anjuta.sourceforge.net/">Anjuta IDE</a>.</li>
</ul>
</div>
<div class="section" id="verdict">
<h3>Verdict</h3>
<p>Ignoring newbies is not a good sign. It gives a feeling of <strong>"casteism"</strong> when you cater only to a certain section of people.</p>
<p><strong>My 2 cents:</strong> If this is the way Foss.in will be conducted in the future then the organizers should consider naming the conference <strong>"Farce.in"</strong>.</p>
</div>
</div>
Newforms Custom Fields and Validation2007-11-18T00:00:00+00:002007-11-18T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-11-18:/tech/blog/2007/11/18/newforms-custom-fields-and-validation/<div class="section" id="id1">
<h2>Newforms Custom Fields and Validation</h2>
<p>Very often on the <a class="reference external" href="http://groups.google.com/group/django-users">Django Users</a> list people ask queries on how to add custom validation to <a class="reference external" href="http://www.djangoproject.com/documentation/newforms/">newform</a> fields.</p>
<p>To answer this question in two lines:</p>
<ul class="simple">
<li>Subclass the field to which you want to add custom validation.</li>
<li>Override the clean method to add your custom …</li></ul></div><div class="section" id="id1">
<h2>Newforms Custom Fields and Validation</h2>
<p>Very often on the <a class="reference external" href="http://groups.google.com/group/django-users">Django Users</a> list people ask queries on how to add custom validation to <a class="reference external" href="http://www.djangoproject.com/documentation/newforms/">newform</a> fields.</p>
<p>To answer this question in two lines:</p>
<ul class="simple">
<li>Subclass the field to which you want to add custom validation.</li>
<li>Override the clean method to add your custom validation.</li>
</ul>
<p>To give an idea, I will take an example of creating a <a class="reference external" href="http://en.wikipedia.org/wiki/Postal_Index_Number">Pincode</a> (Indian equivalent of <a class="reference external" href="http://en.wikipedia.org/wiki/Zip_code">ZipCode</a>) field. Before I start coding let me just give you a brief overview about Pincode so that you can understand the logic behind the validation.</p>
<div class="section" id="features-of-pincode">
<h3>Features of Pincode</h3>
<ul class="simple">
<li>The pincode is a 6 digit unique number that identifies the nearest post office in the locality.</li>
</ul>
<object data="http://media.thejaswi.info/images/blog_posts/772px-PIN_code_of_India.svg" style="width: 400px;" type="image/svg+xml">
Pincode Explanation Diagram</object>
<p>(Image taken from <a class="reference external" href="http://en.wikipedia.org">Wikipedia</a>. Contents of Wikipedia are licensed under <a class="reference external" href="http://en.wikipedia.org/wiki/Wikipedia:Text_of_the_GNU_Free_Documentation_License">GNU Free Documentation License</a>.)</p>
<ul class="simple">
<li>From the first two digits we will be able to identify the destination state.</li>
</ul>
</div>
<div class="section" id="motive-of-creating-the-pincode-field">
<h3>Motive of creating the Pincode Field</h3>
<p>Very often people fill forms online that require address with separate fields for State, City and Pincode. Quite often people goof up the pincode (which is the main criterion for correct delivery of mail). The application too (usually) has no means of validating it. Let's create a PinCode Field which also returns the state name to be checked for consistency with the state name entered in the form.</p>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django</span> <span class="kn">import</span> <span class="n">newforms</span> <span class="k">as</span> <span class="n">forms</span>
<span class="kn">from</span> <span class="nn">django.http</span> <span class="kn">import</span> <span class="n">HttpResponse</span>
<span class="k">class</span> <span class="nc">PinCodeField</span><span class="p">(</span><span class="n">forms</span><span class="o">.</span><span class="n">RegexField</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">max_length</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span><span class="n">min_length</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span><span class="n">error_message</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="nb">super</span><span class="p">(</span><span class="n">forms</span><span class="o">.</span><span class="n">Regexield</span><span class="p">,</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="s1">'\d</span><span class="si">{6}</span><span class="s1">'</span><span class="p">,</span><span class="n">max_length</span><span class="p">,</span><span class="n">min_length</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">clean</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">value</span><span class="p">):</span>
<span class="kn">import</span> <span class="nn">re</span>
<span class="n">value</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">forms</span><span class="o">.</span><span class="n">RegexField</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">clean</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="k">if</span> <span class="n">value</span> <span class="o">==</span> <span class="sa">u</span><span class="s1">''</span><span class="p">:</span>
<span class="k">return</span> <span class="n">value</span>
<span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s1">'\d</span><span class="si">{6}</span><span class="s1">'</span><span class="p">)</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">value</span><span class="p">):</span>
<span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">[:</span><span class="mi">2</span><span class="p">])</span> <span class="o">==</span> <span class="s2">"11"</span><span class="p">:</span>
<span class="k">return</span> <span class="p">(</span><span class="s2">"DE"</span><span class="p">,</span><span class="n">value</span><span class="p">)</span>
<span class="k">elif</span> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">[:</span><span class="mi">2</span><span class="p">])</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">30</span><span class="p">,</span><span class="mi">35</span><span class="p">):</span>
<span class="k">return</span> <span class="p">(</span><span class="s2">"RAJ"</span><span class="p">,</span><span class="n">value</span><span class="p">)</span>
<span class="k">elif</span> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">[:</span><span class="mi">2</span><span class="p">])</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">40</span><span class="p">,</span><span class="mi">45</span><span class="p">):</span>
<span class="k">return</span> <span class="p">(</span><span class="s2">"MAH"</span><span class="p">,</span><span class="n">value</span><span class="p">)</span>
<span class="k">elif</span> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">[:</span><span class="mi">2</span><span class="p">])</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">45</span><span class="p">,</span><span class="mi">50</span><span class="p">):</span>
<span class="k">return</span> <span class="p">(</span><span class="s2">"MP"</span><span class="p">,</span><span class="n">value</span><span class="p">)</span>
<span class="k">elif</span> <span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">[:</span><span class="mi">2</span><span class="p">])</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">50</span><span class="p">,</span><span class="mi">54</span><span class="p">):</span>
<span class="k">return</span> <span class="p">(</span><span class="s2">"AP"</span><span class="p">,</span><span class="n">value</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">None</span>
<span class="n">STATE_NAMES</span> <span class="o">=</span> <span class="p">(</span>
<span class="p">(</span><span class="s2">"DE"</span><span class="p">,</span><span class="s2">"Delhi"</span><span class="p">),(</span><span class="s2">"RAJ"</span><span class="p">,</span><span class="s2">"Rajasthan"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"MAH"</span><span class="p">,</span><span class="s2">"Maharashtra"</span><span class="p">),</span>
<span class="p">(</span><span class="s2">"MP"</span><span class="p">,</span> <span class="s2">"Madhya Pradesh"</span><span class="p">),</span> <span class="p">(</span><span class="s2">"AP"</span><span class="p">,</span><span class="s2">"Andhra Pradesh"</span><span class="p">),</span>
<span class="p">)</span>
<span class="c1"># I have entered only 5 names just to show demo. No prejudices involved here!!!</span>
<span class="k">class</span> <span class="nc">AddressForm</span><span class="p">(</span><span class="n">forms</span><span class="o">.</span><span class="n">Form</span><span class="p">):</span>
<span class="n">state_name</span> <span class="o">=</span> <span class="n">forms</span><span class="o">.</span><span class="n">ChoiceField</span><span class="p">(</span><span class="n">required</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span><span class="n">choices</span> <span class="o">=</span> <span class="n">STATE_NAMES</span><span class="p">)</span>
<span class="n">city_name</span> <span class="o">=</span> <span class="n">forms</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span> <span class="o">=</span> <span class="mi">50</span><span class="p">)</span>
<span class="n">pincode</span> <span class="o">=</span> <span class="n">PinCodeField</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">index</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="n">f</span> <span class="o">=</span> <span class="n">AddressForm</span><span class="p">()</span>
<span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="s2">"<form action='/sub_form/' method='post'>"</span><span class="o">+</span>\
<span class="n">f</span><span class="o">.</span><span class="n">as_p</span><span class="p">()</span><span class="o">+</span><span class="s2">"<p><input type='submit' /></p></form>"</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">sub_form</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="n">f</span> <span class="o">=</span> <span class="n">AddressForm</span><span class="p">(</span><span class="n">request</span><span class="o">.</span><span class="n">POST</span><span class="p">)</span>
<span class="k">if</span> <span class="n">f</span><span class="o">.</span><span class="n">is_valid</span><span class="p">():</span>
<span class="k">if</span> <span class="n">f</span><span class="o">.</span><span class="n">cleaned_data</span><span class="p">[</span><span class="s1">'pincode'</span><span class="p">]:</span>
<span class="k">if</span> <span class="n">f</span><span class="o">.</span><span class="n">cleaned_data</span><span class="p">[</span><span class="s1">'state_name'</span><span class="p">]</span> <span class="o">==</span> <span class="n">f</span><span class="o">.</span><span class="n">cleaned_data</span><span class="p">[</span><span class="s1">'pincode'</span><span class="p">][</span><span class="mi">0</span><span class="p">]:</span>
<span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="s2">"Data Validated"</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="s2">"Pin Code not from State"</span><span class="p">)</span>
<span class="c1"># Or raise a validation error</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="s2">"State not in list."</span><span class="p">)</span>
<span class="c1"># Or raise a validation error</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="n">HttpResponse</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">errors</span><span class="o">.</span><span class="n">as_ul</span><span class="p">())</span>
<span class="c1"># Or raise a validation error</span>
</pre></div>
<p>This was a perverted example to just show how a newform field alongwith some custom validation be created.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Django provides a field for almost every type of situation. Create a custom field only when you believe you are <strong>repeating yourself</strong> often.</p>
</div>
</div>
</div>
Google Safe Browsing and Django Newforms2007-11-12T00:00:00+00:002007-11-12T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-11-12:/tech/blog/2007/11/12/google-safe-browsing-and-django-newforms/<div class="section" id="id1">
<h2>Google Safe Browsing and Django Newforms</h2>
<div class="section" id="what-is-google-safe-browsing">
<h3>What is Google Safe Browsing</h3>
<p>It is an API that enables applications to check URLs against Google's constantly updated blacklists of suspected phishing and malware pages. For more check out <a class="reference external" href="http://code.google.com/apis/safebrowsing/">http://code.google.com/apis/safebrowsing/</a></p>
</div>
<div class="section" id="why-use-google-safe-browsing">
<h3>Why use Google Safe Browsing?</h3>
<p>Nowadays everyone is …</p></div></div><div class="section" id="id1">
<h2>Google Safe Browsing and Django Newforms</h2>
<div class="section" id="what-is-google-safe-browsing">
<h3>What is Google Safe Browsing</h3>
<p>It is an API that enables applications to check URLs against Google's constantly updated blacklists of suspected phishing and malware pages. For more check out <a class="reference external" href="http://code.google.com/apis/safebrowsing/">http://code.google.com/apis/safebrowsing/</a></p>
</div>
<div class="section" id="why-use-google-safe-browsing">
<h3>Why use Google Safe Browsing?</h3>
<p>Nowadays everyone is bombarded by loads of spam soliciting people to click on an <cite>innocent looking</cite> ;-) link. If some dumb user falls for the trick then his life would become miserable from that moment. As elders say <strong>Prevention is better than cure</strong>, so be careful before you click these links.</p>
<p>Google Safe Browsing is a step towards preventing the user from making such dastardly mistakes. <a class="reference external" href="http://www.google.com">Google</a>, one of the largest and popular online search engine has released the database of suspected malware and phishing blacklisted sites.</p>
<p>Google is one of the most active partners of <a class="reference external" href="http://www.stopbadware.org/">StopBadware</a> and <a class="reference external" href="http://www.antiphishing.org/">AntiPhishing</a> and hence you have access to almost all the badware site urls.</p>
</div>
<div class="section" id="why-django">
<h3>Why Django?</h3>
<p>Django is one of the coolest Python web frameworks around. I have been associated with Django for quite some time now and wanted to contribute my bit to the community.</p>
<ul class="simple">
<li>For Django users, I have created a form field called <strong>Safe_URLField</strong> that checks against the database and raises an error if the url is found in it.</li>
</ul>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django</span> <span class="kn">import</span> <span class="n">newforms</span> <span class="k">as</span> <span class="n">forms</span>
<span class="kn">from</span> <span class="nn">safe_browsing.forms</span> <span class="kn">import</span> <span class="n">Safe_URLField</span>
<span class="k">class</span> <span class="nc">SomeForm</span><span class="p">(</span><span class="n">forms</span><span class="o">.</span><span class="n">Form</span><span class="p">):</span>
<span class="n">url_descr</span> <span class="o">=</span> <span class="n">forms</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">50</span><span class="p">)</span>
<span class="n">url_field</span> <span class="o">=</span> <span class="n">Safe_URLField</span><span class="p">()</span>
<span class="o">>>></span> <span class="n">data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"url_descr"</span><span class="p">:</span> <span class="s2">"Crap Site"</span><span class="p">,</span><span class="s2">"url_field"</span><span class="p">:</span><span class="sa">u</span><span class="s2">"www.fxmp3.com"</span><span class="p">}</span>
<span class="o">>>></span> <span class="n">f</span> <span class="o">=</span> <span class="n">SomeForm</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">f</span><span class="o">.</span><span class="n">is_valid</span><span class="p">()</span>
<span class="kc">False</span>
<span class="o">>>></span> <span class="n">f</span><span class="o">.</span><span class="n">errors</span>
<span class="p">{</span><span class="s1">'url_field'</span><span class="p">:</span> <span class="p">[</span><span class="sa">u</span><span class="s1">'For Malware Detection:This page appears to contain malicious code...'</span><span class="p">]}</span>
<span class="o">>>></span>
<span class="o">>>></span> <span class="n">data2</span> <span class="o">=</span> <span class="p">{</span><span class="s2">"url_descr"</span><span class="p">:</span><span class="s2">"Excellent Site"</span><span class="p">,</span><span class="s2">"url_field"</span><span class="p">:</span><span class="sa">u</span><span class="s2">"http://thejaswi.info"</span><span class="p">}</span>
<span class="o">>>></span> <span class="n">g</span> <span class="o">=</span> <span class="n">SomeForm</span><span class="p">(</span><span class="n">data2</span><span class="p">)</span>
<span class="o">>>></span> <span class="n">g</span><span class="o">.</span><span class="n">is_valid</span><span class="p">()</span>
<span class="kc">True</span>
<span class="o">>>></span> <span class="n">g</span><span class="o">.</span><span class="n">errors</span>
<span class="p">{}</span>
</pre></div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">I have also scripted a Safe_URLField alongwith a validator (<cite>isBadwareURL</cite>) which could be used with oldforms(whose use is not recommended).</p>
</div>
</div>
<div class="section" id="who-can-use-this-service">
<h3>Who can use this service?</h3>
<ul class="simple">
<li>Sites where there is input of urls whose credentials might sometimes be suspect, thanks to spammers.(A classic example would be <a class="reference external" href="http://www.djangosites.org/">DjangoSites</a>).</li>
<li>Folks who download lots of software and music from untrusted sources.</li>
</ul>
<p>For a demo, you can check out the service <a class="reference external" href="/projects/safe_browsing/">here</a>.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Please use this service judiciously as my hosting plan is constrained by RAM usage. To prevent misuse, I am recording IP addresses. I assure that this information will be kept confindential and not be used for any other purpose.</p>
</div>
</div>
</div>
I blog in ReSt Part 32007-11-11T00:00:00+00:002007-11-11T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-11-11:/tech/blog/2007/11/11/i-blog-in-rest-part-3/<div class="section" id="id1">
<h2>I blog in ReSt Part 3</h2>
<p>This is the final part in the <strong>"I blog in ReSt"</strong> series. This part discusses about how to get the templates going for the blog.</p>
<ul class="simple">
<li>Create a folder called templates in the project directory and add the absolute path to the directory in the …</li></ul></div><div class="section" id="id1">
<h2>I blog in ReSt Part 3</h2>
<p>This is the final part in the <strong>"I blog in ReSt"</strong> series. This part discusses about how to get the templates going for the blog.</p>
<ul class="simple">
<li>Create a folder called templates in the project directory and add the absolute path to the directory in the settings.py TEMPLATE_DIRS</li>
<li>Create a file called blog.html in templates</li>
</ul>
<div class="highlight"><pre><span></span><span class="x"> </span><span class="cp">{%</span> <span class="k">load</span> <span class="nv">custom_filters</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">load</span> <span class="nv">comments</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">load</span> <span class="nv">markup</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">load</span> <span class="nv">tagging_tags</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">block</span> <span class="nv">title</span> <span class="cp">%}</span><span class="x">Title of the Blog</span><span class="cp">{%</span> <span class="k">endblock</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">block</span> <span class="nv">content</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">blog</span> <span class="k">in</span> <span class="nv">blog_object_list</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{{</span> <span class="nv">blog.blog_title</span> <span class="cp">}}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{{</span> <span class="nv">blog.blog_file</span><span class="o">|</span><span class="nf">open_file</span><span class="o">|</span><span class="nf">restructuredtext</span> <span class="cp">}}</span><span class="x"></span>
<span class="x"> Published on </span><span class="cp">{{</span> <span class="nv">blog.blog_date_pub</span><span class="o">|</span><span class="nf">date</span><span class="s2">:"F j, Y"</span> <span class="cp">}}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">get_free_comment_list</span> <span class="nv">for</span> <span class="nv">blog_app.blog_model</span> <span class="nv">blog.id</span> <span class="k">as</span> <span class="nv">comment_list</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">get_free_comment_count</span> <span class="nv">for</span> <span class="nv">blog_app.blog_model</span> <span class="nv">blog.id</span> <span class="k">as</span> <span class="nv">comment_count</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">comment_count</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">comment</span> <span class="k">in</span> <span class="nv">comment_list</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> <div class="comment_</span><span class="cp">{%</span> <span class="k">cycle</span> <span class="nv">odd</span><span class="o">,</span><span class="nv">even</span> <span class="cp">%}</span><span class="x">" id="c</span><span class="cp">{{</span> <span class="nv">comment.id</span> <span class="cp">}}</span><span class="x">"></span>
<span class="x"> <span class="comnum"><a id="c</span><span class="cp">{{</span> <span class="nv">comment.id</span> <span class="cp">}}</span><span class="x">"</span>
<span class="x"> href="#c</span><span class="cp">{{</span> <span class="nv">comment.id</span> <span class="cp">}}</span><span class="x">">#</span><span class="cp">{{</span> <span class="nb">forloop</span><span class="nv">.counter</span> <span class="cp">}}</span><span class="x"></a></span></span>
<span class="x"> <p><strong></span><span class="cp">{{</span> <span class="nv">comment.person_name</span><span class="o">|</span><span class="nf">escape</span> <span class="cp">}}</span><span class="x"></strong> commented,</span>
<span class="x"> on </span><span class="cp">{{</span> <span class="nv">comment.submit_date</span><span class="o">|</span><span class="nf">date</span><span class="s2">:"F j, Y"</span> <span class="cp">}}</span><span class="x"> at </span><span class="cp">{{</span> <span class="nv">comment.submit_date</span><span class="o">|</span><span class="nf">date</span><span class="s2">:"P"</span> <span class="cp">}}</span><span class="x">:</p></span>
<span class="x"> </span><span class="cp">{{</span> <span class="nv">comment.comment</span><span class="o">|</span><span class="nf">restructuredtext</span> <span class="cp">}}</span><span class="x"></span>
<span class="x"> </div></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> <p>Post a comment</p></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">free_comment_form</span> <span class="nv">for</span> <span class="nv">blog_app.blog_model</span> <span class="nv">blog.id</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> Viewing page <strong></span><span class="cp">{{</span> <span class="nv">page</span> <span class="cp">}}</span><span class="x"> / </span><span class="cp">{{</span> <span class="nv">pages</span> <span class="cp">}}</span><span class="x"></strong>. Total number of posts are </span><span class="cp">{{</span> <span class="nv">hits</span> <span class="cp">}}</span><span class="x">.</span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">has_previous</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">year</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">month</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> <p><a href="/blog/</span><span class="cp">{{</span> <span class="nv">year</span> <span class="cp">}}</span><span class="x">/</span><span class="cp">{{</span> <span class="nv">month</span> <span class="cp">}}</span><span class="x">/page/</span><span class="cp">{{</span> <span class="nv">previous</span> <span class="cp">}}</span><span class="x">/">Newer Posts</a></p></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> <p><a href="/blog/</span><span class="cp">{{</span> <span class="nv">year</span> <span class="cp">}}</span><span class="x">/page/</span><span class="cp">{{</span> <span class="nv">previous</span> <span class="cp">}}</span><span class="x">/">Newer Posts</a></p></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">tag</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> <p><a href="/blog/tag/</span><span class="cp">{{</span> <span class="nv">tag</span> <span class="cp">}}</span><span class="x">/page/</span><span class="cp">{{</span> <span class="nv">previous</span> <span class="cp">}}</span><span class="x">/">Newer Posts</a></p></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> <p><a href="/blog/page/</span><span class="cp">{{</span> <span class="nv">previous</span> <span class="cp">}}</span><span class="x">/">Newer Posts</a></p></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">has_next</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">year</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">month</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> <p><a href="/blog/</span><span class="cp">{{</span> <span class="nv">year</span> <span class="cp">}}</span><span class="x">/</span><span class="cp">{{</span> <span class="nv">month</span> <span class="cp">}}</span><span class="x">/page/</span><span class="cp">{{</span> <span class="nv">next</span> <span class="cp">}}</span><span class="x">/">Older Posts</a></p></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> <p><a href="/blog/</span><span class="cp">{{</span> <span class="nv">year</span> <span class="cp">}}</span><span class="x">/page/</span><span class="cp">{{</span> <span class="nv">next</span> <span class="cp">}}</span><span class="x">/">Older Posts</a></p></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">tag</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> <p><a href="/blog/tag/</span><span class="cp">{{</span> <span class="nv">tag</span> <span class="cp">}}</span><span class="x">/page/</span><span class="cp">{{</span> <span class="nv">next</span> <span class="cp">}}</span><span class="x">/">Older Posts</a></p></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> <p><a href="/blog/page/</span><span class="cp">{{</span> <span class="nv">next</span> <span class="cp">}}</span><span class="x">/">Older Posts</a></p></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">endblock</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
<p>You might be wondering what <cite>{% load custom_filters %}</cite> is. As the name suggests it is a custom filter to read the contents of the file and return them to the <cite>restructuredtext</cite> filter.</p>
<div class="section" id="to-write-your-custom-filter">
<h3>To write your custom filter</h3>
<ul class="simple">
<li>Create a new application called <cite>mytags</cite> and add it to the INSTALLED_APPS in settings.py</li>
<li>In the mytags directory create a folder called templatetags which must have an __init__.py file and the python file containing your filter code (here it is custom_filters.py).</li>
</ul>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django</span> <span class="kn">import</span> <span class="n">template</span>
<span class="n">register</span> <span class="o">=</span> <span class="n">template</span><span class="o">.</span><span class="n">Library</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">open_file</span><span class="p">(</span><span class="n">value</span><span class="p">):</span>
<span class="s2">"Opens the contents of the file given in value."</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">f</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">value</span><span class="p">,</span><span class="s2">"r"</span><span class="p">)</span>
<span class="n">contents</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">IOError</span><span class="p">:</span>
<span class="k">return</span> <span class="kc">None</span>
<span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="k">return</span> <span class="n">contents</span>
<span class="c1"># Register the Filter</span>
<span class="n">register</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="n">open_file</span><span class="p">)</span>
</pre></div>
<p>The <cite>restructuredtext</cite> is a filter from <cite>django.contrib.markup</cite>. The django.contrib.markup currently supports <strong>three</strong> markup languages Textile, Markdown and ReSt.</p>
</div>
<div class="section" id="comments-are-essential-for-a-blog">
<h3>Comments are essential for a blog</h3>
<p>Django has an in-built comment system that can be activated almost instantly. For activating comments add the <cite>django.contrib.comments</cite> to your INSTALLED_APPS in settings.py.
There are two types of Comments Systems:</p>
<ul class="simple">
<li><strong>Comments</strong>: For sites that require only registered users to post comments. This system also has the facility to rate comments based on a concept called <strong>Karma Score</strong>.</li>
<li><strong>FreeComments</strong>: For sites that require any user to post comments. This is the type of comments one usually places on a blog. But beware spam will soon catch up. For the people who want to take extra precaution, I would recommend <a class="reference external" href="http://www.b-list.org">James Bennett's</a> (aka <a class="reference external" href="http://code.google.com/u/ubernostrum/">Ubernostrum</a>) <a class="reference external" href="http://code.google.com/p/django-comment-utils/">Django Comment Utils</a>. Django Comment Utils provides lots of features like email on comment, Akismet based spam filtering, easy moderation etc.</li>
</ul>
<p>The best part about Django's Comment System is that it is extremely easy to use but its biggest drawback is that it hasn't been documented yet. This is no lame excuse for not using Django Comments. In fact lots of users have blogged on how to use the Comment System. Feel free to search and you'll get hold of them. The one link that explains the comment system in detail would be <a class="reference external" href="http://code.djangoproject.com/wiki/UsingFreeComment">this</a>.</p>
<p>The rest of the code is regarding pagination. Refer <a class="reference external" href="http://www.djangoproject.com/documentation/generic_views/#notes-on-pagination">here</a> for more details regarding it.</p>
<p>Now you have a blog written in Django that has all the basic features that <a class="reference external" href="http://www.blogger.com/">Blogger</a> has. Also the blog is highly extensible. Extend the blog and let me know of some cool features that you built into your blog.</p>
</div>
</div>
I blog in ReSt Part 22007-11-10T00:00:00+00:002007-11-10T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-11-10:/tech/blog/2007/11/10/i-blog-in-rest-part-2/<div class="section" id="id1">
<h2>I blog in ReSt Part 2</h2>
<p>Once done with setting up the project, we need to code our views and templates to complete the blog. This part deals with coding the views for the blog.
The different views that we require are</p>
<ul class="simple">
<li>For displaying the landing page</li>
<li>For displaying the …</li></ul></div><div class="section" id="id1">
<h2>I blog in ReSt Part 2</h2>
<p>Once done with setting up the project, we need to code our views and templates to complete the blog. This part deals with coding the views for the blog.
The different views that we require are</p>
<ul class="simple">
<li>For displaying the landing page</li>
<li>For displaying the blog filtered by year</li>
<li>For displaying the blog filtered by month</li>
<li>For displaying the blog filtered by day</li>
<li>Tags to categorize the blog. For this I make use of <a class="reference external" href="http://code.google.com/p/django-tagging">Django-Tagging</a></li>
</ul>
<p>So let's edit the urls.py file in the project directory to reflect on the urlpatterns.</p>
<div class="highlight"><pre><span></span><span class="x">('^blog/$', get_blog_first_page),</span>
<span class="x">('^blog/(?P<year>\d{4})/$', get_posts_by_year),</span>
<span class="x">('^blog/(?P<year>\d{4})/page/(?P<page>\d)/$', get_blog_page_by_year),</span>
<span class="x">('^blog/(?P<year>\d{4})/(?P<month>\d{2})/$', get_posts_by_month),</span>
<span class="x">('^blog/(?P<year>\d{4})/(?P<month>\d{2})/page/(?P<page>\d)/$', get_blog_page_by_month),</span>
<span class="x">('^blog/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$', get_posts_by_day),</span>
<span class="x">('^blog/tag/(?P<tag>[^/]+(?u))/$',tagged_object_list,dict(model=Blog_Model, paginate_by=1, \</span>
<span class="x">allow_empty=True,template_object_name='blog_object', template_name='blog.html',\</span>
<span class="x">extra_context={"tag":1,})),</span>
<span class="x">('^blog/tag/(?P<tag>[^/]+(?u))/page/(?P<page>[0-9]+)/$',tagged_object_list,dict(model=Blog_Meta, \</span>
<span class="x"> paginate_by=1, allow_empty=True, template_object_name='blog_object', template_name='blog.html',)),</span>
</pre></div>
<p>By doing so we will be accepting all urls like</p>
<div class="highlight"><pre><span></span><span class="x">/blog/ # the first page with latest items</span>
<span class="x">/blog/2007/ # the first page of all blog posts from 2007</span>
<span class="x">/blog/2007/page/4/ # the fourth page of blog posts from 2007</span>
<span class="x">/blog/2007/10/ # blog posts from October 2007</span>
<span class="x">/blog/2007/09/page/2/ # the second page from November 2007</span>
<span class="x">/blog/2007/11/15/ # the post on 15 November 2007</span>
<span class="x">/blog/tag/django/ # Posts with tag django</span>
<span class="x">/blog/tag/django/page/7/ # Seventh page with tag django</span>
</pre></div>
<p>Django provides a <a class="reference external" href="http://www.djangoproject.com/documentation/generic_views/#date-based-generic-views">date-based generic view</a> that saves us from the writing views for date filtering etc. But date-based generic views do not provide pagination by default. But django is powerful and highly extensible. It provides an <cite>Object Paginator</cite> which can be used for paginations. So I will use a <a class="reference external" href="http://www.djangoproject.com/documentation/generic_views/#list-detail-generic-views">list-based generic view</a> to mimic the date-based generic views with pagination. Open the views.py file in blog_app and paste the following code.</p>
<div class="highlight"><pre><span></span> <span class="kn">from</span> <span class="nn">django.core.paginator</span> <span class="kn">import</span> <span class="n">ObjectPaginator</span>
<span class="kn">from</span> <span class="nn">blog_app.models</span> <span class="kn">import</span> <span class="n">Blog_Model</span>
<span class="kn">from</span> <span class="nn">django.http</span> <span class="kn">import</span> <span class="n">HttpResponse</span><span class="p">,</span> <span class="n">Http404</span>
<span class="kn">from</span> <span class="nn">django.template</span> <span class="kn">import</span> <span class="n">loader</span><span class="p">,</span> <span class="n">Context</span>
<span class="kn">from</span> <span class="nn">django.views.generic.date_based</span> <span class="kn">import</span> <span class="n">archive_day</span>
<span class="kn">from</span> <span class="nn">django.views.generic.list_detail</span> <span class="kn">import</span> <span class="n">object_list</span>
<span class="kn">import</span> <span class="nn">tagging</span>
<span class="c1"># Number of Entries per page (paginate_by)</span>
<span class="n">num_entries_per_page</span> <span class="o">=</span> <span class="mi">7</span>
<span class="k">def</span> <span class="nf">get_blog_page</span><span class="p">(</span><span class="n">request</span><span class="p">,</span><span class="n">page</span><span class="p">):</span>
<span class="n">queryset</span> <span class="o">=</span> <span class="n">Blog_Model</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="s2">"-blog_date_pub"</span><span class="p">)</span>
<span class="n">paginator</span> <span class="o">=</span> <span class="n">ObjectPaginator</span><span class="p">(</span><span class="n">queryset</span><span class="p">,</span> <span class="n">num_entries_per_page</span><span class="p">)</span>
<span class="n">cloud_list</span> <span class="o">=</span> <span class="n">tagging</span><span class="o">.</span><span class="n">models</span><span class="o">.</span><span class="n">Tag</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">cloud_for_model</span><span class="p">(</span><span class="n">Blog_Model</span><span class="p">,</span><span class="n">steps</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="n">paginator</span><span class="o">.</span><span class="n">pages</span>
<span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="n">page</span><span class="p">)</span> <span class="ow">in</span> <span class="n">paginator</span><span class="o">.</span><span class="n">page_range</span><span class="p">:</span>
<span class="k">return</span> <span class="n">object_list</span><span class="p">(</span><span class="n">request</span><span class="p">,</span><span class="n">queryset</span><span class="p">,</span><span class="n">num_entries_per_page</span><span class="p">,</span><span class="n">page</span><span class="p">,</span><span class="n">template_name</span><span class="o">=</span><span class="s1">'blog.html'</span><span class="p">,</span>\
<span class="n">template_object_name</span><span class="o">=</span><span class="s1">'blog_object'</span><span class="p">,</span><span class="n">extra_context</span><span class="o">=</span><span class="p">{</span><span class="s1">'cloud_list'</span><span class="p">:</span> <span class="n">cloud_list</span><span class="p">,})</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">Http404</span>
<span class="k">def</span> <span class="nf">get_blog_first_page</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="k">return</span> <span class="n">get_blog_page</span><span class="p">(</span><span class="n">request</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">get_blog_page_by_year</span><span class="p">(</span><span class="n">request</span><span class="p">,</span><span class="n">year</span><span class="p">,</span><span class="n">page</span><span class="p">):</span>
<span class="n">queryset</span> <span class="o">=</span> <span class="n">Blog_Model</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="s2">"blog_date_pub__year"</span><span class="p">:</span><span class="n">year</span><span class="p">})</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="s2">"-blog_date_pub"</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">assert</span> <span class="n">queryset</span>
<span class="k">except</span> <span class="ne">AssertionError</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">Http404</span>
<span class="n">paginator</span> <span class="o">=</span> <span class="n">ObjectPaginator</span><span class="p">(</span><span class="n">queryset</span><span class="p">,</span> <span class="n">num_entries_per_page</span><span class="p">)</span>
<span class="n">paginator</span><span class="o">.</span><span class="n">pages</span>
<span class="n">cloud_list</span> <span class="o">=</span> <span class="n">tagging</span><span class="o">.</span><span class="n">models</span><span class="o">.</span><span class="n">Tag</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">cloud_for_model</span><span class="p">(</span><span class="n">Blog_Model</span><span class="p">,</span><span class="n">steps</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="n">page</span><span class="p">)</span> <span class="ow">in</span> <span class="n">paginator</span><span class="o">.</span><span class="n">page_range</span><span class="p">:</span>
<span class="k">return</span> <span class="n">object_list</span><span class="p">(</span><span class="n">request</span><span class="p">,</span><span class="n">queryset</span><span class="p">,</span><span class="n">num_entries_per_page</span><span class="p">,</span><span class="n">page</span><span class="p">,</span><span class="n">template_name</span><span class="o">=</span><span class="s1">'blog.html'</span><span class="p">,</span>\
<span class="n">template_object_name</span><span class="o">=</span><span class="s1">'blog_object'</span><span class="p">,</span><span class="n">extra_context</span><span class="o">=</span><span class="p">{</span><span class="s2">"year"</span><span class="p">:</span><span class="n">year</span><span class="p">,</span><span class="s1">'cloud_list'</span><span class="p">:</span> <span class="n">cloud_list</span><span class="p">,})</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">Http404</span>
<span class="k">def</span> <span class="nf">get_posts_by_year</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">year</span><span class="p">):</span>
<span class="k">return</span> <span class="n">get_blog_page_by_year</span><span class="p">(</span><span class="n">request</span><span class="p">,</span><span class="n">year</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">get_posts_by_day</span><span class="p">(</span><span class="n">request</span><span class="p">,</span><span class="n">year</span><span class="p">,</span><span class="n">month</span><span class="p">,</span><span class="n">day</span><span class="p">):</span>
<span class="n">month_dict</span> <span class="o">=</span> <span class="p">{</span><span class="mi">1</span><span class="p">:</span><span class="s2">"Jan"</span><span class="p">,</span><span class="mi">2</span><span class="p">:</span><span class="s2">"Feb"</span><span class="p">,</span><span class="mi">3</span><span class="p">:</span><span class="s2">"Mar"</span><span class="p">,</span><span class="mi">4</span><span class="p">:</span><span class="s2">"Apr"</span><span class="p">,</span><span class="mi">5</span><span class="p">:</span><span class="s2">"May"</span><span class="p">,</span><span class="mi">6</span><span class="p">:</span><span class="s2">"Jun"</span><span class="p">,</span><span class="mi">7</span><span class="p">:</span><span class="s2">"Jul"</span><span class="p">,</span><span class="mi">8</span><span class="p">:</span><span class="s2">"Aug"</span><span class="p">,</span>\
<span class="mi">9</span><span class="p">:</span><span class="s2">"Sep"</span><span class="p">,</span><span class="mi">10</span><span class="p">:</span><span class="s2">"Oct"</span><span class="p">,</span><span class="mi">11</span><span class="p">:</span><span class="s2">"Nov"</span><span class="p">,</span><span class="mi">12</span><span class="p">:</span><span class="s2">"Dec"</span><span class="p">}</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">month_name</span> <span class="o">=</span> <span class="n">month_dict</span><span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">month</span><span class="p">)]</span>
<span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">Http404</span>
<span class="n">cloud_list</span> <span class="o">=</span> <span class="n">tagging</span><span class="o">.</span><span class="n">models</span><span class="o">.</span><span class="n">Tag</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">cloud_for_model</span><span class="p">(</span><span class="n">Blog_Model</span><span class="p">,</span><span class="n">steps</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="k">return</span> <span class="n">archive_day</span><span class="p">(</span><span class="n">request</span><span class="p">,</span><span class="n">year</span><span class="p">,</span><span class="n">month_name</span><span class="p">,</span><span class="n">day</span><span class="p">,</span><span class="n">Blog_Model</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">(),</span><span class="s1">'blog_date_pub'</span><span class="p">,</span>\
<span class="n">template_name</span><span class="o">=</span><span class="s1">'blog.html'</span><span class="p">,</span><span class="n">template_object_name</span><span class="o">=</span><span class="s1">'blog_object'</span><span class="p">,</span>\
<span class="n">extra_context</span><span class="o">=</span><span class="p">{</span><span class="s1">'cloud_list'</span><span class="p">:</span> <span class="n">cloud_list</span><span class="p">,})</span>
</pre></div>
<p>I have not given the complete view. You can check it out <a class="reference external" href="http://www.djangosnippets.org/snippets/454/">here</a>. The next part in this series talks about templates.</p>
</div>
I blog in ReSt Part 12007-11-09T00:00:00+00:002007-11-09T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-11-09:/tech/blog/2007/11/09/i-blog-in-rest-part-1/<div class="section" id="i-blog-in-restructured-text-part-1">
<h2>I blog in ReStructured Text Part-1</h2>
<p>Nowadays everyone blogs. <a class="reference external" href="http://en.wikipedia.org/wiki/Blog">Blogs</a> have become the medium for people to express <a class="reference external" href="http://blaugh.com/2007/06/20/skyping-baby-names/">almost everything</a>. So I started <a class="reference external" href="http://thejuhyd.blogspot.com">blogging</a> in January on <a class="reference external" href="http://www.blogger.com/">Blogger</a>. Initially I was satisfied with it but started feeling cramped for features. <a class="reference external" href="http://www.wordpress.com/">Wordpress</a> and <a class="reference external" href="http://pyblosxom.sourceforge.net/">PyBlosxom</a> looked like good alternatives but it was …</p></div><div class="section" id="i-blog-in-restructured-text-part-1">
<h2>I blog in ReStructured Text Part-1</h2>
<p>Nowadays everyone blogs. <a class="reference external" href="http://en.wikipedia.org/wiki/Blog">Blogs</a> have become the medium for people to express <a class="reference external" href="http://blaugh.com/2007/06/20/skyping-baby-names/">almost everything</a>. So I started <a class="reference external" href="http://thejuhyd.blogspot.com">blogging</a> in January on <a class="reference external" href="http://www.blogger.com/">Blogger</a>. Initially I was satisfied with it but started feeling cramped for features. <a class="reference external" href="http://www.wordpress.com/">Wordpress</a> and <a class="reference external" href="http://pyblosxom.sourceforge.net/">PyBlosxom</a> looked like good alternatives but it was the latter that impressed me the most. I wanted to blog using PyBlosxom. Then I realized, <em>what's the point in knowing</em> <a class="reference external" href="http://www.djangoproject.com/">Django</a> <em>and still not writing your own blog app</em>.</p>
<p>My requirements for the blog were:</p>
<ul class="simple">
<li><dl class="first docutils">
<dt><strong>Markup based</strong>: The reasons for choosing markup were</dt>
<dd><ul class="first last">
<li>I have a poor memory and can't recollect the 100's of HTML Tags.</li>
<li>Check out <a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/introduction.html#goals">http://docutils.sourceforge.net/docs/ref/rst/introduction.html#goals</a></li>
</ul>
</dd>
</dl>
</li>
<li><strong>File-System based</strong>: Storing all the contents of the blog in a database didn't appeal to me especially when you are restricted by 40 Megs of RAM by your <a class="reference external" href="http://www.webfaction.com/">hosting provider</a> (I am not complaining, that's all that I can afford).</li>
</ul>
<p>Once done with the requirements, I started scripting for my blog and here is a step-by-step process of how to go about it. The blog can be built for any markup langauge like <a class="reference external" href="http://daringfireball.net/projects/markdown/">Markdown</a>, <a class="reference external" href="http://dealmeida.net/projects/textile/">PyTextile</a> or <a class="reference external" href="http://docutils.sourceforge.net/rst.html">ReSt</a>.</p>
<ul class="simple">
<li>First fire up a django project.</li>
</ul>
<div class="highlight"><pre><span></span>$ django-admin.py startproject myproject
</pre></div>
<ul class="simple">
<li>Then start a new application called blog_app.</li>
</ul>
<div class="highlight"><pre><span></span>$ python manage.py startapp blog_app
</pre></div>
<ul class="simple">
<li>Edit the settings.py to add a database engine and a database of your choice. I used <a class="reference external" href="http://www.sqlite.org/">SQLite</a> because it is a lightweight database with a very small footprint. Also add <cite>django.contrib.markup, django.contrib.admin, blog_app</cite> in the INSTALLED_APPS.</li>
<li>Open the models.py file in blog_app and create a new Model. The blog will also support tags using <a class="reference external" href="http://code.google.com/p/django-tagging/">Django-Tagging</a></li>
</ul>
<div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.db</span> <span class="kn">import</span> <span class="n">models</span>
<span class="kn">from</span> <span class="nn">tagging.models</span> <span class="kn">import</span> <span class="n">Tag</span>
<span class="kn">from</span> <span class="nn">tagging.fields</span> <span class="kn">import</span> <span class="n">TagField</span>
<span class="k">class</span> <span class="nc">Blog_Model</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
<span class="n">blog_title</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">250</span><span class="p">)</span>
<span class="n">blog_date_pub</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">DateField</span><span class="p">()</span>
<span class="n">blog_file_name</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">250</span><span class="p">)</span>
<span class="n">blog_tags</span> <span class="o">=</span> <span class="n">TagField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">255</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">save</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># Override the save method of Model.</span>
<span class="nb">super</span><span class="p">(</span><span class="n">Blog_Meta</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">tags</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">blog_tags</span>
<span class="k">def</span> <span class="nf">_get_tags</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="n">Tag</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">get_for_object</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">_set_tags</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">blog_tags</span><span class="p">):</span>
<span class="n">Tag</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">update_tags</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">blog_tags</span><span class="p">)</span>
<span class="n">tags</span> <span class="o">=</span> <span class="nb">property</span><span class="p">(</span><span class="n">_get_tags</span><span class="p">,</span> <span class="n">_set_tags</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">__unicode__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">blog_title</span>
</pre></div>
<ul class="simple">
<li>Save the above code and run syncdb from the project directory.</li>
</ul>
<div class="highlight"><pre><span></span>$ python manage.py syncdb
</pre></div>
<ul class="simple">
<li>Uncomment the admin urlpattern from the urls.py file and run the server.</li>
</ul>
<div class="highlight"><pre><span></span>$ python manage.py runserver
</pre></div>
<ul class="simple">
<li>Go to the admin url in your webbrowser and add a few entries to your Blog Models.</li>
</ul>
<p>In the next part we see how to write the views and templates for the blog.</p>
</div>
Top 5 Firefox Extensions2007-09-29T00:00:00+00:002007-09-29T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-09-29:/tech/blog/2007/09/29/top-5-firefox-extensions/<div class="section" id="id1">
<h2>Top 5 Firefox Extensions</h2>
<p>I am a part-time webdesigner and developer and here are the top 5 Firefox extensions in my list (ordered according to rank).</p>
<ol class="arabic simple">
<li><a class="reference external" href="https://addons.mozilla.org/en-US/firefox/addon/1843">Firebug</a>: A must for every webdesigner. For beginners, there is <a class="reference external" href="http://karmatics.com/aardvark/">Aardvark</a></li>
<li><a class="reference external" href="https://addons.mozilla.org/en-US/firefox/addon/60">Webdeveloper</a>: Another must for webdesigners.</li>
<li><a class="reference external" href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a>: A cool addon that can be used …</li></ol></div><div class="section" id="id1">
<h2>Top 5 Firefox Extensions</h2>
<p>I am a part-time webdesigner and developer and here are the top 5 Firefox extensions in my list (ordered according to rank).</p>
<ol class="arabic simple">
<li><a class="reference external" href="https://addons.mozilla.org/en-US/firefox/addon/1843">Firebug</a>: A must for every webdesigner. For beginners, there is <a class="reference external" href="http://karmatics.com/aardvark/">Aardvark</a></li>
<li><a class="reference external" href="https://addons.mozilla.org/en-US/firefox/addon/60">Webdeveloper</a>: Another must for webdesigners.</li>
<li><a class="reference external" href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a>: A cool addon that can be used to jazz up sites locally, scrap all your friends in a jiffy in Orkut and also to download Youtube videos...This is just a small description, Greasemonkey has more utilities. Check out <a class="reference external" href="http://www.userscripts.org/">Userscripts</a>.</li>
<li><a class="reference external" href="https://addons.mozilla.org/en-US/firefox/addon/3615">del.icio.us Bookmarks</a>: <a class="reference external" href="http://del.icio.us/">del.icio.us</a> is an online bookmarking site and this is their cool addon. Also the bookmarks move where ever you go.</li>
<li><a class="reference external" href="https://addons.mozilla.org/en-US/firefox/addon/16">Chatzilla</a>: Don't have to chat on the IRC from outside your browser!!!</li>
</ol>
<p>If any IE users are reading this blog, switch to Firefox and become productive effortlessly.</p>
</div>
Cool Python Documentation Utilities2007-09-16T00:00:00+00:002007-09-16T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-09-16:/tech/blog/2007/09/16/cool-python-documentation-utilities/<div class="section" id="id1">
<h2>Cool Python Documentation Utilities</h2>
<p>It's been a long time since I blogged. Part of the reason was laziness and the other part was that I needed good content to blog on.
Now I have overcome both and here's my new post.</p>
<p>I have learnt from my experience that users (and …</p></div><div class="section" id="id1">
<h2>Cool Python Documentation Utilities</h2>
<p>It's been a long time since I blogged. Part of the reason was laziness and the other part was that I needed good content to blog on.
Now I have overcome both and here's my new post.</p>
<p>I have learnt from my experience that users (and developers alike!!!) mainly adopt projects which have comprehensive documentation. Just look at some of the most successful OSS projects, they devote a lot of time and energy to write and update documentation.</p>
<p>Here are two cool projects that I checked out to jazz <a class="reference external" href="http://code.google.com/p/django-check-constraints/">my project</a>!!!
Two such projects would be:</p>
<blockquote>
<ul class="simple">
<li><strong>Docutils</strong>:<a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> is an open-source text processing system for processing plaintext documentation into useful formats, such as HTML or LaTeX. It includes reStructuredText, the easy to read, easy to use, what-you-see-is-what-you-get plaintext markup language.
Using the simple markup language of Docutils one can generate documentation for their project in various formats without having to work on them individually.
Check out a cool looking example -> Restructured Text <a class="reference external" href="http://docs.python.org/dev/3.0/whatsnew/3.0.txt">Source</a> transformed to <a class="reference external" href="http://docs.python.org/dev/3.0/whatsnew/3.0.html">Result</a></li>
<li><strong>Epydoc</strong>:<a class="reference external" href="http://epydoc.sourceforge.net/">Epydoc</a> is a tool for generating API documentation for Python modules, based on their docstrings.
Most Python developers have the habit of writing docstrings. By using epydoc one can generate API documentation based on docstrings, comments and doc-tests.
Check out <a class="reference external" href="http://djangoapi.quamquam.org/trunk/">Django's API</a> auto-generated using Epydoc.</li>
</ul>
</blockquote>
<p>My project documentation is now based on <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructured Text</a> and I have generated API documentation using epydoc (converted to PDF) available <a class="reference external" href="http://thejaswi.puthraya.googlepages.com/api.pdf">here</a>.</p>
</div>
YouTube downloader in Python2007-04-10T00:00:00+00:002007-04-10T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-04-10:/tech/blog/2007/04/10/youtube-downloader-in-python/<div class="section" id="id1">
<h2>Youtube Downloader in Python</h2>
<p>I was surprised to read an <a class="reference external" href="http://news.bbc.co.uk/1/hi/entertainment/6168950.stm">article</a> on <a class="reference external" href="http://www.bbc.co.uk/">BBC</a> that stated that <a class="reference external" href="http://www.youtube.com/">YouTube</a> had eaten substantially into television's already declining viewership. Many others did not even find it worth taking note of because they had envisioned that YouTube would be a disruptive application (true in more …</p></div><div class="section" id="id1">
<h2>Youtube Downloader in Python</h2>
<p>I was surprised to read an <a class="reference external" href="http://news.bbc.co.uk/1/hi/entertainment/6168950.stm">article</a> on <a class="reference external" href="http://www.bbc.co.uk/">BBC</a> that stated that <a class="reference external" href="http://www.youtube.com/">YouTube</a> had eaten substantially into television's already declining viewership. Many others did not even find it worth taking note of because they had envisioned that YouTube would be a disruptive application (true in more than a sense). An even more surprising fact was that digital TV had failed to live up to people's expectations.
On the other hand YouTube's popularity keeps increasing exponentially. Some benefits of YouTube are:</p>
<ol class="arabic simple">
<li><strong>Interactivity</strong>:The user is the king. He gets to watch what he loves. He can play a critique and collaborate with people irrespective of geographical locations.</li>
<li><strong>Lack of Censorship</strong>:Probably one of the biggest advantages of YouTube. Such services are a blessing for people in countries like China, Iran etc. It is their window to the outside world. (more so with the <a class="reference external" href="http://news.bbc.co.uk/1/hi/business/6411017.stm">BBC and YouTube deal</a> in place)</li>
<li><strong>Personalization</strong>:Services in YouTube can be personalized. Unlike TV, YouTube displays unobstrusive and contextual ads. Just try locating ads on its site and you would take a while to realise their presence.</li>
<li><strong>Copyright and Copyleft</strong>:This particular aspect was in spotlight recently, thanks to the <a class="reference external" href="http://mashable.com/2007/03/13/viacom-youtube/">Viacom</a> episode. Why do producers keep cribbing about the losses incurred by the industry? They (probably don't realise that through such media) can showcase their work to truly global audiences and get much needed publicity for (almost) free. How can anyone enjoy a movie or a music video (in such a small screen) online? The producers need to understand that internet tariffs are dearer than movie tickets or music cd's (atleast in developing countries). Rather than crying foul, they must concentrate on improving the quality of their work. They should make their work compelling enough that it'll drag people off their PC's, into movie halls. The other advantage for users is the availability of <a class="reference external" href="http://www.gnu.org/copyleft/">copyleft</a> (rather <a class="reference external" href="http://creativecommons.org/">Creative Commons</a>) material. These profess sharing and improvization of work(truly <a class="reference external" href="http://en.wikipedia.org/wiki/Web_2">Web 2.0</a>).</li>
</ol>
<p>An analogy that I can think of</p>
<p>"<cite>Lots of book publishers protested against the release of e-books fearing loss of revenue.
But indirectly e-books have helped the book publishers. A potential customer will skim
through a few pages or a few chapters (if he is patient enough and no one would risk
going blind reading an e-book) and then decide if it is worth the paper edition.
This process is quite to similar to the one that happens in a book shop. If you don't believe me
check out</cite> <a class="reference external" href="http://www.lulu.com/">Lulu</a> <cite>or</cite> <a class="reference external" href="http://www.apress.com/">Apress</a>."</p>
<p>Now coming to the point of why I wrote the YouTube downloader. Well a couple of reasons inspired me to go ahead:</p>
<ol class="arabic simple">
<li>Keeping archives of some real cool videos. There are some videos on YouTube that ought to be treasured. Why go through the pain of re-searching and then waiting for the video to stream? Once on the disk, play them whenever required. Also what is the guarantee that the video will stay online for long? It could be pulled off if some suckers have their say.</li>
<li>To show off my programming skills (or rather Python's power to make a dumb ass programmer look kewl). Frankly, I love challenges and problem solving.</li>
</ol>
<p>Before I post the code I need to give credit to <a class="reference external" href="http://solvalou.net/">Takashi Ohida</a> of <a class="reference external" href="http://video.qooqle.jp/dl/">http://video.qooqle.jp/dl/</a> for his online YouTube downloader. I downloaded his <a class="reference external" href="http://video.qooqle.jp/dl/youtube_downloader.zip">PHP source</a> and adapted it to the commandline using Python. He saved me the pain of going through those hundreds of lines of YouTube's source. As usual my gratitude goes to <a class="reference external" href="http://www.python.org/~guido/">Guido Van Rossum</a> and the <a class="reference external" href="http://www.python.org/community/">Python community</a> for the beautiful <a class="reference external" href="http://www.python.org/">Python Programming Language</a>.</p>
<div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">urlgrabber</span><span class="o">,</span><span class="nn">re</span>
<span class="kn">import</span> <span class="nn">urlgrabber.progress</span>
<span class="n">url</span> <span class="o">=</span> <span class="n">raw_input</span><span class="p">(</span><span class="s2">"Enter the URL: "</span><span class="p">)</span>
<span class="n">file_name</span> <span class="o">=</span> <span class="n">raw_input</span><span class="p">(</span><span class="s2">"Enter a filename: "</span><span class="p">)</span>
<span class="n">video_id</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s2">"\?v=(.*)"</span><span class="p">)</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">url</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">urlgrabber</span><span class="o">.</span><span class="n">urlread</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
<span class="n">param</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s2">"watch_fullscreen\?video_id=.*?&t=(.*?)&sk"</span><span class="p">)</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">a</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">final_url</span> <span class="o">=</span> <span class="s2">"http://youtube.com/get_video.php?video_id="</span><span class="o">+</span><span class="n">video_id</span><span class="o">+</span><span class="s2">"&t="</span><span class="o">+</span><span class="n">param</span>
<span class="n">prog</span> <span class="o">=</span> <span class="n">urlgrabber</span><span class="o">.</span><span class="n">progress</span><span class="o">.</span><span class="n">text_progress_meter</span><span class="p">()</span>
<span class="n">urlgrabber</span><span class="o">.</span><span class="n">urlgrab</span><span class="p">(</span><span class="n">final_url</span><span class="p">,</span><span class="n">file_name</span><span class="p">,</span><span class="n">progress_obj</span><span class="o">=</span><span class="n">prog</span><span class="p">)</span>
</pre></div>
<p>Updated this script on September 26th. Will work till Youtube changes its tactics again.</p>
</div>
Recursive Quick Sort in Python2007-03-23T00:00:00+00:002007-03-23T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-03-23:/tech/blog/2007/03/23/recursive-quick-sort-in-python/<div class="section" id="recursive-quick-sort-algorithm-in-python">
<h2>Recursive Quick Sort Algorithm in Python</h2>
<p>Well it has been a long time since I blogged about algorithms (my last post on alogrithms <a class="reference external" href="http://thejaswi.info/blog/2007/01/18/">here</a>). As promised I am back with the quicksort algorithm. The quicksort alogrithm that I've written is recursive in nature against the iterative implementation.</p>
<p>Though the iterative …</p></div><div class="section" id="recursive-quick-sort-algorithm-in-python">
<h2>Recursive Quick Sort Algorithm in Python</h2>
<p>Well it has been a long time since I blogged about algorithms (my last post on alogrithms <a class="reference external" href="http://thejaswi.info/blog/2007/01/18/">here</a>). As promised I am back with the quicksort algorithm. The quicksort alogrithm that I've written is recursive in nature against the iterative implementation.</p>
<p>Though the iterative implementation is efficient because there is a lower memory overhead as compared to its recursive implelementation, it is very complex to code (though not impossible).</p>
<p>The recursive alogorithm on the other hand consumes a lot of stack space and has a considerable overhead for the subsequent recursive calls.
I would recommend <a class="reference external" href="http://en.wikipedia.org/">Wikipedia</a> as a great resource on algorithms. You can check out this <a class="reference external" href="http://en.wikibooks.org/wiki/Algorithm_implementation">link</a> to know more about algorithms.</p>
<p>Here is the code I've written:</p>
<div class="highlight"><pre><span></span><span class="n">q</span><span class="o">=</span><span class="p">[]</span>
<span class="k">def</span> <span class="nf">quicksort</span><span class="p">(</span><span class="n">q</span><span class="p">):</span>
<span class="n">lesser</span><span class="o">=</span><span class="p">[]</span>
<span class="n">greater</span><span class="o">=</span><span class="p">[]</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">q</span><span class="p">)</span> <span class="o"><=</span> <span class="mi">1</span><span class="p">:</span>
<span class="k">return</span> <span class="n">q</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">q</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
<span class="k">if</span> <span class="n">i</span> <span class="o"><</span> <span class="n">q</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
<span class="n">lesser</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">greater</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
<span class="k">return</span> <span class="n">quicksort</span><span class="p">(</span><span class="n">lesser</span><span class="p">)</span><span class="o">+</span><span class="n">q</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">1</span><span class="p">]</span><span class="o">+</span><span class="n">quicksort</span><span class="p">(</span><span class="n">greater</span><span class="p">)</span>
</pre></div>
<p>Here is the benchmarking result that I've obtained:</p>
<div class="section" id="results-of-quicksort">
<h3>Results of Quicksort</h3>
<table border="1" class="docutils">
<colgroup>
<col width="19%" />
<col width="10%" />
<col width="10%" />
<col width="12%" />
<col width="12%" />
<col width="12%" />
<col width="13%" />
<col width="13%" />
</colgroup>
<tbody valign="top">
<tr><td> </td>
<td colspan="7">Number of Elements</td>
</tr>
<tr><td>in seconds</td>
<td><strong>10</strong></td>
<td><strong>50</strong></td>
<td><strong>100</strong></td>
<td><strong>200</strong></td>
<td><strong>500</strong></td>
<td><strong>1000</strong></td>
<td><strong>5000</strong></td>
</tr>
<tr><td>Quicksort</td>
<td>0.086</td>
<td>0.373</td>
<td>0.781</td>
<td>2.196</td>
<td>5.393</td>
<td>9.855</td>
<td>95.567</td>
</tr>
</tbody>
</table>
<p><a class="reference external" href="http://thejaswi.info/blog/2007/01/18/">Compare</a> with Bubble Sort and Straight Insertion Sort benchmark results.</p>
<p>The mere fact that the quicksort algorithm executes in micro seconds shows its speed. Thanks to <a class="reference external" href="http://en.wikipedia.org/wiki/C._A._R._Hoare">C.A.R.Hoare</a> for developing such a fast algorithm.</p>
</div>
</div>
RM to MP3 Conversion2007-01-28T00:00:00+00:002007-01-28T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-01-28:/tech/blog/2007/01/28/rm-to-mp3-conversion/<div class="section" id="id1">
<h2>RM to MP3 Conversion</h2>
<p>Very often I come across friends downloading songs in <a class="reference external" href="http://www.real.com/">RM (Real Media) Format</a> because they are very small in size. But after downloading them they realize that their favourite (MP3 sucks...OGG rocks) <a class="reference external" href="http://en.wikipedia.org/wiki/MP3">MP3</a> (portable) player cannot play them and get frustrated. Here is a small …</p></div><div class="section" id="id1">
<h2>RM to MP3 Conversion</h2>
<p>Very often I come across friends downloading songs in <a class="reference external" href="http://www.real.com/">RM (Real Media) Format</a> because they are very small in size. But after downloading them they realize that their favourite (MP3 sucks...OGG rocks) <a class="reference external" href="http://en.wikipedia.org/wiki/MP3">MP3</a> (portable) player cannot play them and get frustrated. Here is a small <a class="reference external" href="http://xiph.org/vorbis/listen.html">Vorbis vs MP3 vs Real vs Microsoft Media</a>
Now I write a small how-to convert RM Format to MP3 Format using Mplayer and Lame (standard applications in any <a class="reference external" href="http://www.gnu.org/gnu/linux-and-gnu.html">GNU-Linux Box</a>).</p>
<div class="section" id="installing-mplayer">
<h3>Installing Mplayer</h3>
<p>Since I use <a class="reference external" href="http://fedora.redhat.com/">Fedora</a> I'll be dealing with installing <a class="reference external" href="http://www.mplayerhq.hu/">Mplayer</a> using <a class="reference external" href="http://linux.duke.edu/projects/yum">Yum</a></p>
<div class="highlight"><pre><span></span>$ yum install mplayer
</pre></div>
<p>(The corresponding utilities for <a class="reference external" href="http://www.debian.org/">Debian</a> is <a class="reference external" href="http://www.apt-get.org/">apt-get</a>, for <a class="reference external" href="http://www.ubuntu.com/">Ubuntu</a> is <a class="reference external" href="http://en.wikipedia.org/wiki/Dpkg">dpkg</a> and for <a class="reference external" href="http://www.gentoo.org/">Gentoo</a> is <a class="reference external" href="http://gentoo-wiki.com/MAN_emerge">emerge</a>).</p>
</div>
<div class="section" id="installing-lame">
<h3>Installing Lame</h3>
<p><a class="reference external" href="http://lame.sourceforge.net/">Lame</a> can also be installed through Fedora Repositories.</p>
<div class="highlight"><pre><span></span>$ yum install lame
</pre></div>
<p>Once done with the installation, it is time for the conversion.</p>
</div>
<div class="section" id="converting-rm-to-mp3">
<h3>Converting RM to MP3</h3>
<div class="highlight"><pre><span></span>$ mplayer thefiletobeconverted.rm -ao pcm
</pre></div>
<p>What the above command does is that it dumps the RM Format Song to raw unencoded PCM (ie Wave Format).</p>
<div class="highlight"><pre><span></span>$ lame -h -b <span class="m">128</span> audiodump.wav myconvertedfile.mp3
</pre></div>
<p>The <strong>"h"</strong> argument specifies higher quality of encoding and <strong>"b"</strong> arguments set the bitrate, default 128 kbps</p>
<p>Hopefully you find this mini how-to useful.</p>
<p><strong>NOTE</strong>: RM to MP3 Conversion is illegal and lossy and I am not responsible for any negative consequences.</p>
</div>
</div>
Rocking Industrial Tour2007-01-20T00:00:00+00:002007-01-20T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-01-20:/personal/blog/2007/01/20/rocking-industrial-tour/<div class="section" id="id1">
<h2>Rocking Industrial Tour</h2>
<p><a class="reference external" href="http://osmania.ac.in">Osmania University</a> has been gracious enough to accomodate an Industrial Tour in the curriculum. Though meant to give an exposure to real time industrial experiences, it has ended up serving as a mini vacation with a small portion of time allotted for industrial visits.
For my class …</p></div><div class="section" id="id1">
<h2>Rocking Industrial Tour</h2>
<p><a class="reference external" href="http://osmania.ac.in">Osmania University</a> has been gracious enough to accomodate an Industrial Tour in the curriculum. Though meant to give an exposure to real time industrial experiences, it has ended up serving as a mini vacation with a small portion of time allotted for industrial visits.
For my class the preparation began as soon as the semester exams finished. First there was intense lobbying for the places of visit and after a week there was a sudden unanimity.
The places we decided to visit were <a class="reference external" href="http://maps.google.com/?hl=en&q=Pune&amp;amp;amp;amp;ie=UTF8&z=15&ll=17.923618,73.659328&spn=0.020457,0.048752&t=h&om=1">Mahabaleshwar</a>, <a class="reference external" href="http://maps.google.com/?hl=en&amp;amp;amp;amp;q=Mumbai&ie=UTF8&amp;z=12&ll=18.95987,72.820129&spn=0.162673,0.390015&t=h&om=1&iwloc=addr">Mumbai</a> and <a class="reference external" href="http://maps.google.com/maps?f=q&amp;amp;amp;amp;hl=en&ie=UTF8&amp;om=1&z=11&ll=15.251727,73.99292&spn=0.331892,0.55481&t=h">Goa</a>. (View the places on Google Maps)
The organizers headed by Anand got down to serious work, to short list industries in these cities. Finally the work was successfully completed.
Next was the work of shortlisting the travel agent and after a survey Swift Travels, Kukatpally, Hyderabad was selected.
Then the budget for the tour was negotiated and fixed at Rs.4000/- per head.
The itinerary was drawn and forwarded to the college management for approval. After a few(sic) obstacles the plan got approval and we went ahead with the tour.
The plan was announced in the class and those interested were asked to register and pay.
Initally 43 people expressed intent and a couple of them then dropped out. So the tour went ahead with 41 students and 2 faculty members.
On 5th at 8:00 pm we boarded the Mumbai Express from Nampally and left for Pune. The next day we reached Pune at 9:00am and immediately boarded a waiting bus for Mahabaleshwar (a 2.5 hour drive). Thanks to a flat tyre we reached Mahabaleshwar at 3:00pm. Hungry and tired we quickly had our lunch and went to visit Elphinstone Point and the Mahabaleshwar Temple (dedicated to Mahabali)_
Then we broke for the day and returned to the hotel for dinner. Some people went out for shopping while others decided to relax.
The next day we started in the morning at 7:30 am and travelled to Tapola where we were promised a Kashmir like island. After a 45 minute boat ride we realised that we had been duped. We were shown a barren island and were told that this was the "Second Kashmir". The travel agent covered up by telling us that we were in Mahabaleshwar at the wrong time of the year. The best time being "Monsoon" when the mountains are lush green and rivulets flow down from the hills and flood the plains. With half the day wasted, we cautiously agreed to visit <a class="reference external" href="http://www.mshwar.com/panchgani.htm">Panchgani</a>. The sight of the five table top plateaus enthralled me. We then boarded Tongas (horse carts) and went around the main plateau. The local guide (a kid of about 12 years) listed the countless movies shot at the location while I secretly admired his memory power. The last halt for the day was at <a class="reference external" href="http://www.maprofoods.com/">MAPRO</a> (Company that deals in fruit processing). We were shown around the factory and asked to help ourselves to free samples and then purchase their products. The gang had a lot of fun on the trampoline (placed near the gate) while the rest decided to relish the samples offered.
On 8th at 5:30 am we left for Mumbai (via Pune) on the <a class="reference external" href="http://www.msrdc.org/projects/mumbai_pune.html">expressway</a>. People who crib about poor roads in India must travel by the Expressway. We reached Mumbai at 11:30 am and immediately headed for Chembur where our first industrial visit was scheduled. IRESCO Electricals Limited played host to us. On seeing the industry (located in a small hut) we were shocked to the bone. Some jibed that we had come all the way from Hyderabad just to see a crammed hut. After a heavy lunch (at Matunga) we headed for the <a class="reference external" href="http://www.mumbainet.com/travel/gateway.htm">Gateway of India</a>. A couple of hours later we spent a few minutes at the <a class="reference external" href="http://www.mumbainet.com/travel/marinedrive.htm">Marine Drive</a> before heading for the Chatrapathi Shivaji Terminus (formely Victoria Terminus)_. After a two and half hour wait we boarded the Konkan Kanya Express at 11:00 pm and left for Madgaon (South Goa). We reached Madgaon at 10:45 am and immediately left for the <a class="reference external" href="http://www.ashextourism.com/hotelsresorts/Goa/StarBeachResort.html">Star Beach resort</a> at Colva (about 100 metres from the beach). Later in the evening we headed for D-Link, the second industry on our itinerary. <a class="reference external" href="http://www.dlink.co.in/dlink/software/goa.htm">D-Link</a> has a manufacturing (rather assembly line) in Goa. Back from the industry we rushed to the <a class="reference external" href="http://www.goa-beaches.com/colva-beach.html">Colva Beach</a>. It was here that many enjoyed the water sports like Banana Ride. With darkness setting in we decided to retire for the day. Some energetic junata went on a "shopping spree".
The next day ie 10th January,2007 we left in the morning for North Goa sight seeing. It included a visit to <a class="reference external" href="http://en.wikipedia.org/wiki/Fort_Aguada">Fort Aguada</a>, <a class="reference external" href="http://www.goa-beaches.com/calangute-beach.html">Calangute Beach</a> and a one hour sun down Cruise. The Cruise was the most enjoyable leg of that day's sight seeing as we were treated to some Goan Folk Dances and to a youthful dance courtesy of my class mates(They literally set the dance floor on fire). Exhausted with the day's travel we broke for the day.
On 11th January we were slated to visit South Goa. After a lingering delay we started the day's trip. First we visited the Archives Museum of Goa. The museum highlighted the life of Medieval Goans. Then we went to the <a class="reference external" href="http://www.shrimangesh.org/">Mangeshi Temple</a>. The temple is built in Portugese style and is refreshingly different compared to South Indian Temples. Next we visited the <a class="reference external" href="http://en.wikipedia.org/wiki/Bom_Jesus_Basilica">Bom Jesus Basilica</a> where the relics of <a class="reference external" href="http://en.wikipedia.org/wiki/Francis_Xavier">Saint Francis Xavier</a> are preserved. While heading back for the hotel we got a glimpse of <a class="reference external" href="http://www.goahub.com/goa/beaches/miramar-beach.html">Miramar Beach</a>. As soon as we got down in Colva we headed straight for the beach and rode the water scooter. But as luck would have it, a quarrel broke out between rivals(water sport organizers) and we were needlessly dragged into it. Sandeep handled the situation diplomatically and brokered a compromise between the two parties. But by then the sun had set and we could not parasail or do the banana ride. So we played on the beach for an hour or so and went back to our rooms. Again, I must mention some junata stayed back for shopping (this time it went on till midnight).
Finally on 12th it was time to leave Goa and return to Hyderabad. We had booked tickets for Hyderabad from Londa. <a class="reference external" href="http://maps.google.com/?q=Dharwar&ie=UTF8&z=9&ll=15.800182,74.501038&spn=1.324011,2.219238&om=1">Londa</a> was a back breaking 4 hours by bus. For about 25 Km there was no sight of roads and the bus crawled on the dust track. We experienced certain "technical difficulties" at the Border Checkpost but they were comfortably handled(in the typical Indian style). At 2:15pm we reached the Londa railway station and to our horror noticed that there was nothing for lunch at the railway canteen. Disgusted some people munched on the bisuits they had purchased earlier in the day and killed time playing cards, while a few played football in the barren fields. We boarded the train at 5pm and when we were just starting to settle in, the news of results being announced broke out. Sadly then none of the mobile networks had any coverage (So much for "Wherever you go, Our network follows you"). Around 7:30pm as we neared Dharwar and Hubli the signal on the mobiles was restored and everyone had their ears on their mobiles anxiously waiting for their results. By 9pm the train was quite with everyone knowing their marks. In this chaos, we forgot to have our dinner and the train was halting at insignificant stations where food was not sold. Hospet Junction at 10:30 pm was the last chance for us to fill our empty and growling stomachs. We scurried to the nearest food stall and bought whatever food items we could get our hands on. The canteen manager was very happy, his daily produce was sold in just under a minute. Back at the train we had our food (riddled with stones) and went off to sleep.
Next morning we were up early anxiously awaiting the Hyderabad station. Finally on arrival we were relieved and recollected the rocking Industrial Tour.</p>
<p><strong>NOTE</strong>: If someone enjoyed the tour he must thank the Osmania University rather than any Tom,Dick or Harry.</p>
</div>
Bubble and Straight Insertion Sort in Python2007-01-18T00:00:00+00:002007-01-18T00:00:00+00:00Thejaswi Puthrayatag:thejaswi.info,2007-01-18:/tech/blog/2007/01/18/bubble-and-straight-insertion-sort-in-python/<div class="section" id="id1">
<h2>Bubble and Straight Insertion Sort in Python</h2>
<p>Recently I got my hand on the book <em>Introduction to the Design and Analysis of Algorithms</em> (<a class="reference external" href="http://worldcat.org/oclc/2463560">http://worldcat.org/oclc/2463560</a>) by S.E.Goodman and S.T.Hedetniemi published by the Mc-Graw Hill Company. The book is out of print now and …</p></div><div class="section" id="id1">
<h2>Bubble and Straight Insertion Sort in Python</h2>
<p>Recently I got my hand on the book <em>Introduction to the Design and Analysis of Algorithms</em> (<a class="reference external" href="http://worldcat.org/oclc/2463560">http://worldcat.org/oclc/2463560</a>) by S.E.Goodman and S.T.Hedetniemi published by the Mc-Graw Hill Company. The book is out of print now and I found it in a library. The book had never been lent and I was the lucky first person to borrow it (20 years after it had been bought). This highlights the negligience of libraries and reading habits in <a class="reference external" href="http://maps.google.com/?hl=en&q=Hyderabad">Hyderabad</a> (India). Half way through the book (after having read the various sorting algorithms) I decided to give my programming skills in <a class="reference external" href="http://www.python.org/">Python</a> a test. I first started out writing the bubble sort program. This was probably the easiest sorting algorithm to code. Then I wrote the straight insertion sort, a better performer than the bubble sort. Though the quick sort algorithm is the most efficient algorithm, I haven't been able to code it (as of now). I am presently working on it and the program might be out soon.</p>
<div class="section" id="bubble-sort">
<h3>Bubble Sort</h3>
<div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">xrange</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">a</span><span class="p">)):</span>
<span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">xrange</span><span class="p">(</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">,</span><span class="nb">len</span><span class="p">(</span><span class="n">a</span><span class="p">)):</span>
<span class="k">if</span> <span class="n">a</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">></span><span class="n">a</span><span class="p">[</span><span class="n">j</span><span class="p">]:</span>
<span class="n">tmp</span> <span class="o">=</span> <span class="n">a</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
<span class="n">a</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">a</span><span class="p">[</span><span class="n">j</span><span class="p">]</span>
<span class="n">a</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="n">tmp</span>
</pre></div>
<p>Here "a" is the list of integers to be sorted. I used the <a class="reference external" href="http://docs.python.org/lib/module-random.html">random</a> module to generate the random data for the list.The funda of the bubble sort is to compare a particular element with all the other elements in the list. Whenever it finds a number lower than it, it swaps places with the number and the comparison goes on. Since every element (say for a N-length array) must be compared with N-1 elements and this comparison goes on for all the N elements, this algorithm is usually not preferred. It is taught in colleges and schools because it is the easiest to realise.</p>
</div>
<div class="section" id="straight-insertion-sort">
<h3>Straight Insertion Sort</h3>
<div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">xrange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="nb">len</span><span class="p">(</span><span class="n">a</span><span class="p">)):</span>
<span class="n">k</span><span class="o">=</span><span class="n">a</span><span class="p">[</span><span class="n">j</span><span class="p">]</span>
<span class="n">l</span><span class="o">=</span><span class="n">j</span><span class="o">-</span><span class="mi">1</span>
<span class="k">while</span> <span class="n">k</span> <span class="o"><>=</span><span class="mi">0</span><span class="p">:</span>
<span class="n">a</span><span class="p">[</span><span class="n">l</span><span class="o">+</span><span class="mi">1</span><span class="p">]</span><span class="o">=</span><span class="n">a</span><span class="p">[</span><span class="n">l</span><span class="p">]</span>
<span class="n">l</span><span class="o">=</span><span class="n">l</span><span class="o">-</span><span class="mi">1</span>
<span class="n">a</span><span class="p">[</span><span class="n">l</span><span class="o">+</span><span class="mi">1</span><span class="p">]</span><span class="o">=</span><span class="n">k</span>
</pre></div>
<p>We move along a fixed direction of the unsorted list and try to locate the correct location of the number ie until all the sorted numbers with smaller values come before it and all those with larger values come after it:</p>
<pre class="literal-block">
Unsorted List --> 27 412 71 81 59 13
Iteration 0: Unsorted 412 71 81 59 13 Sorted 27
Iteration 1: Unsorted 71 81 59 13 Sorted 27 412
Iteration 2: Unsorted 81 59 13 Sorted 27 71 412
Iteration 3: Unsorted 59 13 Sorted 27 71 81
Iteration 4: Unsorted 13 Sorted 27 59 71 81 412
Iteration 5: Unsorted Sorted 13 27 59 71 81 412
</pre>
<p>Then I wrote the main program ie generation of random data, sorting and verifying which is better of the two algorithms.</p>
</div>
<div class="section" id="generation-of-random-data">
<h3>Generation of Random Data</h3>
<div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">random</span>
<span class="n">a</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">matdim</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s1">'Enter the number of elements for the array: '</span><span class="p">)</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">xrange</span><span class="p">(</span><span class="n">matdim</span><span class="p">):</span>
<span class="n">a</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">10000</span><span class="p">))</span>
</pre></div>
<p>Next we check which sorting program is the best (amongst the two)</p>
<p>Results of Bubble Sort and Straight Insertion Sort:</p>
<pre class="literal-block">
Number of Elements 10 50 100 200 500 1000 5000
Bubble Sort 0.0548 0.951 4.0509 13.540 127.595 379.938 8212.631
Straight Insertion Sort 0.0381 0.725 2.723 10.940 111.083 303.351 6697.399
All times in milliseconds
</pre>
<p>The data has been rounded off to the third place of decimal. <strong>Note</strong>: The data has been obtained using Python 2.4.4 on an AMD Athlon XP Machine 2.4GHz running Fedora Core 6 with kernel 2.6.18-1.2798.fc6. The mileage may vary for tests on other machines.</p>
<p><strong>Checking</strong>: The execution profile of the sorting program has been checked using the <a class="reference external" href="http://docs.python.org/lib/module-time.html">time</a> module. There is a better way of determining the execution profile using the <a class="reference external" href="http://docs.python.org/lib/module-timeit.html">timeit</a> module. I decided not to use it since I just wanted an approximate time of execution. The primary objective was to show that Straight Insertion Sort is better than Bubble Sort.</p>
<p><strong>Last Note</strong>: As we can see from the table Straight Insertion Sort is faster compared to Bubble Sort. Quick Sort is a lot faster than either of the two sorts but it is comparitively more complex to code. I am presently breaking my head over how to code the Quick Sort Algorithm in Python (without using stacks). Hopefully should be out with it in a couple of weeks.</p>
</div>
</div>