Prevent MACBook Sleep

Some 3rd parties can prevent MacBook from sleep. Why does Apple always let MacBook/Air go to sleep when lid is closed and ignore user’s settings?

Read More

Fix Docker Exception - Credentials store error on MacOS

When I run docker-compose command on Mac OS, I hit an error as below:

docker.errors.DockerException: Credentials store error: StoreError('Credentials store docker-credential-osxkeychain exited with "User interaction is not allowed.".',)
Failed to execute script docker-compose
Read More

Nginx Proxy Server Configuration

Example 1:

server {
    listen 80;
    index index.html index.htm index.nginx-debian.html index.php;
    server_name aaa.bbb.ccc.ddd;
    location ~/app2(.*)$ {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_pass http://aaa.bbb.ccc.ddd:8001$1;
    }
}
Read More

Why String is immutable in Java

  1. String values are stored in String constant pool. It can be accessed by multiple client.
  2. It is used by the class loading mechanism. For security reason, it should not be changed to other value.
  3. Immutable string allow to cache its hashcode. It makes hashmap/hashtable very fast since they don’t calculate hashcode everytime.
  4. String instance is thread-safe in Java.
Read More