Posts

Showing posts from January, 2022

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 command. The -n flag tells echo to NOT generate a new line at the

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