Decoding the word ‘discipline’

What is discipline? Is disciplined life the way to a better life? Was Mahatama Gandhi disciplined? Yes. Einstein? Don’t know. Were both successful? Yes, both believed in something and had courage to live their ideas.

I always thought discipline meant to have a structured life – rise early, do exercise, eat well, sleep early. Sounds boring! But most homo sapiens struggle through life without having the tools to live an enriched life.

As, M Scott says in , The Road less Traveled, inspired by Buddhism, ‘Life is difficult‘. And he goes on to say – ‘Discipline is the basic set of tools we require to solve life’s problems‘. These words caught my attention. And, I continued reading with enthusiasm. He suggests 4 tools – delaying of gratification, acceptance of responsibility, dedication to truth and balancing.

Delaying gratification is a process of scheduling the pain and pleasure of life in such a way as to enhance the pleasure by meeting and experiencing the pain first and getting it over with. It is the only decent way to live

We must accept responsibility for a problem before we can solve it. The difficulty we have in accepting responsibility for our behavior lies in the desire to avoid the pain of the consequences of that behavior. The entirety of one’s adult life is a series of personal choices.

What does a life of total dedication to truth mean? It means, first of all, a life of continuous and never-ending stringent self-examination.

Balancing is the discipline that gives us flexibility. The essence of this discipline of balancing is ‘giving up’. The pain of giving up is the pain of death, but death of the old is birth of the new.

0
0
  

Exploring Counter and defaultdict in python collections

I needed to count frequency of items in a list. Given a list like below

some_data = ['a','b','v','c','l','c']

The ugly way was using the dictionary

frequency_count = dict()
some_data = ['a','b','v','c','l','c']

for item in some_data:
  if item in frequency_count:
    frequency_count[item] += 1
  else:
    frequency_count[item] = 1

print frequency_count

The end result is
{'a': 1, 'c': 2, 'b': 1, 'l': 1, 'v': 1}

But we can use Counter which is much cleaner

from collections import Counter
cnt = Counter()
some_data = ['a','b','v','c','l','c']
for item in some_data:
  cnt[item] += 1
print cnt

Result -

Counter({'c': 2, 'a': 1, 'b': 1, 'l': 1, 'v': 1})

But, more elegant, as suggested in comments by Andy

from collections import Counter
some_data = ['a','b','v','c','l','c']
result = Counter(some_data)

And, another way is using defaultdict

Result

defaultdict(, {'a': 1, 'c': 2, 'b': 1, 'l': 1, 'v': 1})

You can read more here http://docs.python.org/2/library/collections.html

0
0
  

List for people who love to read

1. Brain Pickings – “Brain Pickings is a human-powered discovery engine for interestingness”. You can subscribe for weekly digest.

2. Long Form – I loved ‘The Story of Suicide’.

3. Good Reads – Create your list of books read, you want to read, read reviews etc. A good site but sluggish in performance.

4. Standford Encyclopedia Of Philosophy – A great resource for those who love to explore philosophers and their ideas.

0
0
  

Two lovely quotes on marriage and children

I was reading ,’ The Road Less Traveled ‘, in the bookshop and came across these quotes.

Your children are not your children.
They are the sons and daughters of Life’s longing for itself.
They come through you but not from you,
And though they are with you yet they belong not to you.

You may give them your love but not your thoughts,
For they have their own thoughts,
You may house their bodies but not their souls,
For their souls dwell in the house of tomorrow, which you
cannot visit, even in your dreams.

You may strive to be like them, but seek not to make them like you.
For life goes not backward nor tarries with yesterday.
You are the bows from which your children as living arrows are sent forth.

The archer sees the mark upon the path of infinity, and
He bends you with His might that His arrows
may go swift and far.
Let your bending in the archer’s hand be for gladness;
For even as He loves the arrow that flies, so He loves also
the bow that is stable

Next quote –

But let there be spaces in your togetherness,
And let the winds of the heavens dance between you.

Love one another, but make not a bond of love.
Let it rather be a moving sea between shores of your souls.
Fill each other’s cup but drink not from one cup.
Give one another of your bread but not eat not from the same loaf
Sing and dance together and be joyous, but let each
of you be alone.
Even as the strings of a lute are alone though
they quiver with the same music

Give your hearts, but not into each other’s keeping,
For only the hand of Life can contain your hearts.
And stand together yet not too near together.
For the pillars of the temple stand apart,
And the oak tree and the cypress grow not
in each other’s shadow.

+1
0
  

New web ideas explored this week

1. Typing Test – multi-lingual including Hindi and Urdu
2. UI Patterns for various scenarios – Explored and found some good ideas
3. Random Hacks of Kindness – interesting idea to solve problems around the world
4. Listen to any website – give url of a page and this application will read out to you!
5. Audio books – Cool!! “Reado has been a pioneer in the world of Indian Audio books.”
6. Watsi enables you to directly fund low-cost, high-impact medical treatments for people in need. – I wonder if there is an equivalent Indian version

0
0
  

Facebook, irctc, keep-alive, performance

Many people are frustrated with irctc.co.in. The site has become excruciatingly slow! And booking a ticket is a test of patience. Not only that, sometimes you end up getting server error during the process of booking. One of my friends shared his frustration on facebook. I decided to do some research.

First, I looked at the response headers and found -

Connection:close
Content-type:text/html;charset=Shift_Jis
Date:Sun, 25 Nov 2012 08:01:22 GMT
Server:Microsoft-IIS/6.0
X-Powered-By:ASP.NET

A surprise! The site runs on IIS and is developed in ASP.NET ( the headers can be faked). The next thing I noticed was – ‘connection:close’. I thought this might have adverse affect on performance since site uses https. But, apparently no. This article says

The connection will stay open while both sides send and receive encrypted data until either side sends out a “closure alert” message and then closes the connection. If we reconnect shortly after disconnecting, we can re-use the negotiated keys (if the server still has them cached) without using public key operations, otherwise we do a completely new full handshake.

Using ‘connection:close’, helps server to keep resources free. And, since requests are ajax based, only small amount of data is exchanged between the client and the server. I found a wonderful article which traces history of keep-alive and why it is considered as harmful.
Some more resources
TLS
TCP Connection establishment

0
0
  

Stumbled On Python Libraries

I am making a list of libraries which I discover while reading blogs, mailing lists, etc. and feel can be useful.

1. Requests An inspiring library, already used in many small python scripts.

2. django-mediagenerator asset manager. Better are django-compressor and django-pipeline

3. Wappalyzer The blurb says “Wappalyzer is a browser extension that uncovers the technologies used on websites. It detects content management systems, web shops, web servers, JavaScript frameworks, analytics tools and many more.”

0
0
  

Truth

Mr Truth, you trouble us a lot. Who are you? What is your character? Why are you dressed in morals? Or, is it not your reality? Are you same as honesty? We are bombarded with “honesty is the best policy”. Please clarify. Can you please stand up and reveal yourself naked? And, why verbs are added like “search for truth”? We have to search you. Why? Are you not present? Right here, right now. Maybe, we just want to fool ourselves and feign ignorance and deny your existence.

0
0
  

Reading Digest Internet – September 9, 2012

+1
0