Category Archives: Technical

Collective Phenomena

Inspired by this post, I wrote a CoffeeScript implementation. This is a very interesting phenomena that revealed the beautiful philosophy behinds the nature, a slight push to the collection of simplicity can make miracles : D

As you can see, each particle is just moving around on a circle orbit with the same velocity, only the initial position is different. However, when they are made a whole, things begin to be interesting.

Continue reading

Some tips of Goagent on Unix-like system you may need to know


There are plenty of tutorials about how to setup a minimum Goagent server and client. I won’t reinvent the wheel here. Who may want to read this post.

  1. You have already setup the Goagent server and client, and it seems working ok.
  2. You still can’t visit Google+, Twitter, Facebook, or so on.
  3. You want to wipe out all the warning information, and make your Goagent work perfectly.

Continue reading

My terminal theme

This theme is build on the top of zsh and the famous OH MY ZSHELL. Besides, it has been included in the official OH MY ZSH repo : D

To a compatible theme, I think it’s better not to use special characters like ╭  ➜  ✗ . If you want your theme works fine on both Unix and Windows, a clean format and a simple color scheme are necessary. Therefore, I use only ANSI Character Set and ANSI Colors. The main goal of this theme is to make the  *nix servers’ admins happy. This theme is even more robust than the default theme robbyrussell.

I separate each command group with an empty line in front of the “#” prompt. The indicator words are all in a dim color. The most eye-catching color yellow is assigned to the current directory. For other colors’ setting, the same color will be assigned to different location with a long distance. And the more important it is, the more warmer color it is assigned to.

For the purpose of making the beginner to learn the command line easier, I set the dollar symbol “$” as the main command prompt. The %” or “# indicates the current state of the terminal. The “L” indicates current shell level, it can be useful when you are in nested shells. The last “N” indicates the current command number, with the time stamp you it may help you calculate how long a command takes.

The basic theme format:

Continue reading

Some thoughts on the software’s auto-update design pattern

There are so many ways to get the program to have the ability of auto-update. But as I’ve known, there is no way can absolutely make sure the program will update itself as expected. For example, you have defined some data type, in your program and store the data locally. And you have happily distributed your product to thousands users. Then months pass, you add some details to the basic data type. You migrate all the user data properly, and everything gone fine. Not a single complain heard from you users. Things turned complicate when the third time you update your data type. Now you have 3 types of data. Some of your users may be still the oldest version. Fortunately, you have left a tag in the data type to mark the version of the data type. So you take your time to check the version, and implement 2 method to migrate the data.

How about if this pattern continues for around 10 times? How many migration methods you should implement? Nine, of course. But if for some reason some of your users have reversed the version to an old one? From the basic principles of combination, we need 10×9 which means 90 methods to meet the requirement. That sounds crazy.

The main problem is because you can’t be sure whether all the users have always updated to the newest version. In other words, you need to find a solution to sync all the users program version and don’t hurt their data. On one can predict the future, we never know how the data finally like.

To be continued…

A Batch Encoding Convertor for Text File and ID3 Tag

encoding conventor

When copying some of my old project files from Windows 7, the origin system text file encoding made some troubles for me. So in December, I wrote a small tool to help me out. But before days, the same problem came out again when the old mp3 ID3 tagged files met the iTunes. Therefore, I extended the tool to automatically convert the mp3 files to the specified encoding. I used the ID3iconv to help with the tag editing.

Continue reading

A Simple Python Web Bot Implementation

Here I just want to mention one thing, sometimes it might be more aesthetic use another language to present the comments. The comments will be easier to be found through a bunch of codes.

MSV Application Architecture

I think the general MVC architecture is not perfect enough for a complex dynamic application. The most confusing part of the MVC is it’s Controller. It receives the user sent data, sends commands to change the state of the Model, and also takes the responsibility to change the presentation of the view.

I think it could be simpler:

  • Model
  • Service
  • View

To separate each component’s responsibilities, and make the architecture more open. I replaced the Controller with the Service. The Service only handles the data that the View requests, such as REST, or sends commands to change the Model’s state. All UI logic is moved to the View, and all View requests are async based. So that we can take the full control of the representing flow the application. The front-end developers will only need the client knowledge and skills to construct the dynamic content of the application.

The disadvantages of this architecture are obvious. The client should at least supply a programmable interface. Such as the HTML based web application, the browser should support javascript and the javascript is enabled. And looser coupling means lower performance.