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 / 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-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 / get-trojan.sh
Last active June 2, 2020 04:14
Install trojan from source under Ubuntu 18.04
git clone '[email protected]: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 / 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 / install.sh
Last active November 3, 2018 10:36
Set up pagure on Trisquel 8
#!/bin/sh
# Please refer to the manual section from the site
# https://pagure.io/pagure
# python3-gdbm is not found in trisquel by default but preinstalled on
# ubuntu.
sudo apt install python3-dev python3-pip python3-venv python3-gdbm \
libgit2-dev redis-server libjpeg-dev libffi-dev
@LeeiFrankJaw
LeeiFrankJaw / README.md
Last active October 16, 2018 09:10
Set up Gitlab Development Kit on Trisquel 8

Set up Gitlab Development Kit on Trisquel 8

  • Login as non-root user.

  • Install ruby with required version (2.4.4 at the time I wrote this), the gitlab site recommends using a ruby version manager (such as RVM, rbenv,

@LeeiFrankJaw
LeeiFrankJaw / iPhone-mencoder.sh
Last active October 3, 2019 12:11
Make iPhone compatible video with mencoder
mencoder input -o output.mp4 \
-of lavf -lavfopts format=mp4 \
-ovc x264 -x264encopts bframes=0:global_header \
# -ss 5:00 -endpos 5:00 \
-oac lavc -lavcopts acodec=ac3
# NOTE: THE OPTION -ovc copy SIMPLY DOES NOT WORK AND MENCODER CANNOT
# USE LIBAVCODEC PROPERLY. DO NOT WASTE TIME ON MENCODER LEARN ffmpeg
# INSTEAD.