Skip to content

Instantly share code, notes, and snippets.

@felixmon
felixmon / auto_update.sh
Created February 3, 2019 16:37 — forked from quericy/auto_update.sh
Auto update tracker list of aria2 config in Mac OSX
#!/bin/bash
DAEMON=/usr/local/Cellar/aria2/1.31.0/bin/aria2c
PID_NAME=aria2c
PID=$(ps ux | awk '/aria2c/ && !/awk/ {print $2}')
CONFIG_PATH='/path/to/aria2.conf'
TRACKER_URL='https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all_ip.txt'
#####
wget https://github.com/xtaci/kcptun/releases/download/v20170525/kcptun-linux-amd64-20170525.tar.gz
tar xvf kcptun-linux-amd64-20170525.tar.gz
sudo mv server_linux_amd64 /usr/local/bin/kcptun_server
sudo mv client_linux_amd64 /usr/local/bin/kcptun_client
sudo mkdir -p /etc/kcptun
sudo bash -c "cat <<EOT > /etc/kcptun/server_conf.json
{
\"listen\": \":4321\",
\"target\": \"127.0.0.1:8421\",
@felixmon
felixmon / compress-pdf-with-gs.md
Created March 11, 2019 09:28 — forked from guifromrio/compress-pdf-with-gs.md
Compress PDF files with ghostscript

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
@felixmon
felixmon / read-docx.py
Created April 27, 2019 08:16
Read and count words and Chinese words in Docx
# 读取已有的word文档
# 参考1:https://www.jianshu.com/p/94ac13f6633e
# 参考2: https://python-docx.readthedocs.io/en/latest/api/text.html#paragraph-objects
# 参考3: https://www.jianshu.com/p/867fe84d8440
import sys
import re
from docx import Document
@felixmon
felixmon / ls-full.sh
Last active September 17, 2019 15:47
LS full/absolute path of a file
# https://www.rapidtables.com/code/linux/ls/ls-full-path.html
$ ls -d $PWD/*
$ ls -d $PWD/*.docx
# Get the sum number
$ ls -d $PWD/*.docx | wc -l
@felixmon
felixmon / read-docx-output.py
Last active April 27, 2019 11:11
Read docx from shell directory and count the words
# 读取已有的word文档
# 参考1:https://www.jianshu.com/p/94ac13f6633e
# 参考2: https://python-docx.readthedocs.io/en/latest/api/text.html#paragraph-objects
# 参考3: https://www.jianshu.com/p/867fe84d8440
import sys
import re
from docx import Document
@felixmon
felixmon / read.sh
Created April 27, 2019 11:04
read.sh
#!/bin/bash
ls -d $PWD/*.docx >1.txt
python3 read-docx.py >2.txt
@felixmon
felixmon / wget.sh
Created May 9, 2019 02:33
How to Use Wget to Archive a Blogspot Blog
# http://www.dheinemann.com/2011/how-to-use-wget-to-archive-a-blogspot-blog/
wget -nc -w 1 -r --random-wait -k -l 2 -p -np -E -H --referer=http://nerds-central.blogspot.com -e robots=off --domains=nerds-central.blogspot.com,blogger.com,nerds-central.com,blogspot.com http://nerds-central.blogspot.com
@felixmon
felixmon / curl-sh.md
Last active May 31, 2019 04:31
Batch Download Images with Chrome Developer Tools

Batch Download Images with Chrome Developer Tools

  1. Enter Developer Mode
  2. Right click on randome image and choose "copy all as cURL"
  3. Paste in any text editor
  4. Replace all

curl '

with