Posts

Encode and Decode on FreeBSD

Base64  Encode % echo -n "Hello World!" | base64 -e SGVsbG8gV29ybGQh -n   Do NOT print the trailing newline character.  |  The output(stdout) text of  echo -n "Hello World!" is passed to base64 -e directly as input(stdin).  -e   Encode  Decode % echo "SGVsbG8gV29ybGQh" | base64 -d Hello World! -d Decode   URI Encode % echo -n "http://google.com/index.php?id=1'" | python3 -c "import sys;import urllib.parse; print(urllib.parse.quote(sys.stdin.read()));" http%3A//google.com/index.php%3Fid%3D1%27 Decode % echo "http%3A//google.com/index.php%3Fid%3D1%27" | unvis -eh   http://google.com/index.php?id=1'   -e       Don't decode  \  escaped sequences.   -h       Decode using the URI encoding from RFC 1808.  (VIS_HTTP1808) Hexadecimal % echo -n "Hello" | od -A n -t x1 48  65  6c  6c  6f The echo program will provide the string to the next comma...

Convert Chinese to Unicode or reverse with native2ascii or uni2ascii on FreeBSD

  Use  uni2ascii Install uni2ascii  # pkg install uni2ascii    Converting Chinese to Unicode: % uni2ascii -a U chinese.txt  > unicode.txt   Converting Unicode to Chinese: % ascii2uni -a U unicode.txt  > chinese.txt   Use native2ascii Converting Chinese  to Unicode: % native2ascii -encoding GBK  chinese.txt unicode.txt Converting Unicode to Chinese: % native2ascii -reverse -encoding GBK unicode.txt chinese.txt native2ascii is a tool of JDK, you need to install JDK first if you want to use native2ascii.  

Set ports and portsnap in China for FreeBSD

 1.Install ports: # portsnap fetch -s portsnap.cn.freebsd.org 2. Edit /etc/portsnap.conf SERVERNAME=portsnap.tw.FreeBSD.org 3. Download portsnap # portsnap fetch extract Update # portsnap update 4. Edit file /etc/make.conf and add configuration as follows: FETCH_CMD=axel -n 30 -a # Open 30 threads to download DISABLE_SIZE=yes MASTER_SID_OVERRIDE?=http://mirrors.163.com/freebsd/ports/distfiles/

How to log in when Slim does not allow you to log in

I install software and didn't configure correctly. Then Slim won't let me login even I enter the valid username and password. So what should I do: Try press  Ctrl  + Alt + F1 to get vt0 shell login OR Try press Ctrl + Alt + F4 to quit slim, and you will get vt0 shell login too.

Markdown to PDF using pandoc on FreeBSD

Install pandoc and wkhtmltopdf: # pkg install pandoc # pkg install wkhtmltopdf   Convert markdown to pdf: $ pandoc --pdf-engine=wkhtmltopdf  -o test.pdf test.md

How to unzip multiple zip files?

Build a shell script and run it. The content of the shell script is as follows:  #!/bin/sh for z in *.zip; do unzip "$z"; done  

How to Dockerizing LEMP Stack with Docker-Compose

Image
LEMP: Linux, Nginx, PHP, MySQL Nginx Create docker-compose.yml in a directory(lemp) is as follows: version: '3.8' services:   nginx:     image: nginx:1.20.2     ports:       - 80:80 Let's test this out .   $ docker-compose up -d  The -d option indicates that run the containers in the background. It might take a little while as the Nginx image will first be downloaded from Docker Hub. When it is done, open localhost in your browser, which should display Nginx's welcome page: Welcome to nginx! If you see this page, the nginx web server is successfully installed and working. Further configuration is required. For online documentation and support please refer to nginx.org . Commercial support is available at nginx.com . Thank you for using nginx. To stop the container, simply run: $ docker-compose stop  PHP Replace the content of docker-compose.yml with this one: version: '3.8' services:   nginx:  ...