Skip to content

Instantly share code, notes, and snippets.

View LeeiFrankJaw's full-sized avatar

Lei Zhao LeeiFrankJaw

View GitHub Profile
@LeeiFrankJaw
LeeiFrankJaw / hocr2djvused.py
Last active June 19, 2023 03:06 — forked from char101/hocr2djvused.py
Converter from tesseract hocr to djvused commands (python 3, tested with tesseract 5.0.0 alpha)
import os
import re
import sys
from io import StringIO
from lxml import etree
SPECIAL_CHARACTERS = {
7: 'a', # BELL
8: 'b', # BS
@LeeiFrankJaw
LeeiFrankJaw / compress.sh
Created June 19, 2023 02:58
Compress Apple HEVC HDR Videos
for i in *.mp4; do
ffmpeg -i "$i" -c:v libx265 -crf 30 -c:a copy -color_primaries bt2020 -colorspace bt2020nc -color_trc arib-std-b67 -map_metadata 0 -max_muxing_queue_size 1024 -n Compressed/${i::-4}.mp4;
done
@LeeiFrankJaw
LeeiFrankJaw / bionic.sh
Last active August 25, 2021 21:38
Install Clang on Ubuuntu LTS
#!/bin/bash
# Install Clang 8 on Ubuuntu 18.04.2 LTS
# Turn on errexit.
set -e
# You do not need to add new repository to the source list since the
# llvm toolchain now can be found on the bionic bionic-updates
# universe repositories.
@LeeiFrankJaw
LeeiFrankJaw / get-ocserv.sh
Created July 9, 2020 21:00
Install ocserv 0.11.9 from source under Debian 10.4
git clone https://gitlab.com/openconnect/ocserv.git
cd ocserv/
apt install autoconf pkg-config libev-dev libwrap0-dev libpam0g-dev liblz4-dev libseccomp-dev libreadline-dev libnl-route-3-dev libkrb5-dev liboath-dev libradcli-dev libsystemd-dev protobuf-c-compiler gperf libprotobuf-c-dev libtalloc-dev libhttp-parser-dev libpcl1-dev libopts25-dev liblockfile-bin nuttcp lcov libuid-wrapper libpam-wrapper libnss-wrapper libsocket-wrapper gss-ntlmssp libpam-oath autogen
sh autogen.sh
./configure
make
make install
@LeeiFrankJaw
LeeiFrankJaw / get-craftcms.sh
Created July 2, 2020 15:32
Install Craft CMS on Ubuntu 18.04 LTS
# With Apache
# apt install php composer
# Without Apache
apt install php-fpm composer
# Install dependencies
apt install php-curl php-xml php-mbstring php-imagick php-mysql
# With PostgreSQL
@LeeiFrankJaw
LeeiFrankJaw / get-trojan.sh
Last active June 2, 2020 04:14
Install trojan from source under Ubuntu 18.04
git clone 'git@github.com:trojan-gfw/trojan.git'
sudo apt install cmake default-libmysqlclient-dev libboost-program-options-dev libboost-system-dev libssl-dev
# Oops, the boost version shipped with Ubuntu 18.04 is too old for trojan.
wget 'https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.bz2'
tar xvf boost_1_72_0.tar.bz2 -C /usr/local/
cd trojan/
git checkout v1.14.1
cmake -D CMAKE_INSTALL_PREFIX:PATH=/usr/local -D BOOST_ROOT:PATH=/usr/local/boost_1_72_0/ .
@LeeiFrankJaw
LeeiFrankJaw / get-v2ray.sh
Created March 10, 2020 15:55
Install v2ray on Ubuntu 18.04 from source
# Refer to https://www.v2ray.com/developer/intro/compile.html
@LeeiFrankJaw
LeeiFrankJaw / combine.sh
Last active March 4, 2020 20:03
Convert HLS stream from m3u8 to MP4
# Convert HLS stream from m3u8 to MP4
gst-launch-1.0 -v mp4mux name=mux ! filesink location=output.mp4 filesrc location=GOPR7003.m3u8 ! hlsdemux ! decodebin name=decoder decoder. ! queue ! videoconvert ! x264enc ! mux. decoder. ! queue ! audioconvert ! voaacenc ! mux.
# Combine normal TS files into MP4
cvlc -v segment-*.ts \
--sout='#gather:file{dst=output.mp4}' \
--sout-keep \
@LeeiFrankJaw
LeeiFrankJaw / get-git.sh
Last active February 23, 2020 13:37
Install git from source under Ubuntu 18.04
sudo apt install git
git clone git@github.com:git/git.git
cd git/
git checkout v2.15.1
sudo apt install libcurl4-openssl-dev
make configure
./configure --prefix=/usr/local # --without-tcltk
make all man
# make NO_GETTEXT=yes all man
make install install-man
@LeeiFrankJaw
LeeiFrankJaw / get-stubby.sh
Last active January 6, 2020 10:36
Install Stubby on Ubuntu 16.04 LTS
# In fact, getdns repo has stubby as a submodule and there is no need
# to clone a separate repo.
git clone git@github.com:getdnsapi/stubby.git
cd stubby/
# please refer to
# [get-getdns.sh](https://gist.github.com/LeeiFrankJaw/0068ea73267c165ee4bef091fc3822f2)
# for how to install the getdns dependency.
sudo apt install libyaml-dev
autoreconf -vfi
./configure