Convert jks to key file for web server

Cli

Run

1
2
3
4
5
6
7
8
# 1. Convert .jks to .p12 (need password)
keytool -importkeystore -srckeystore your-file.jks -destkeystore new-output.p12 -deststoretype PKCS12

# 2. Extract .pem from .p12 (need password)
openssl pkcs12 -nokeys -in new-output.p12 -out new-output.pem

# 3. Extract unencrypted .key from .p12 (need password)
openssl pkcs12 -nocerts -nodes -in new-output.p12 -out final-output.key

Reference

https://gist.github.com/paulosalgado/d12b069498ac6c8ed0821a066d68605e


Create your DNS server on docker

Docker

Instatllation

1
2
# assume docker is installed already
docker pull sameersbn/bind

Run

1
2
3
4
docker run --name bind -d \
--publish 53:53/tcp --publish 53:53/udp --publish 10000:10000/tcp \
--volume ./bind:/data \
sameersbn/bind

Add new domain and A record

  1. Open your browser access https://localhost:10000 (Webmin) > Servers > BIND DNS Server.
  2. Create master zone
  3. Edit Records File
  4. Click right top corner button to Apply configuration

Test

Dig

Reference

https://github.com/sameersbn/docker-bind
https://hub.docker.com/r/sameersbn/bind



Javascript bundler webpack

Web

Installation

1
2
3
# webpack@4.1.1
npm init -y
npm install --save-dev webpack

Basic Usage

1
2
# compile to bundle.js
npx webpack src/index.js --output dist/bundle.js

Integrate with npm project

1
2
3
4
5
6
7
8
9
10
11
vim package.json
{
...
"scripts": {
"build": "webpack"
},
...
}


npm run build

Custom config - webpack.config.js

1
2
3
4
5
6
7
8
9
const path = require('path');

module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
}
};

Reference

https://webpack.js.org/guides/getting-started/


Linux sed

Cli

Basic usage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# print first 30 lines
sed 1,30d log.log

# delete first 30 lines
sed -e 1,30d log.log

# delete 17th lines
sed -e 17d log.log

# delete last 20 lines
sed -e '10,$d' log.log


# delete last 20 lines and backup file that named 'log.log.bak'
sed -e '10,$d' -i '.bak' log.log


# replace StdOut
sed -e 's/__variable__/__replaced__/g' file.txt

# replace in file
sed -e's/__variable__/__replaced__/g' -i '' file.txt

Reference

https://linux.die.net/man/1/sed






MacOS Multiple User Run Brew Issue

Cli

Error message

1
2
3
4
Error: Can't create update lock in /usr/local/var/homebrew/locks!
Fix permissions by running:
sudo chown -R $(whoami) /usr/local/var/homebrew
Error: Permission denied @ rb_sysopen - /usr/local/var/homebrew/locks/YOUR_PACKAGE.formula.lock

Solution

1
2
sudo chown -R $(whoami) /usr/local/Cellar/
sudo chown -R $(whoami) /usr/local/var/homebrew

Error message 2

1
Error: Permission denied - /usr/local/opt/jpeg

Solution

1
2
sudo chown -R "$USER":admin /usr/local
sudo chown -R "$USER":admin /Library/Caches/Homebrew