Linux netstat example

netstat command is used to see the network connections.

Java8 understand stream filter

I knew a long time ago that there is a method filter in stream. Every time I use it, I don’t know how it filters internally. Will he remove the qualified ones or leave the qualified ones? Every time I need to run the code to make sure my logic is correct.

Java ReentrantLock tryLock example

RentrantLock is more flexible than synchronized. When using synchronized, the thread will be blocked if the lock cannot be obtained. If RentrantLock is used, the above problem will not occur. We can use the tryLock method to try to obtain the lock and process our own business logic by obtaining the result.

guava implement round robin

we can use Iterators.cycle of guava to implement round robin. Here is an example.

Linux systemctl list all services

Use follow command to list all services in CentOS7.

Linux wget output to stdout

Use the following command to output the result of the wget command to the screen instead of saving it to a file.

IDEA change new project maven home directory

The default home directory of the Maven project in IDEA is Bundled(Maven 2) or Bundled(Maven 3). I am used to using my own Maven home directory. So, every time I create a new project, I will change this default Maven home directory. It is too much trouble. After reviewing the official documentation, I learned that the default new project settings can be changed.

git bisect example

Before starting to learn this command, we need to initialize a git directory. The following script can help us initialize a git repository with 20 commits

Maven change mirror repositories

If you want download artifacts faster you need to configure maven setting.xml file.

Enable PostgreSQL remote access

Following these steps to enable PostgreSQL remote access.

Config PostgreSQL in CentOS7

It is no way to use service postgresql-9.4 initdb init PostgreSQL in CentOS7. I use following commends.

PostgreSQL dump and restore database

It is easy to dump database by using pg_dump commend.

Red packet algorithm

This is an interview question. Not fully understood yet. ;(

guava BloomFilter example

The biggest advantage of the Bloom filter is that his space usage is very high. His disadvantage is that there may be misjudgments. Bloom filters return two values: elements may exist and elements definitely do not exist.

redis benchmark

Benchmarking Redis is very easy. After completing the redis installation, there is a command tool in his directory to perform benchmark tests. Here is a simple example.