Category Archives: Technical

Weight your toys

I decide to write this post because this post reminds something about my weakness when dealing with algorithm problems.

Here’s the problem, I put it to gist.


 

How to abstract reality problems to sort problems, and how to take advantage of sort to find out things that interest us?

The code above, I want to use observer design pattern ( compare_event ). Yes that’s the part to emphasise that we always want to search things interest us, if not, why we search things? So that is the pattern of human beings, and I always decouple things when I find a point that fit normal brains.

Here is the steps that I always follow to create a solution:

  1. Understand them, feel them, and try to measure them. We always have a way to quantify things, though most people die here or find a really bad way to measure things.
  2. So we have convert states to numbers in the first step. We can use the numbers to compare two things.
  3. If I want to search something, I always search things while sort them. You always do the two things together, think about it when you are paring the socks from your washing machine. Even school child does it without thinking.
  4. I interpolate tasks while each comparison. Searching itself is also a task. Each task can access the current comparison result and process state.
  5. Choose a sort algorithm which fit the situation best
  6. Launch the whole process.

 

Git Daemon Two Common Mistakes

This is a powerful function introduced since git 1.7. The git will listen to a port and receive  incoming git protocol request. When we need to auto deploy project inside a private network, it is one of the easiest way to work with. It doesn’t depend on http or ssh, and much faster. Though it doesn’t support user authentication, it still a good solution for sharing code.

Two common mistake that the git documentation doesn’t mention:

  1. A white list path must be set.
    Something like this won’t work: 
  2. The white list path should be an absolute path or ‘./‘ prefixed.
    Something like below won’t work, the  test_repo should be prefixed:   ./test_repo , or use absolute path 

A simple correct example should be like below.

Then access your server by git push git://server_addr:8123/test_repo .

I wrote a simple shell function to help setup:

 

Circular list formula

This example, list length is 2 elem, mask length is 1 elem.
So the total item number should be 3 elem.
The total virtical offset should be 2 elem.

Thoughts on naming convention

I heard a lot of voices saying that they want to make their coding style the same with the corresponding frameworks, so they study the ancestors’ codes and mimic the so called golden standards.

Keeping coding style the same with the framework is no wrong. But don’t lost your own voice when you are trying to follow other’s. 

I prefer my coding style being different from the framework that I’m using. One big advantage is that it will be much easier to distinguish which part of the codes is mine and which belongs to the API. For example, a mix of camelCase and underscore conventions:

If a new member comes to read this java snippet, he will find it useful to find the road map of this project. Sometimes I think a proper way to mix will make life easier, isn’t it?

Sublime Text 3 plugins – Lots of plugins won’t make you a superman

Recently, the newly Sublime Text 3 is just around the corner. It has been years I have digged into its creativity world.

The rich API of ST cultivated so many wonderful plugins, but intall lots of plugins won’t make you a superman, we should learn to reduce the noise of this buzzing world. Therefore, my recommendation will focus on the most pure and down-to-earth plugins that just work.

Continue reading