Author Archives: ledohoanglong

How to find anything with Google


You can find almost every kind of information with Google. That’s nothing new. But how?

A quick example: Yesterday, my friend’s headphone seems go wrong suddenly. When he views his favorite “comedie musicale” (he likes to say it so), he can hear the music, but not the voice of the singer. Such a crime to art.

So I advise him to ask the know-it-all of our century, Dr. Google. Though my friend must be kind of a difficult person himself, he is still far from this Doctor. Dr. Google answers every question thrown at him, but with one condition. You should know what you ask for.


After my friend throws in a dozen of query, like, “how can’t I hear my musicale”, I can’t standby any more. Putting in “headphone hear music but no voice”, go view first three links in SuperUser, skim through stuff, and find the right solution.

Below is some tips for doing it more efficiently.

1. Put thought in your search query. Be concrete. Think about what people may say if they have the same problem. Chances are, hundreds people have solved your problem before,

2. Identify reliable sources. SuperUser is a site I often search first when having problems with my computer. Clear question, short answer, easy to read, to the point, and saves lots of time. You can find your source by yourself.

3. Try searching by English first. If it doesn’t work, try a different language. You will be surprised when you see the gap between documents of different languages.

StackOverflow: why it succeed?

You succeed when you reach your goal. Simple at that.

Why StackOverflow is a success? It’s not because that the website has reach 560M page view/ month. It’s because it makes software developer’s life easier.

My criterion for whether Stack Overflow works: when you type your question into Google, and you’re happy to see a Stack Overflow result rather than a result at another one of those Q&A sites where you have to sign up and pay a monthly fee to see the answer. - Joel Spolsky

Once you understand the site’s goal, you would understand the hard choice that its creators have made. Many people complain how the site has been so strict in its “standard” for question and answer. When they come to the site asking for help, but leaving unsatisfied. Or worse, their question would be closed in few seconds because it’s “too broad”.

It’s because that SO “true” customer are the indirect users, those who come searching for an answer. The answer gets written only once, but it gets read millions of times years later.

The more time you spend on writing a short, clear and coherent question, the more time would be saved from your reader.

Logging or debugger?

It all begins when I read a small story over the net:

A young girl watching her mother prepare a ham to bake for dinner. As the mother cut both ends off the ham, the daughter asked why. Mom replied that her mother had always done it that way. When the daughter still insisted on knowing why, a quick call to grandma revealed the reason: “Because the pan was too small.”

The story above is exactly what I usually get when I try to present something new. Like what I’m going to do here.

Well, not exactly new. Debugging by using log vs. debugging using debugger was a long time debate. We can google dozens of articles written about the subject. And while most of them use the very political phrase “it depends” as an answer, I would confidently tell you “logging is obviously superior in 99% of the time“. Continue reading

Simple things matter

Today, out of boring, I did visit again codility to take a few tests. Their free tests aren’t much of a challenge, so I got them one by one, each in 5 minutes or so. Then I come across a test which, to my opinion, just a little trick question:

Problem: PermMissingElem

Task description
A zero-indexed array A consisting of N different integers is given. The array contains integers in the range [1..(N + 1)], which means that exactly one element is missing.
Your goal is to find that missing element.
Write a function:

 class Solution { public int solution(int[] A); } 

that, given a zero-indexed array A, returns the value of the missing element.
For example, given array A such that:
A[0] = 2
A[1] = 3
A[2] = 1
A[3] = 5
the function should return 4, as it is the missing element.

Feel free to drop a few minutes to think it through. It isn’t even hard.

You finished your program? Ok, then let’s continue.
I took my 5 minutes and write a very simple script, including the unit tests:

First Solution
class Solution {
public int solution(int[] A) {
// write your code in Java SE 8
int sum = 0;
int sumTotal = (A.length + 1) * (A.length + 2) / 2;

for (int i = 0; i < A.length; i++) {
sum = sum + A[i];

int result = sumTotal - sum;
return result;

Unit tests:

  • [6,5,4,3,2]
  • [2, 5, 1, 4]
  • [2]
  • [1]
  • [6,3,5,4,2,1]

All my unit tests passed. I submitted, kind of waiting for another 100%. But it was FAILED with n ~ 1,000,000.

My algorithm is right, I know that. So what’s the matter with big number?

In case you’re still wonder, here’s the program that worked and got 100% score:

Right Solution

class Solution
public int solution(int[] A) {
// write your code in Java SE 8
int sum = 0;
int sumTotal = 0;

for (int i = 0; i < A.length; i++) {
sum = sum + A[i];

for (int i = 1; i <= A.length + 1; i++) {
sumTotal = sumTotal + i;

int result = sumTotal - sum;
return result;

Can you tell the difference? :)

Model is model – a quick draft

A sample of business model

Model is model, nothing more, nothing less.

Recently when I take a course about Corporate Strategy, I learn about various strategic diagrams. BCG1, BCG2, Life cycle diagrams… there are a lot of them.

Many of my classmates wonder why we must do this/that by a different way. Why we calculate relative market share based on relative comparison with the market leader; but for market leader, we compare with the second-follower?… Many questions, but the reason for all the confusion is that they are put down as “unquestionable reality” and are not easily explained by logic or mathematics.

So I feel the urge to note down a few things:

1. Models don’t decide reality. None of them does. So, if the BCG doesn’t fit your organization situation, feel free to drop it. Forget the classes and the lectures, they only give you the tools. What we really need is the model mindset – a method to use that powerful tool.

2. Models are made to reflect & simplify the world. They are used to explore ideas & explain knowledge. They help us make clearer thinking and focus on specific aspects of the reality. There are models all around us. From the map of a city, to the schedule calendar, or a quick draft of a painter… they are all models. They are not reality in its full sense: they reflects reality, with the focus on what we care about.

Let’s take the Hochiminh city map as an example. In a map, we don’t describe a city. We don’t show that the Ben Thanh Market is painted with yellow color, or The Palace of Independence is covered by a beautiful garden. What we really care about: they are streets & their directions, how to move from 1 point to another. So the map is made with only lines & dots, & symbols, to help you traveling.

The same applies for the BCG matrix. The real business environment is complex, so that people must come up with some simplification to get the direction. It doesn’t mean we must always drop the dog and feed the star. For some cases, if cleverly handled, a dog SBU can be positioned in a niche market and bring profits without much investment (becoming cash cow), while some stars must be dropped for gathering enough money to invest in 1-2 best stars.

Ok, so, BCG model means that in most cases, dropping the ineffecient SBUs is a good idea, so that we could save money for others. Damn, we can understand it without BCG, it’s normal logic. So why we need BCG? Because it’s too simple, easy to remember & understand. That’s all.

Therefore, please don’t get the model for itself, but understand it, and apply to the situation.

Shiseido – and Japan philosophy of service

Little Omotenashi photo little-omotenashi_zpsb24a009a.jpgOmotenashi

The highest form of hospitality is Omotenashi. In summary, it’s “the host anticipates the needs of the guest in advance and offers a pleasant service that guests don’t expect.”

Coming from a pharmacy, to a leading cosmetics vendors in the world economy, is not simple. However, Shiseido did it.

I will not go further into the analysis how a small pharmacy can grow to a company, and how an Asian organization can succeed in such a competitive market, where Western companies have lots of technology advantages. There are quite a few reasons: the timing, the technologies, marketing… and so on.  Just forget them for now. The only thing that makes Shiseido special, in my view, is the reason for that the company exists.

Shiseido is built on the philosophy of Omotenashi.

Omotenashi photo japanesegirl_zpsb9b6cc23.jpg

Omotenashi: The word ‘Omotenashi’ in Japanese comes from omote (surface) and nashi (less), which means “single-hearted”, and also mote (carry) and nashi (accomplish), which means “to achieve”. Therefore, Omotenashi has two meanings, which include offering a service without expectation of any returned favour, and the ability to actualise that idea into an action.

Don’t take the word, look into their action:

Only in the Mirai-Tsubaki 2012 project, Shiseido sent out 45,800 employees to do 131 social welfare activities throughout the world. They build schools, give books to students, promoting good traffic behaviors, send cosmetics (yep) to victims of the Japan earthquake 2011, training handicapped women in Vietnam, planting trees, developing natural-friendly cosmetics, recycling drugs,… And they do it all when the financial situation is going down.

Shiseido considers the most beautiful skin is the natural skin. It believes that the skin itself can’t be good without the well-being of the whole person, the harmony of both body and mind. The true beauty doesn’t come from the skin itself, but come from the caring, empathy of the people. I remember a story, when a young American girl comes to cosmetics store for a make-up. The consultant tells her: “you are young, and your skin is beautiful already. You don’t need any make-ups. Instead, you should learn how to take care of your skin, so that it will be always beautiful.”

That’s how an organization can LAST.

Never use “reserved keyword” as column name

The title says it all. Never EVER use the reserved keyword of a database system for a column name. You will meet problems that cost lots of time (which isn’t worth at all!)

If someone tells you about this little trick:

    &lt;class name=&quot;long.model.User&quot; table=&quot;USER&quot;&gt;
        &lt;cache usage=&quot;read-write&quot;/&gt;
        &lt;id name=&quot;id&quot; column=&quot;ID&quot;&gt;
            &lt;generator class=&quot;sequence&quot;&gt;
                &lt;param name=&quot;sequence&quot;&gt;user_seq&lt;/param&gt;

        &lt;property name=&quot;position&quot; column=&quot;&amp;quot;POSITION&amp;quot;&quot;/&gt;

Then just kick him in the ass! Why we should use something as dirty as “"”?

If you still not believe, take the example above, then try to UPDATE the position of a random user.

As you may guess:

UPDATE public.user set position = 'MANAGER'; // NOT WORK 
UPDATE public.user set 'position' = 'MANAGER'; // NOT WORK 
UPDATE public.user u set u.'position' = 'MANAGER'; // NOT WORK AGAIN 
UPDATE public.user u set u.POSITION = 'MANAGER'; // NOT WORK! 


Here’s what you MUST do if already get fallen into the trap

UPDATE public.user set &quot;POSITION&quot; = &quot;MANAGER&quot;; // WORK! Windows only 
UPDATE public.user set &quot;POSITION&quot; = 'MANAGER'; // WORK! only Linux 

Hence don’t try to trick the system. Curiosity is good, but you might need to pay for it by several hours playing with how Postgresql deal with case-sensitive name. Nice to find out, but either way, it isn’t a portable database script.

[Duolingo Introduction] Part 1: From Captcha to Digitalizing the books


Duolingo is a startup that focus on language-learning. And it’s a nice one.

Being constructed by the founder of Re-captcha, Duolingo also shares the vision of utilizing the power of community to make the world better. So, before the story of Duolingo, I’ll tell you the tale about how  Luis von Ahn creates Recaptcha.

recaptcha-exampleHave you even registered in any website? Did you see little words that you must type to prove that you are not a auto-robot? “If you type the weird words in the images right, you may get in”. If you saw it, you know what a Captcha is. It’s a simple mechanism – based on the fact that no matter how far technology goes, it’s still nearly impossible for a machine to tell a bad writing from random images with thousands of senseless dots.

Ok, but have you ever asked yourself, why sometimes, you must type 2 words instead of 1?

The reason is simple. When Luis sees that we all must type Captchas everyday, he wants to make it more useful.  He told himself: we still have lots of books/ materials in paper form. If we scan them, they still be in pure image form – we won’t be able to search them like a text ebook. The current technology doesn’t allow machine to translate from image to text accurately. But what if people can help in the process?

So Recaptcha was born. Among 2 word-images Recaptcha gives you, it only knows exactly 1 word. If you type that word right, Recaptcha will recognize you as a human and let you in. And yes! Because you type one word right, the second word should be right too! You just translate an image to a word!

missing you

The result is that a lot of books in Google Scholar is digitalized that way.