CentOS7 virtualBox install guest additions

In order to use share folder you have to install guest additions in VirtualBox. In this page I will show you how to install it. Click devices -> Install Guest Additions... and wait a minute. Open terminal in CentOS7. Before installing it you need make sure your environment is OK.

CentOS config double network adapter

When you install CentOS in virtual machine you need to config double network adapters. One is for connecting internet another is for ssh. For more detail you can click VirtualBox CentOS static ip address.

Nginx basic http authentication

I want to add basic http authentication in my personal wiki. I don't want to write any code to implement this function. After searching on the Internet, I found Nginx can do this by adding configuration. basic http authentication is very simple and unsafe. It adds user name and password information in http header which encoded by base64.

IDEA find unused code

There are many unused code in my project. Whenever I see useless code, I will remove them. I think this is too inefficient. Fortunately, I found that IDEA can help me discover all the useless code in the project. In this blog I will show you how to use this feature.

Linux restart one network interface

Use following commands to restart on network interface. First you need to know that how many network cards on your machine.

Linux crontab example

The crontab command can be used to create timed tasks. Here are some simple examples.

Linux sed command example

sed is stream editor for filtering and transforming text. I will show you how to use it to cut text into another file. Let's say you have file(test.txt) like following.

fastjson JSONPath example

We can use fastjson to serialize and deserialize json. When the json structure is complicated, it will be more troublesome to handle. The json is like following.

Linux quickly create a big file

Use the following command to quickly create a large file. You can also specify the size of the file.

Java8 CompletableFuture runAsync allof example

In the previous blog Java8 CompletableFuture concurrence example we have learned how to use the method allof and supplyAsync of CompletableFuture to achieve concurrency. The problem is that the code is less readable when there are multiple CompletableFuture.

Java could not find or load main class

Error: Could not find or load main class For this problem, not only beginners of Java will encounter it. When developers with many years of work experience leave the IDE and want to run java manually, they may also be troubled by this problem. If you add package in your class then you need put it in the same directory.

Java stack trace disappear

I recently found a lot of exceptions without stack information when I looked at the logs. There is only one exception name in the log, and there is no complete stack information. I know the reason after google. To improve efficiency, the JVM hides duplicate stack information. More information can be found here

Java get local address example

I recently need to get a local ip when doing a feature. The following code perfectly implements this function. It’s very simple, just a few lines of code.

vim recording and execution macro

Using macros to perform repetitive operations is a very efficient way. In this page I will show you how to use it.

Spring Boot filter WebFilter annotation example

There is an embedded tomcat in Spring Boot. We can not edit web.xml to add a filter. In this page I will show you how to add filter in Spring Boot without web.xml. I use WebFilter annotation to add filter. After adding this annotation you have to add ServletComponentScan annotation to make Spring Boot find this filter.