Monday, March 30

The Optimist - One man's search for the Brighter side of life - Lawrence Shorter

This book looked promising and I had to read it during the summers. The Title was exactly what i was looking for subconsciously. As the title suggest, the book is a straightforward journey into finding what optimism is? If i have to sum it up, it is a big book of great quotes, however I've realised that it there is no path to being optimistic. Initially i thought there will a set of rules, following those would help a person attain the highest level of optimism.

I must say, the pessimist in me has welcomed the new optimistic. I for now am looking at a brighter side of life and some of the things that are mentioned in the book actually are useful which I have started applying in my day to day life.

Below are all the beautiful quotes that I would life to mention here for my future reference. 

Bad news had left me unscathed. I was an optimist, and I was proud of my ability to ignore events and carry on as if everything were fine. That was the privilege of optimism. Deep down if you're an optimist, you know that everything is going to be OK. You don't know why - you just know. It's like your little secret.

First law of optimism : The more optimistic you are, the better life gets.

It was midway by the time I walked out of the house. I didn't know where I was going, but I was ready. I was glad and, for the first time in weeks, I felt full of optimism.
Confidence is the feeling you have before you understand the situation - Anonymous
The pessimist were a terrible and inscrutable enemy. Even though we lived in the most wonderful and fortunate period of human history, there were still people out there addicted to negativity, who made it their task to spread fear and anxiety.

Ashley judd believes that suffering will always exists. She's learned to accept that.

Accepts yourself and accept the negative. God is love, so if we do loving things, be loving , love ourselves and let the love for ourselves emanate out, that will set us on the path to finding the peace and serenity that is possible in this lifetime.

The atmosphere felt monastic and peaceful, far away from the chaos and stupidity of the outside world.
There is nothing either good or bad, but thinking makes it so. - William Shakespeare, Hamlet.
Learned Optimism - Martin Seligman
Each of us has our 'explanatory style' a way of thinking about the causes of things that happen in our lives. The basis of optimism does not lie in positive phrases or images of victory, but in the way you think about causes.

Optimism comes down to three things : When something bad happens do you
1) Take it personally
2) Expect it to last forever and
3) let it affect other areas of your life?
If so, then you're a pessimist.

Seligman - We've found that happiness is measurable and that there is a formula for this...
Life satisfaction  = Positive Emotion + Engagement + Meaning.
There are shortcuts to positive emotion, but there are not shortcuts to engagement, The engaged life is when you're totally absorbed in what you're doing and it comes when your highest challenges meet your highest strengths. There's also meaning. Human beings ineluctably want meaning and purpose in life, but this only happens when you use your strengths to serve something bigger than yourself.

Scientific technique for raising human happiness. Three blessings Exercise :- Every night before you go to sleep, write down three things that went well today. It turns out that building gratitude is one of the main ways of developing happiness.
The three blessings is an intervention for increasing positive emotion about the past. Optimism is related to emotion about the future.

when you're a pessimist you give up easily, when you're an optimist you try. Pessimist just have different thoughts about adversity.

Pessimists have habits of thought, which mean that they interpret failure very negatively. These negative thoughts then create feelings of helplessness, which in turn feed depression. Pessimist tend to take bad luck personally. They see bad events as a reflection on themselves. They also tend to assume they're going to last forever and they're going to affect all parts of their life. But if they can learn to question and dispute those thoughts, then they can shift their explanatory style from a pessimistic one to an optimistic one.

Can pessimism be cured?
It's a training. You can teach yourself to recognise the negative thoughts you're saying to yourself before you start believing them. You become an expert disputer of your own beliefs.

Seligman says it's not our problems that makes us depressed. It's our thoughts.

Human beings ineluctably (not able to be) want meaning and purpose in life, but this only happens when you use your strengths to serve something bigger than yourself.

Saligman -Author of Learned Optimism, provides the following tip :-
Stand up and slam the palm of your hand against the wall and shout 'STOP!' This is one of several simple but highly effective thought stopping techniques used by people who are trying to interrupt habitual thought patterns.

Achieving enlightenment is every Buddhist's goal. It means an end to suffering, a state of bliss.
Buddhist don't believe in God. They only believe in supreme consciousness. All entities including the self are an illusion. The only way to avoid suffering is to escape from all human attachments.

For an optimist, it makes no sense to lose hope. We can always do better (instead of being devastated, resigned or disgusted), limit the damage (instead of letting it all go to pot), find an alternate solution (instead of wallowing pitifully in failure), rebuild what has been destroyed (instead of saying 'it's all over!') take the current situation as a starting point (instead of wasting our time crying over the past and lamenting the present), start from scratch (instead of ending there), understand that sustained effort will have to be made in the best apparent direction (instead of being paralysed by indecision and fatalism), and use every present movement to advance, appreciate, act and enjoy inner peace (instead of wasting our time brooding over the past and fearing the future).

In creative visualisation you use your imagination to create a clear image, idea, or feeling of something you wish to manifest. Then you continue to focus on the idea, feeling, or picture regularly, giving it positive energy until it becomes objective reality.
"The question is, when did you stop growing? When did you stop having those Aha! moments? And that's the moment you died. Most pessimist are the walking dead. It doesn't matter that they breath and they get up and eat. They are dead" - Taddy Blecher.
What education means?
The word education came from the Latin 'educare' - to lead out. It meant leading out the genius out of heavy human being, the beauty in everybody.

We live in a field of infinite possibility. We just have infinite possibilities for creating solutions to the problems we have.

Transcendental Meditation is an easily learned, natural mental technique which opens the awareness to the infinite reservoir of energy, creativity and intelligence that lies deep within everyone. Whatever you believe in, whatever system you follow, what matters is that you do it.

Transcend the boundaries of fear.
Somewhere in your heart is a powerful voice which is telling you what you should be doing. If you an break through the boundaries of fear and just listen to that voice, then everything will be beautiful, or listen to the voice, then break the boundaries. It doesn't matter which way around you do it. If you have problems hearing the voice then you can meditate, although this is only necessary if you have a tiny narrow awareness of life and you absolutely need it.

Today Blecher didn't spend hours alone with his computer, sending emails to celebrities and making notes in his diary. He worked with other people, lots of other people. That's where he got his energy from.

Since the beginning of time people have been trying to change the world so that they can be happy. This hasn't ever worked, because it approaches the problem backward.

Most people are at war with reality. They are never at peace because they believe their thoughts and their thoughts do not accept what is and so they suffer.

When I believe my thoughts, I suffer, but when I question my thoughts, I don't suffer.

Stress in your life is caused only by one thing, your reaction to not getting what you want.

My philosophy of life is that everything that happens to you happens for the best. In other words it's impossible for you to make a mistake.
"The terrible has already happened" - Heidegger
Power of acceptance - Forgive them, they don't know what they do.

In trusting there is a power to see clear, a power to be able to see in the future.
The most intelligent thing you can do is to appreciate everything, no matter how bad it is. It won't take long before life will give up. It will adapt to your mind and deliver only good things. - Marbel Mohr.
The universe always acts in your best interest and always brings into your life exactly what you need at any instant...

Everything in life happens to confront you with some deep inner fear. So that you can let go of it. But you can't let go of things before you know them. The process is about facing deepest beliefs and emotions.
"Screw it, let's do it : Lessons in life - Richard Branson"I have found that, if I have fun, the money will come. I often ask myself, is my work fun and does it make me happy? If something stops being fun, I ask why? If  can't fix it, I stop doing it"
When you have goals and positive outlook on life, you have something to aim for.

Richard Branson
What drives me is being in a position to change things, to keep learning and to be in a position to make a difference. Throughout my life I've been trying to get into that position, and now I'm in that position I don't want to waste a minute of it. But I also have an attitude in life that however hard I'm working and however tired I am, make sure I enjoy every single second of my life, and if you just make sure you enjoy every person  you're with and every second of your life, the pleasure you're going to give other people is enormous.

True optimism is about following your heart. It's about visualising things and letting them flow effortlessly into your life.

Fear of pain is so much worse than the pain itself.

Notes to pessimist
Gottfried, wilhelm heibniz (1646 - 1716) :-
Everything is perfect because - mathematically - nothing is this world could be any other way. For similar reasons, anything that can happen will happen.

Buddha :-
Suffering is causes only by believing painful thoughts. Life will keep presenting you with situations until you finally stop believing them. Everything that happens to you, happens because you 'need' it.

Viktor Frnkl (1904 - 97) :-
If you are afraid of something, its much more likely to happen to you. 'Fear brings to pass what one is afraid of'. Suffering is an achievement in its own right.

"The law of attraction" states that like energies attract. Therefore whatever we think about the most we will experience.
"We have found that merely repeating positive statements to yourself does not raise mood or achievements very much, if at all. It is how you cope with negative statements that has an effect. - Martin seligman
If you can break things into bite-sized pieces you can handle anything.

Realism consists of accurately seeing the probabilities of a good or a bad outcome, then accepting this reality. But true options consists of accepting the risks and then doing it anyway.

Dr wong was a chinese psychologist who had developed a radical new approach to optimism.

Tragic Optimism :- Tragic optimism is an attitude, and its defining characteristics is acceptance of reality. To develop tragic optimism you need some kind of spiritual belief, a religion, something bigger than yourself.

Optimism and Pessimism are two related but independent dimensions.

Tragic optimism means admitting that life is tragic but still maintaining the hope that tomorrow will be bigger.
We know that bad things happen most of the time, but also life is worth living. It doesn't matter how bad things get, there's still something worth living for.

"So many people say they can't make a living, can't pay the rent - but I've tried it myself and I think if you're willing to work hard there's plenty of work out there. I'm willing to drive a truck, I'm willing to do laundry, I can go shopping for you and I'll go walk your dog. You can still make a decent living. I'm very optimistic.

If you want to get filthy rich, you might have an impediment (something that makes it difficult to do or complete something, something that interferes with movement or progress) wants to work hard I think the sky's the limit.

"Yesterday I met a man who suffers from insomnia. When he wakes up in the middle of night, sweating, unable to sleep, clogged by worries about his career or his children, he writes them down and puts them in a jar. Then he screws the lid and places the jar on top of the bookshelf, far out of reach. Once a week he allows himself to schedule a meeting with the worry jar. They get half an hour of his time and that's it. At the end of each year he invites his friend around for a party and he burns the jar."
"That thing the nature of which is totally unknown to you is usually what you need to find, and finding it is matter of getting lost - Rebecca solnit"
Craig newmark - founder of craigslist.
What makes me optimistic in a big way - by following through with principles, giving people a break and treating others well, somehow we have created a culture of trust with the community.

Optimism is a lot of things. The most important thing I've learnt is that none of it matters at all. Not even a tiny little bit.

Thursday, March 26

Outliers – The story of success - Malcom Gladwell

Outliers – The story of success is a non-fiction book written by Malcom Gladwell. I had heard a lot about this book and the title itself is very promising, so this had to be my next read.
What is an outlier? "Outlier" is a scientific term to describe things or phenomena that lie outside normal experience.

In this book, the author tries to examine the factors that contribute the high level of success. By taking into consideration some of the well-known, highly successful people, and examining their life minutely, the author tries to discover the reason behind their success.

For example, the Canadian Ice hockey team players are born mostly in the first few month of the calendar year. Their birth month, then gives a clear picture to author that the initial selection will be based on age and thus getting selected to a school team will provide them good exposure to better facilities, thus making them the best players. The author also discusses about Bill Gates, and the famous music band “The Beatles” and tries to find out their success story.

The most important point according to me is :
You have to work hard. Period. The stories of people go back in early 20’s. The author sheds light on the time period in which these successful people were born and other external factors, but the truest reason I found was that these people were successful, because of their hard work.

Wednesday, March 25

HTML Email Designs - Points to consider while designing a HTML email.

I have done considerable HTML email development. Though I am not a good designer, I would like to share some of the points that I would want to see in an HTML email as a consumer/reader.

  1. KISS Principal -
    Keep it simple, stupid is a very good principal and I agree to it. I think even Apple agrees to it. However, the simpler the design, more easy it is to read and so would actually catch user's attention. Users like me use their emails extensively and I for one immediately delete an email if it has more than required information.
  2. Content is King:
    Yes, and I do believe this to its core. However, when it comes to an HTML email, we have to ensure that the most relevant information is provided. You can have external links for user to view a detailed version of information, however even that needs to be methodically arranged.

  3. How many Images?
    The less, the better. If the HTML emails are for a brand, then obviously you would have your logo as an image and then you can have one main image. I feel two images are more than enough.

    HTML emails are viewed in numerous clients and clients such as Outlook would not download images (Outlook requires to have user’s permission to download image). Also consider the mobile clients, having to load images in mobile takes up extra data usage; they are slow at downloading images. Thus coming back to the original proposal, try having less images.

  4. Provide Links to external pages wherever applicable:
    Let’s say you have to design a newsletter, and there is a lot of information that you have to display. As a user, try to analyze which information is important, useful and relevant. You can always have links to external pages with more information in case if the reader is interested. Thus you can achieve the same design without cluttered content.
    Ask yourself, would I be reading this email if it had landed up in my inbox?
  5. You can have beautiful rounded corners to anchor tags:
    Only if you are not strict about having the same design on multiple clients. With new devices such as android/iPhone some of the CSS3 properties are available to use. So you can have beautiful rounded corners (or more of css3 fun) for latest clients and degrade gracefully to outlook and other non-supporting clients.

Monday, March 23

The Element – How finding your passion changes everything - Ken Robinson

The book is well written, easy to follow and has very nice anecdotes worth noting done for future reference. I’ve enjoyed the book. This is one of the few books that I enjoyed thoroughly. I wasn’t compelled to finish till the last page but was looking forward to finish it.

Conventional route to success:
Live your life straightforward, get in school, get a college degree and then get a job that you are forced to like so that you can earn money. Get married and have children. If we have to plot a graph of this lifestyle I am sure it would be a straight-line.  Since you’ve earned money and can fulfill the most basic lifestyle for your family, you have this feeling of being successful.  Where did the passion, the thought of doing something out of the box, the adventure, the risk, doing something just for the fun and not for the outcome, go? You are accustomed to living a conventional lifestyle and you are too bored to get out of that comfort zone.

The above is a typical scenario and I don’t feel ashamed to agree that it may represent me. However I am quite sure I am going to change it.

Below are some of the excerpts that I really feel are worth noting down and should be revisited again to boost the morale.

  • Some people have no real sense of what their individual talents and passion are. They don’t enjoy what they are doing now but they have no idea what actually would fulfill them.
Matt Groening – Creator of “The Simpsons” : I understand the series of stages I was supposed to go through, you go to college, you get a credential, and then you go to out and get a good job. I knew it wasn’t gonna work for me. I knew I was gonna be drawing cartoons forever.

  • Never underestimate the vital importance of finding early in life the work, that for you is play. This turns possible underachievers into happy warriors.
The Element: - Describes a place where the things we love to do and the things we are good at come together. Being in our Element depends on finding our own distinctive talents and passions.

Why most people have not found their Element?
  • People have limited conception of their own natural capacities. People don’t understand their own powers.
  • Limitation in our understanding of how much potential we have for growth and change. For the most part, people seem to think that life is linear, that our capacities decline as we grow older, and that opportunities we have missed our gone forever.
Young kids aren't particularly worried about being wrong. If they aren't sure what to do in a particular situation, they'll just have a go at it and see how things turn out. This is not to suggest that being wrong is being creative. Being wrong is just being wrong. What is true is that if you’re not prepared to be wrong, you’ll never come up with anything original.

Education is the system that’s supposed to develop our natural abilities and enable us to make our way to world. Business everywhere says they need people who are creative and can think independently. It’s about having lives with purpose and meaning in and beyond whatever work we do.

People didn't pursue their passion simply because of the promise of a paycheck. They pursued them because they couldn't imagine doing anything else with their lives.

  • The Element is a meeting point between natural aptitude and personal passion.
  • The Element has two main features and there are two main conditions for being in it. The features are aptitude and passion. The conditions are attitude and opportunity. I get it, I love it, I want it, Where is it?

Key principles of the Element are that we need to challenge what we take for granted about our abilities and the abilities of other people.

One of the enemies of creativity and innovation, especially in relation to our own development, is common sense. The playwright bertolt brecht said that as soon as something seems the most obvious thing in the world, it means that we have abandoned all attempts at understanding it.

Taking the definition of intelligence for granted is one of the main reason why so many people underestimate their true intellectual abilities and fail to find their Element.

Three features of human intelligence.
1)      It is extraordinary diverse.
2)      It is tremendously dynamic.
3)   It is entirely distinctive.

You don’t be creative without acting intelligently. The highest form of intelligence is thinking creatively. Everyone is born with tremendous capacities for creativity. The trick is to develop these capacities.

The process of seeing “in your mind’s eye” is the essential act of imagination. So my initial definition of imagination is “the power to bring to mind things that are not present to our senses”.

Through imagination we can visit the past, contemplate the present, and anticipate the future. We can create, we can conjecture, we can hypothesize, we can speculate and we can suppose.

Creativity : The process of having original ideas that have value. To be creative you actually have to do something.

Creativity involves several different processes that wind through each other. The first is generating new ideas, imagining different possibilities, considering alternative options. The creative process also involves developing these ideas by judging which work best or feel right.

What we think of ourselves and of the world make us who we are and what we can be.

“The greatest discovery of my generation is that human beings can alter their lives by altering their attitude of mind… if you change your mind, you can change your life” – William james.

Being in the zone happens when psychic energy or attention is invested in realistic goals, and when skills match the opportunities for action. The pursuit of a goal brings order in awareness because a person must concentrate on the task at hand and momentarily forget everything else.

Being in the element and especially being in the zone doesn’t take energy from you, it gives it to you.
Activities we love fill us with energy even when we are physically exhausted. Activities we don’t like can drain us in minutes, even if we approach them at our physical peak of fitness.
Some people are most in their element when they are working alone.

Personal, social and cultural are the three concentric circles of constraints barriers to finding the element.

Throughout his life, chuck close has had endless reasons to give in to his problems and to give up as an artist. He chose instead to push on beyond every limit his life presented and to stay in his element no matter what new obstacles reared up in his way.

Whether you’re disabled or not, issues of attitude are of paramount importance in finding your element.  A strong will to be your self is an indomitable force.

It is easier to overcome people’s judgment than to overcome our own self judgment, the fear we internalize.

Groupthink : The effect of our decision, thoughts are all based on how our peers think.

According to Irving Janis, a psychologist, groupthink is a mode of thinking that people engage in when they are deeply involved in a cohesive in group, when the members striving for unanimity override their motivation to realistically appraise alternative cause of action. The prevailing belief here is that the group knows best, that a decision or a direction that seems to represent the majority of the group stands beyond careful examination – even when your instincts suggest otherwise.

It is not what happens to us that determines our lives – it’s what we make of what happens. It’s not what happens to us that makes the difference in our lives. What makes the difference is our attitude towards what happens.

Attitude and Aptitude
One way of opening ourselves up to new opportunities is to make conscious efforts to look differently at our ordinary situation. Doing so allows a person to see the world as one rife with possibility and to take advantage of some of those possibilities if they seem worth pursuing.
Another attitude that leads to what many of us would consider “good luck” is the ability to reframe, to look at a situation that fails to go according to plain and turn it into something beneficial.

The role of mentors
Recognition – Mentors recognize the spark of interest or delight and can help an individual drill down to the specific components of the discipline that match that individual capacity and passion.
Encouragement – Mentors lead us to believe that we can achieve something that seemed improbable or impossible to us before we met them.

Facilitating – Mentors can help lead us toward our Element by offering us advice and techniques, paving the way for us, and even allowing us to falter a bit while standing by to help us recover and learn from our mistakes.

Stretching – Effective mentors push us past what we see as our limits. A true mentor reminds us that our goal should never be “average” at our pursuits.
Feel the fear and do it anyway – Susan Jeffers.

Remarkable, life enhancing things can happen when we take the time to step out of our routines, rethink our paths, and revisit the passions we left behind for whatever reason we can take ourselves in fresh direction at nearly any point in our lives. We have the capacity to discover the Element at practically any age.

Thursday, March 12

How to store JSON in sessionStorage

Let's say you want to store JSON as a sessionStorage in your browser.

JSON example

        "id": "1",
        "name": "John Doe"
        "id": "2",
        "name": "Jane Doe"
        "id": "3",
        "name": "Mike Doe"
        "id": "4",
        "name": "Henry Doe"

A short Algorithm
1) Check if a browser supports sessionStorage
2) If Yes, Look for an existing data in SessionStorage
3) If No, get data from Server and then Store in SessionStorage

If(typeof(Storage) !== “undefined”){
  alluserRecords = JSON.parse(sessionStorage.getItem(“getUserRecords”));
  /* Lines of Code that gets the desired JSON via a AJAX call */
  sessionStorage.setItem(“getUserRecords”, JSON.stringify(data));


While Storing in sessionStorage we need to call the JSON.stringify function on the raw JSON object. This will convert it into string. SessionStorage stores data in the key value form where value is normally of type String.
If we do not convert it into the String, then sessionStorage stores it as [Object, Object] which is not readable.

After you have stringified the JSON and stored correctly in your sessionStorage, you may later want to convert back the value to a readable JSON format. It is when JSON.parse function is useful.

Sunday, March 1

MySql : Get the count of records from a table with Group By clause

While doing pagination i wanted to get the count of all the records to get the total number of pages. However since i am displaying the records grouping them via date parameter the total number of records will be affected.

Scenario : I am storing user records date wise. So on a particular date i could have entered more than 1 record. While displaying data, important is that i get the total records on date field.  The best option is to use a group by to get all the entries on a date, followed by a count on that query.

See MySql statements below.

Test 1 : Get all the records group by date for a particular user

SELECT count(*) as totalcount 
FROM task_details 
WHERE task_details.users_id = '7' 

The above query returns total number of entries that are made a on a particular date for a particular user.

To get the total entries the user made date wise, we could call a select count(*) on the above query. For example see below

SELECT count(totalcount) as total 
    SELECT count(*) as totalcount 
    FROM task_details 
    WHERE task_details.users_id = '7' GROUP BY DATE(
) as results

The above query returns the total entries (count) by user date wise.

Please note the use of "results" which is an alias to the subquery query. If we do not give any alias then MySql returns an error. Ref : Stackoverflow question here.