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 Sketch of a Puppy

My first time to use Corel Painter to draw something. Thanks to the pencil brush tool, it only took about one hour to finish this sketch. And I really miss the Paint Tool SAI on Windows. What I am currently using is Painter 12. To be frank, Painter is the most inconvenient design tool that I’ve used. The keyboard shortcut design is poor, and the tool manipulation is far from good.

Another thing that I learned from this sketch is that Photoshop sucks when handling complex brush painting or natural like painting.

The pen tip of the Intuos 4 feels so loose when you quickly drawing short lines. So I fix the pen tip with some scotch tapes inserting into the pen tip hole. And it really helps. The nice short lines come back again.


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.

The better way to combine hashcodes

For example, two int numbers x and y. A simple way is like below:

But it’ll be easily result in collision. To avoid this, Joshua Bloch performed an elegant way to combine two hashcodes:

The usage of the prime numbers are the most brilliant part of the algorithm.