30 major causes of failure - Think & Grow Rich

Major causes of failure, from the book Think and Grow Rich by Napoleon Hill:
  1. Unfavorable hereditary background
  2. Lack of a well-defined purpose in life
  3. Lack of ambition to aim above mediocrity
  4. Insufficient education - best-educated are often self-educated
  5. Lack of self-discipline
  6. Ill health - including causes by overeating unhealthy foods, lack of exercise...
  7. Unfavorable environmental influences during childhood
  8. Procrastination
  9. Lack of persistence
  10. Negative personality
  11. Lack of controlled sexual urge
  12. Uncontrolled desire for "something for nothing" - gambling
  13. Lack of a well defined power of decision
  14. One or more of the six basic fears
    • Fear of poverty/criticism/ill health/loss of love of someone/old age/death
  15. Wrong selection of a mate in marriage
  16. Over-caution
  17. Wrong selection of associates in business
  18. Superstition and prejudice
  19. Wrong selection of a vocation
  20. Lack of concentration of effort
  21. The habit of indiscriminate spending
  22. Lack of enthusiasm
  23. Intolerance
  24. Intemperance
  25. Inability to cooperate with others
  26. Possession of power that was not acquired through self effort
  27. Intentional dishonesty
  28. Egotism and vanity
  29. Guessing instead of thinking
  30. Lack of capital

async & await - A simple sample

In this article I'll create a very simple WPF app, then use  Async & Await - the new asynchronous programming approach to improve its responsiveness. Hopefully will help you have a quick overview and understanding if you're new to it.

Suppose we have an empty TextBlock and a Run button, when Run is clicked we want to show a fake percentage status which is increased by 10% every 1 second. It seems very simple, just add a new line to the TextBlock each second with the increased percentage.

private void Button_Click(object sender, RoutedEventArgs e)
    for (int i = 1; i <= 10; i++)
        this.NotificationTextBox.Text += this.GetStatus(i);

private string GetStatus(int step)
    return step * 10 + "%\n";

Only it wouldn't work, you will see that instead of adding the percentages one by one, the window is hung for 10 seconds and then all the percentages are shown up at once. The use of async and await will solve this.

async await sample

First we need to turn GetStatus into an async method, you need to add the async keywork, and create a Task<string> so we can use await for it instead of just return string, it's also common to named your async method with "Async" at the end (GetStatusAsync)

private async Task<string> GetStatusAsync(int step)
    Task<string> getStatusTask = Task<string>.Factory.StartNew(() =>
        return step * 10 + "%\n";
    return await getStatusTask;

Now it's kind of intuitive to just use the await keyword when calling GetStatusAsync, but don't forget to also make the Button_Click event async, or else you will get the error "The 'await' operator can only be used within an async method" (which did make we get stuck for awhile and wonder "why the hell it doesn't work??")

private async void Button_Click(object sender, RoutedEventArgs e)
    for (int i = 1; i <= 10; i++)
        this.NotificationTextBox.Text += await this.GetStatusAsync(i);

Run the program a gain and click the button, you will see that the percentages are updated nicely every one second.

Phone Dev Reference - My WP App

After some time working on the project, my first Windows Phone 8 app is finally published on November 27, the app name is Phone Dev Reference, and here is the description:
Phone Dev Reference icon
"A quick reference for developers to see the phone controls in live action and how to create them. The app is not intended to be a step-by-step guide so you should be familiar with Windows Phone or XAML development."
The idea is a kind of reference/cheatsheet app that developers can try the phone controls and capacities right on their development phones and also see how we commonly code that. It's a good way to learn Windows Phone programming and can also serve as a quick reference if you already have experience, for sometimes there are things we have to look up again every time we need.

Phone Dev Reference screenshots

The app certification process was pretty smooth thanks to the Store Test Kit built into Visual Studio helped me caught some errors before submitting, it took about more than 3 days until I got the passed certification email from Microsoft.

The app price is $0.99 and there's a Trial mode with the restriction that you can't see CustomMessageBox, alphabet LongListSelector, and RichTextBox. I tried using ad instead of function restriction for Trial, but when I registered for real ad I realized that PubCenter hasn't supported my country yet, I also intended to try Smaato or AdMob but then I came up with this (hopefully) better idea.

You can get it here: or search for it on your phone, "dev ref" is a good keyword. (works with Windows Phone 8, it seems I added some new things only for WP8 so you can't get it on WP7)

Quiet highlights

Some of my highlights from the book Quiet: The Power of Introverts in a World That Can't Stop Talking
We’re told that to be great is to be bold, to be happy is to be sociable. We see ourselves as a nation of extroverts—which means that we’ve lost sight of who we really are.

so many people pretend to be extroverts.

We like to think that we value individuality, but all too often we admire one type of individual—the kind who’s comfortable “putting himself out there.” Sure, we allow technologically gifted loners who launch companies in garages to have any personality they please, but they are the exceptions, not the rule, and our tolerance extends mainly to those who get fabulously wealthy or hold the promise of doing so.

Introversion—along with its cousins sensitivity, seriousness, and shyness—is now a second-class personality trait, somewhere between a disappointment and a pathology.

Some of our greatest ideas, art, and inventions—from the theory of evolution to van Gogh’s sunflowers to the personal computer—came from quiet and cerebral people who knew how to tune in to their inner worlds and the treasures to be found there.

Introverts recharge their batteries by being alone; extroverts need to recharge when they don’t socialize enough.

Carnegie’s metamorphosis from farmboy to salesman to public-speaking icon is also the story of the rise of the Extrovert Ideal.

by 1920, popular self-help guides had changed their focus from inner virtue to outer charm

the new personality-driven ads cast consumers as performers with stage fright from which only the advertiser’s product might rescue them.

His hypothesis was that extroverted leaders enhance group performance when employees are passive, but that introverted leaders are more effective with proactive employees.

“The evangelical culture ties together faithfulness with extroversion,” McHugh explained. “The emphasis is on community, on participating in more and more programs and events, on meeting more and more people. It’s a constant tension for many introverts that they’re not living that out.

if you’re in the backyard sitting under a tree while everyone else is clinking glasses on the patio, you’re more likely to have an apple fall on your head.

“A mind forever Voyaging through strange seas of Thought alone.”

Deliberate Practice is best conducted alone for several reasons. It takes intense concentration, and other people can be distracting. It requires deep motivation, often self-generated. But most important, it involves working on the task that’s most challenging to you personally.

it takes approximately ten thousand hours of Deliberate Practice to gain true expertise, so it helps to start young.

Open-plan offices have been found to reduce productivity and impair memory. They’re associated with high staff turnover. They make people sick, hostile, unmotivated, and insecure.

programmers from the same companies performed at more or less the same level, even though they hadn’t worked together. That’s because top performers overwhelmingly worked for companies that gave their workers the most privacy, personal space, control over their physical environments, and freedom from interruption.

What looks like multitasking is really switching back and forth between multiple tasks, which reduces productivity and increases mistakes by up to 50 percent.

Psychologists usually offer three explanations for the failure of group brainstorming. The first is social loafing: in a group, some individuals tend to sit back and let others do the work. The second is production blocking: only one person can talk or produce an idea at once, while the other group members are forced to sit passively. And the third is evaluation apprehension, meaning the fear of looking stupid in front of one’s peers.

felt too cut off from the world to type a single keystroke... the café worked as my office because it had specific attributes that are absent from many modern schools and workplaces. It was social, yet its casual, come-and-go-as-you-please nature

The most effective teams are composed of a healthy mix of introverts and extroverts

who was unusually shy as a child, is good at school, watchful and quiet, devoted to his girlfriend and parents, prone to worry, and loves learning on his own and thinking about intellectual problems

If you spend a lot of time charging around, then you have less time for reading and learning.

Enjoyment appears at the boundary between boredom and anxiety, when the challenges are just balanced with the person’s capacity to act. —MIHALY CSIKSZENTMIHALYI

introverts, who have trouble projecting artificial enthusiasm.

A shy man no doubt dreads the notice of strangers, but can hardly be said to be afraid of them. He may be as bold as a hero in battle, and yet have no self-confidence about trifles in the presence of strangers. —CHARLES DARWIN

highly sensitive people tend to be keen observers who look before they leap. They arrange their lives in ways that limit surprises. They’re often sensitive to sights, sounds, smells, pain, coffee. They have difficulty when being observed (at work, say, or performing at a music recital) or judged for general worthiness (dating, job interviews). But there were also new insights. The highly sensitive tend to be philosophical or spiritual in their orientation, rather than materialistic or hedonistic. They dislike small talk. They often describe themselves as creative or intuitive. They dream vividly, and can often recall their dreams the next day. They love music, nature, art, physical beauty. They feel exceptionally strong emotions—sometimes acute bouts of joy, but also sorrow, melancholy, and fear. Highly sensitive people also process information about their environments—both physical and emotional—unusually deeply. They tend to notice subtleties that others miss—another person’s shift in mood, say, or a lightbulb burning a touch too brightly.

high-reactive temperaments come with risk factors. These kids are especially vulnerable to challenges like marital tension, a parent’s death, or abuse.

someone offers you a beer, says the personality psychologist Brian Little, “they’re really saying hi, have a glass of extroversion.”

human extroverts have more sex partners than introverts do—a boon to any species wanting to reproduce itself—but they commit more adultery and divorce more frequently, which is not a good thing for the children of all those couplings.

Sensitive people seem to do the reverse. They “enjoy small talk only after they’ve gone deep,” says Strickland. “When sensitive people are in environments that nurture their authenticity, they laugh and chitchat just as much as anyone else.”

introverts are “geared to inspect” and extroverts “geared to respond.”

if you leave them to their own devices, the introverts tend to sit around wondering about things, imagining things, recalling events from their past, and making plans for the future. The extroverts are more likely to focus on what’s happening around them. It’s as if extroverts are seeing “what is” while their introverted peers are asking “what if.”

“It’s not that I’m so smart,” said Einstein, who was a consummate introvert. “It’s that I stay with problems longer.”

people who focus on their own instincts and those who follow the herd.

The wind howls, but the mountain remains still.

we can feel sociable at 6:00 p.m. and solitary at 10:00 p.m

Yes, we are only pretending to be extroverts, and yes, such inauthenticity can be morally ambiguous (not to mention exhausting), but if it’s in the service of love or a professional calling, then we’re doing just as Shakespeare advised.

Jealousy is an ugly emotion, but it tells the truth.

Introverts should ask themselves: Will this job allow me to spend time on in-character activities like, for example, reading, strategizing, writing, and researching? Will I have a private workspace or be subject to the constant demands of an open office plan? If the job doesn’t give me enough restorative niches, will I have enough free time on evenings and weekends to grant them to myself?

single. You dislike the bar scene, but you crave intimacy, and you want to be in a long-term relationship in which you can share cozy evenings and long conversations with your partner and a small circle of friends. In order to achieve this goal, you make an agreement with yourself that you will push yourself to go to social events, because only in this way can you hope to meet a mate and reduce the number of gatherings you attend over the long term.

“I am social,” she says. “I love you, I love my family, I love my close friends. I just don’t love dinner parties. People don’t really relate at those parties—they just socialize. You’re lucky because I devote all my energy to you. You spread yours around to everyone.”

Your degree of extroversion seems to influence how many friends you have, in other words, but not how good a friend you are.

Big Five traits: Introversion-Extroversion; Agreeableness; Openness to Experience; Conscientiousness; and Emotional Stability.

The purpose of school should be to prepare kids for the rest of their lives, but too often what kids need to be prepared for is surviving the school day itself.

kids stop learning when they feel emotionally threatened

my passion overcomes my shyness once I get started on a speech. If you find something that arouses your passion or provides a welcome challenge, you forget yourself for a while. It’s like an emotional vacation.”

contributing earlier in a discussion is a lot easier than waiting until everyone else has talked and letting the tension build as he waits to take his turn.

While extroverts are more likely to skate from one hobby or activity to another, introverts often stick with their enthusiasms.

intense engagement in and commitment to an activity is a proven route to happiness and well-being

Well-developed talents and interests can be a great source of confidence

Figure out what you are meant to contribute to the world and make sure you contribute it.

Quit your job as a TV anchor and get a degree in library science. But if TV anchoring is what you love, then create an extroverted persona to get yourself through the day.

Respect your loved ones’ need for socializing and your own for solitude (and vice versa if you’re an extrovert).

Normalize string and remove special characters

Long, long ago I wrote an article about creating a simple search engine which is able to work with characters containing accents, imagine we want to reuse it for URL rewriting (e.g. we don't want our URL to be 'núi-biển-đà-nẵng-^^', it should be 'nui-bien-da-nang').

This is the old normalization code:
private static string NormalizeString(string inputWord)
    StringBuilder stringBuilder = new StringBuilder();            
    foreach (char c in inputWord.Trim().ToLower().ToCharArray())
        string normalizedChar = c.ToString()
            .Normalize(NormalizationForm.FormD).Substring(0, 1);

    return stringBuilder.ToString();

We need to remove special characters in the text if it has any, usually we just use numbers 0-9 and characters A-Z for URL. We can do that easily by converting the normalized character to ASCII and compare it. Take a look at this ASCII table:, you can see that 0-9 in ASCII is from 48 to 57, and A-Z is from 97 to 122. So here is the code:
// Not to add special characters
int ascii = (int)char.Parse(normalizedChar);
if ((ascii >= 48 && ascii <= 57) || (ascii >= 97 && ascii <= 122))

You will notice that the code correctly converts 'ú' to 'u', 'ể' to 'e', 'à' and 'ẵ' to 'a', but 'đ' is gone. Supposedly you added some code for converting the whole sentence yourself, you will get 'nui-bien-a-nang' instead of 'nui-bien-da-nang'.

How is that possible? It seems somehow 'đ' is completely different from 'd', it's not 'd' with accent but another character itself, and its ASCII is 273 (neither from 48-57 nor from 97-122, and gone). I can't find any solution for that but this:
if (normalizedChar == "đ")
    normalizedChar = "d";

Yes, that's it. Please let me know if you have a better solution. 'đ' is the only issue I found so far, I hope it's the only one, otherwise we will have to add more conditions.
That's it for our URL generator, I'm sure you can write your own code for adding '-' between the words right?

Device and Service - Kindle experience series

I'm enjoying my Kindle Basic now, but my confession is that when I was thinking about buying one, I didn't intended to use it the way I'm using it now.

This is the last post in my Kindle experience series:

Kindle Basic - Collections Scott Hanselman was right, I'm reading more than ever, there's something special about it, something makes you just want to pick up the Kindle and read, maybe the small and skinny design, maybe the collection of many books (even though I've just bought  2 by far, the rest are just samples :P), maybe the E Ink screen... Whatever the reason, I'm glad I'm spending more time on books and less time hanging around the web pointlessly.

Reading PDF files, that was the most important reason for me to own a Kindle, but it turned out Kindle is not a good PDF reading device (maybe Kindle DX is, if you don't mind its overwhelming size). With a Kindle format file (AZW), you can change the font size of the book, but of course you can't do that with PDF, and Kindle's zooming function works well for images but not PDFs i think. The best option is using Landscape mode, but it still depends on the design of the PDF file, some files look great in Landscape and easy to read, but some are still a little hard to read because of small text. You might also want to try converting to AZW by sending the file to "name" or using an app but most of the time you'll get some pages with broken layout (I also tried sending a DOC file to Amazon service for converting, unlike PDFs, the outcome file looked great).

Luckily the easiness to get books and samples made me forget the pain, we know that with Kindle, it's easier to get and read books, but it's even double in value when you're a foreigner, I've never thought it would be that easy to get English books, with the so-called Amazon Whispernet, suddenly everyone on the world has the same opportunity. Kindle books' prices are kind of affordable, many are even free, including some classic novels. But I still think it should have been cheaper, I ran into many programming and software development books with very high prices, and some books have their Kindle version more expensive than physical version, strange, isn't it?

Speaking of English and foreigners, a dictionary is a must, and Kindle does this rather too well than I expect. You just need to move the cursor next to a word and its meaning will be automatically display at the bottom or on the top of the screen. The default dictionary is Oxford, which is English - English, if you want another you'll need to buy or find a free one.

When reading Kindle books, you have the option to go to the table of contents, beginning, end, location... And I love how we can highlight, bookmark, and create notes, but when having so many highlights (e.g. 20 pages of highlights) I didn't find any easy way to navigate but having to move from page to page. If you take notes often when reading, then go for Kindle Touch, or something non-Kindle, because taking notes with Kindle Basic's 5-way controller is not easy at all. Your annotations can be synced with other Kindles, Kindle for PC, and Kindle Cloud Reader; you can also share them at Also note that you can add annotations to PDFs but neither the files nor the annotations can be synced.

Overall, though there're still many rooms for improvement, I would love to see a hybrid between Kindle Basic and Kindle Touch, a device with better PDF experience (and not too big like DX)... but if you love reading, don't wait. Even if you're not a bookworm, you should consider owning one, for it can make you become one.

Fire, Touch, or Basic? - Kindle experience series

A weird thought came into my mind recently: maybe I'll need 4 years, not for university or anything but read.

This is the first post in my Kindle experience series:

I intended to write it all in one post but it's kind of long and time-consuming so I have to break down like this. There might be some changes in the number of posts or post titles but what I'm going to share is still the same.

When everyone started talking about the Kindle Fire, I paid some attention to it and thought about owning one (actually I almost bought one :P). Why? Because I thought it's a cheap eBook readers which can do more things than other Kindles and does things other Kindles can better.
But after doing some research, I realized that we shouldn't call Kindle Fire an eBook reader (I think the term "comic reader" is more correct). Take a look at this table:

Compare Kindles
Kindle BasicKindle Basic
Kindle TouchKindle Touch
Kindle Fire
Kindle Fire
6" E Ink Pearl
6" E Ink Pearl
7" Vibrant Color IPS
 Battery Life
 (Wireless off)
1 month
2 months
8 hours
6.5" x 4.5"
x 0.34"
6.8" x 4.7"
x 0.40"
7.5" x 4.7"
x 0.45"
5.98 ounces
7.5 ounces
14.6 ounces
 Supports Audio
 Touch Screen
 “X-ray” Content
 Content Formats
Natively: Kindle (AZW), TXT, PDF, unprotected MOBI, PRC.
Through conversion: DOC, DOCX, JPEG, GIF, PNG, BMP
Natively: Kindle (AZW), TXT, PDF, Audible (Audible Enhanced(AA,AAX)), MP3, unprotected MOBI, PRC.
Through conversion: DOC, DOCX, JPEG, GIF, PNG,  BMP.
Natively: Kindle (AZW), TXT, PDF, Audible (Audible Enhanced(AA,AAX)), MP3, unprotected MOBI, PRC.
Through conversion: DOC, DOCX, JPEG, GIF, PNG, BMP.
(with special offer)
(with special offer)

"Kindle's E Ink screen reads like real paper, with no glare".
See the "vibrant color screen" there? I was a fool thinking Kindle Fire screen were something like "E-Ink-with-Colors screen". Besides, I don't want to charge my reading device every 8 hours.
So it looks like Kindle Touch is the best option here: more storage, more battery life, supports audio... Oh wait... what's wrong with the so-big "Landscape mode"? It's a very big issue in my opinion, but Amazon, CNET, and many other big sites don't even mention anything about it. That's like a conspiracy to me so I want to make it big here.
If you haven't known, Landscape mode is essential to read PDF files (otherwise the text will be too small), actually I encountered some PDF files which even when you switch to Landscape mode, the text is still a little small, but at least it's readable. You might think if you only use AZW files, then that's not a big deal, but some books also contain images, and many of them are also  easier to see in Landscape mode. All in all, I think most of us will need Landscape mode sooner or later.

And this is my conclution:
Kindle Fire is not good for reading.
Screen rotation is not available on Kindle Touch.
So I go for Kindle Basic, the biggest drawback here is that it does not support audio, but the thought of something that is good for nothing but reading is kind of sexy, isn't it?