Wednesday, March 23

The Alchimist - A Magical Fable About Following Your Dream

I got an opportunity to read this book. I had only heard once about this book from a friend. The alchimist by Paulo Coelho is one of  the finest book i have ever read. Its about following your dreams. The protagonist is a Shepard, a believer and a dream follower. The book shows us how to count our blessings, live with the facts and the most important trust in your own self.

I have noted down some of the most remarkable excerpts here.

If you start out by promising what you don't even have yet, you'll loose your desire to work toward getting it.
The principal of favorability - When you play cards the first time, you are almost sure to win. Beginner's luck.
Why is that? Because there is a force that wants you to realize your destiny, it whets your appetite with a taste of success.
When you want something, all the universe conspires to help you achieve it.
I'm like everyone else. I see the world in terms of what i would like to see happen, not what actually does.
Every blessing ignored becomes a curse.
The closer one gets to realizing his destiny, the more that destiny becomes his true reason for being.
We are afraid of losing what we have, whether it's our life or our possessions and property. But this fear evaporates when we understand that our life stories and the history of the world were written by the same hand.
The principal that governs all things, its called the SOUL of the world. When you want something with all your heart , that's when you are closest to the soul of the world. Its always a positive force. Everything on the face of the earth had a soul, whether a mineral, vegetable or an animal - or even just a simple thought.
Now , I'm beginning what i could have started ten years ago. But I'm happy at least I didn't wait twenty years.
It's not what enters men's mouths that is evil. It's what comes out of their mouth that is.

There are many more. This book is very inspiring and worth reading.

Monday, March 21

Jquery, Get a block of html in a variable.

I came across this situation where , i had to get a block of html code to store in a variable, along with the html off-course. I was using, jquery. you can do this using a simple jquery function html().
For eg. if your code is

<div id="mycode">
<p>My description</p>
</div>

Then your jquery code should be

var data = $("#mycode").html();
This snippet saved me a lot of time and i could achieve the requirement.

Tuesday, March 8

Php : Breaking a Long string using wordwrap function

While working on facebook application, the user email id can be a proxy id provided by facebook. This email id is a long piece of string. While displaying this email id, it would occupy most of the width on the page. I had to break the string using the php built in wordwrap function.

Consider this string.
$string = "apps.232434343432+4343245342.12323skj23236512312323216+343@proxy.facebook.com";
To break the string so that it fits inside a td tag of width 300px use the wordwrap() function

$new_string = wordwrap($string,40,'<br />',true);
Check out the php manual here