Uncategorized

Sending Messages to Yourself on Skype

I always like a simple feature in Slack that you can chat with yourself to store notes, links, files or your own reminders. Despite that fact that I use it most of the time, this feature doesn’t exist in Skype, and I really hate it.

Turns out there is a simple trick to do it that I happened to discover yesterday:

On Skype, create a new group chat with only you in there.

Done! Name the group my notes or something. Pin it so that you can easily access to it. One more thing: enable the Share Link then save the link. In case you happen to accidentally leave the group, you can re-join it again.

Now that Skype can have the chat-to-yo-self feature like Slack does.

Advertisements
Uncategorized

Today I Found: Bill Gates’s message for college grads if they want to change the world.

In his letter, Bill Gates wrote that he was lucky because he started his venture at the right time, when the digital revolution was just underway, and the young people at that time had had a great opportunity to shape it.

Today, college graduates have also the same chance with these fields:

If I were starting out today and looking for the same kind of opportunity to make a big impact in the world, I would consider three fields.

One is artificial intelligence. We have only begun to tap into all the ways it will make people’s lives more productive and creative.

The second is energy, because making it clean, affordable and reliable will be essential for fighting poverty and climate change.

The third is biosciences, which are ripe with opportunities to help people live longer, healthier lives.

But his letter contains a very important point which I also agree with:

For one thing, intelligence is not quite as important as I thought it was, and it takes many different forms.

In the early days of Microsoft, I believed that if you could write great code, you could also manage people well or run a marketing team or take on any other task. I was wrong about that. I had to learn to recognize and appreciate people’s different talents. The sooner you can do this, if you don’t already, the richer your life will be.

(emphasize mine)

Bill had the same point as with Jeremy Harbour in his book “Go Do!” in which: when one who is excel in his technical skill may not be ready to start his own company because he lacks other important skills.

today-i-found

Today I Found: Soft-Coding & #1 Deadly Sin of Programmers

A question on StackOverflow, What is Soft-Coding (anti-pattern), introduced me to the term soft-coding (a pun to hard coding).

To explains simply the term, I quoted the code snippet of the accepted answer:

SpecialFileClass file = new SpecialFileClass( 200 ); // hard coded

SpecialFileClass file = new SpecialFileClass(DBConfig
  .Start()
   .GetConnection()
    .LookupValue("MaxBufferSizeOfSpecialFile")
      .GetValue());

Too much of anything is not good. The above is not an exception. Too much of flexibility led to over-engineering.

This is somehow similar to the #1 deadly sin in the series Seven Deadly Sins of Programming by Eric Gunnerson.

Uncategorized

Morning 28.9

​Tweet an article written by Digg Engineers about how they migrated one of their modules from Node.js to Golang. Their result was a sucess.

The article gives a very detail analysis why Node.js did not meet their needs anymore. It also mentioned that the performance of the module was increase a lot. However, they stated that there were no plans to migrate all of the rest to Go.

Then I happened to find out a profile named VietCoding and then find out a blogging platform full of Vietnamese developers with good articles, kipalog.com.

Big world!

java

How to iterate over a Collection in Java?

Traditional way

List<Integer> numbers = ...

for (int i = 0; i < numbers.length(); i++) {
    if (i % 2 == 0) {
        Integer value = numbers.get(i);
        if (value % 2 == 0) {
            // do something to value
        }
    }
}

Pros:
– an iconic way
– can access to both index and value at the same time

Cons:
– too much code

Use:
– when you need to know the index of the element in a loop.

The Iterator way

In Java, Array and Collection all implement Iterable which returns an Iterator.

List<Integer> numbers = ...

for (Iterator<Integer> it = numbers.iterator(); it.hasNext();) {
    Integer value = it.next();
    if (value % 2 == 0) {
        it.remove();
    }
}

If you need to know the index, use ListIterator (only work with List):

List<Integer> numbers = ...

for (ListIterator<Integer> it = numbers.listIterator(); it.hasNext();) {
    Integer index = it.nextIndex();
    Integer value = it.next();
    if (index % 2 == 0 && value % 2 == 0) {
        it.remove();
    }
}

Pros:
– supports iterator over all kinds of Collection types (Set, Queue, etc)
– can remove elements during iteration.
– faster than Tranditional way in case of LinkedList or other Collection implementation where random access is time-consuming.

Cons:
– too much code

The Enhanced for way

This is the most recommended way since Java 5 if you just need to iterate over a Collection without the need to access to the index.

List<Integer> numbers = ...

// read as "for each number in numbers"
for (Integer number : numbers) {
    if (number % 2 == 0) {
        // do something with number
    }
}

Tips:

To iterate over an entire java.util.Map, please use this:

Map<String, Object> cache = ...

for (Map.Entry<String, Object> entry : cache.entrySet()) {
    doSomeThingTo(entry.getKey(), entry.getValue());
}

Pros:
– simple, easy to read
– keep variables’ scopes clean (especially in nested loops)

Cons:
– cannot access to the index of the element (well, not every time we need it actually)

The Java 8 way (or the function way or the lambda way)

In Java 8, Stream API has been introduce which makes it very easy to iterate and do somthing no elements of a Collection.

List<Integer> numbers = ...

numbers.stream()
    .filter(number -> numbers % 2 == 0)
        .forEach(number -> doSomething(number));

// or simply

numbers.forEach(number -> doSomething(number));

Pros:
– easy to write and read
– method chain
– lazy evaluate

Cons
– the API has quite a lot of methods so it takes time to master all of them.

notes

Big Data and its application?

I & my girlfriend was coming back to our hometown, Bien Hoa city. As usual, every time I was in motion, I always have some really deep thought.

When she & I was discussing about how we could invest money by buying gold and then selling again to make some profit, a thought came to me that we can develop a algorithm that can analyze the up & down of gold market and predict when should buy and when we should sell gold to make the best profit. And this can apply to every thing, for example, real estate, clothing, stock, etc. Or we can gather data from Google Map and then apply principle of Feng Shui to detect and suggest which land we can invest and make profit.

The problem is, how can I develop such system when I don’t have any knowledge and experience in Data Analysis and Big Data algorithm. I think I need to consult with someone else about this.

Uncategorized

Knowing Your Code’s Structure

I haven’t paid much attention to how the classes in my projects communicate with each other. Looking at the package structure, they all look good and well-organized. Then one day, I came across the article Your Code Structure and it made me to seriously think about re-validate my source code.

In the article, Edmund Kirwan used his tool, named Spoiklin Soice, to analyze the modules of JUnit from the early version to the latest one. The result was that as JUnit evolving, its classes had become more tangled and its structure had become a real mess (according to the graph).

This was really interesting because JUnit had been a widely known & used by almost all Java developers and it was developed by the lengedary Kent Beck. In the article, the latest version of JUnit, 4.11, had become really complex due to new features added into the library. I had always thought of JUnit as a powerful and well-tested tool and never paid attention to its structure and design ever since I used it. It could be the case that as time goes by, JUnit would become more and more difficult to extend and mantain due to its complexity.

Well, that was for JUnit, how about my projects? Spoiklin Soice is really interesting tool, I will use it to analyze them to see whether the structure is still controllable.

But what if we knew that the structure of a project had become too complex, what we could do to make it right again? Or there are any principle that we could follow and then keep everything in its right position?

Download and read more about Edmund’s work at his blog: http://edmundkirwan.com/general/spoiklin.html