git sync remote tag to local

I want sync remote tags to local. After google I got some commends. Unfortunately, those commands sometimes work and sometimes don't work. I think this may be related to the environment and the version of git. Eventually I finally found a universal solution.

Get file md5 example

When we download file from remote server. We need to check the integrity of the file. In general, the website will provide the md5 value of the downloaded file. In this page I will show you how to use apache-commons-codec to get the md5 of file.

okhttp post json example

okhttp is one of best network framework. In this page I will show your how to use it post json to remote server. The code is here.

Java understand IncompatibleClassChangeError

When I use thrift generate classes I got IncompatibleClassChangeError. This error means the class you depends has changed. Let's say your project depend on ClassA.class. When ClassA.class upgrades to new version (add some new methods or fields). It's name doesn't change. You project can use both old and new version of this class. This is "Binary Compatibility". But when the new version change one static field to no-static. IncompatibleClassChangeError will be thrown.

Java8 Collectors.mapping example

There are many practical methods in the Collectors class. mapping method is one of them. In this page I will show you how to use mapping method in Collectors. Let's say you have a list of users(List). Let's say you want to group these users by age. The code will be like this.

Java8 CompletableFuture concurrence example

It is very convenient to use CompleteFuture to implement concurrency in java8. I will show you how to use it in this page. Let's say you need to query someone's information(address, company name, family). Every query need 300ms. If you request the information one by one, you will need about 1 second. If you use the CompleteFuture concurrent request, it only takes 300 milliseconds.

CentOS install docker

It is easy to install docker in CentOS. Open the official website of docker copy commands and paste them in your terminal. now docker only supports CentOS7+. Before installing you need make sure your CentOS version is higher than 7. For the detail you can click here

Execute multiple commands by redis-cli

We can use redis-cli to connect redis sever and execute command. Today I want to execute multiple commands. After connecting redis server I copy multiple commands and paste them in redis-cli. I got error message. My commands are like following.

Spring Boot async example

Generally we call methods in a synchronous manner. In some cases we need to call methods asynchronously. @Async can help us call methods asynchronously when using Spring Boot. Before using @Async we need to add an @EnableAsync on the startup class. Here's a simple example that shows how to use @Async to implement asynchronous method calls.

Java understand daemon thread

Recently I am writing a program that processes messages in the background. The program quits when I start 10 threads. I checked all the exception stack information and found no errors. I tried to find this "error" on Google and didn't find any useful information. Why my program or my thread stop? I read my code line by line. It seems like following.

MySQL change data directory

The default data directory of MySQL is /var/lib/mysql. If there is no disk space for this directory we need to move data to another directory(another fileSystem). In my environment I install MySQL by yum command. The /var/lib/mysql directory is mounted on / and there is no more space for data. I change data directory by using these following commands.

fastjson convert generic classes(list)

fastjson is excellent framework for handle json data. It can parse json string to generic classes. Here is sample code.

Linux telnet check remote port

We can use telnet to check weather the remote server port is open or not. The command is easy to use, just telnet . When the remote server port is open it will output like following.

Linux share directory with python

Sometimes we need copy file from server to local. There are several ways to do that. We can use scp, sz commands to transfer files. scp command need us to input local IP, username and password. sz command need us to install lrzsz. Today I found another way to do this.

Apache commons stopwatch example

The class StopWatch class which in apache-common-lang package is a good tool for timing. It provides some useful method to measured running time of program. Most of these methods of StopWatch are easy to understand. Only one method: split() need us try to understand.