Skip to content

Latest commit

 

History

History
363 lines (231 loc) · 8.7 KB

workingTips.md

File metadata and controls

363 lines (231 loc) · 8.7 KB

工作 working Tips

proxy setting

export _proxy=username:password@IP_or_DOMAIN:3128
export  http_proxy=http://$_proxy
export https_proxy=http://$_proxy


export  HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$https_proxy


#u3d proxy ?
export  HTTP_proxy=$http_proxy
export HTTPS_proxy=$https_proxy

# export NO_PROXY=localhost,localhost.,127.0.0.1,10.96.0.0/12,10.244.0.0/16,10.192.0.0/16
export NO_PROXY="localhost,127.0.0.*,10.96.0.0/12,10.244.0.0/16,10.192.0.0/16"
export no_proxy=$NO_PROXY

curl 对某些 url 不使用代理

curl -v --noproxy 127.0.0.1

pip 使用国内源

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ... 

pip upgrade all outdated package

pip list --outdated | cut -d' ' -f1 | xargs pip install --upgrade

FileMerge

opendiff file1 file2

or for entire directories

opendiff dir1 dir2

or

/Developer/Applications/FileMerge.app/Contents/MacOS/FileMerge -left “File1” -right "File2" -ancestor "File3" -merge "File4"

Get Proxy Info

chrome: chrome://net-internals/#proxy

lldb 调试 Segment Fault on MacOSX

  • 编译加上 +g 选项
  • ulimit -c unlimited
  • /cores/core.xxx 文件生成
  • lldb appname core.15667
  • 运行, crash后,输入 bt 打印跟踪堆栈

download youtube playlist : yt-dlp

  • install: deprecated !!!
    • brew install yt-dlp
  • best installation
    python3 -m pip install --force-reinstall https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz
    yt-dlp URL
yt-dlp --ignore-errors --rm-cache-dir -c --write-auto-sub --sub-lang=en   -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' --cookies-from-browser chrome 'https://www.youtube.com/playlist?list=PLKUel_nHsTQ1yX7tQxR_SQRdcOFyXfNAb'
  • 如果视频确定有 premade 字幕, 使用 --write-sub
  • ensure you add ' ' to url since some special character may appears in URL has a special meaning in bash
  • other useful options
    • -c means resume downloading
    • --ignore-errors 忽略下载错误,比如 private vidoe
    • --rm-cache-dir 避免403 错误
  • start from specific entry from a list, e.g. from 20
    • --playlist-start 20

re-download youtube auto sub

$ yt-dlp --write-auto-sub --skip-download --sub-lang=en  ...

yt-dlp download mp3 audio only

yt-dlp --ignore-errors --rm-cache-dir  -x --audio-format mp3  'your-url'

using ffmpeg to convert video to mp3 (未验证)

To encode a high quality MP3 from an AVI best use -q:a for variable bit rate:

ffmpeg -i sample.avi -q:a 0 -map a sample.mp3

-af 'volume=2'

-q:a for variable bit rate:

use ffmpeg select left audio channel and downgrade to mono

# ffmpeg -i input -map_channel 0.0.0 output
ffmpeg -i xxx.m4a -map_channel 0.0.0 output.mp3

use ffmpeg manipulate audio channel

https://trac.ffmpeg.org/wiki/AudioChannelManipulation

change audio volume

# low 50% volume of left audio channel
-af  "pan=stereo|c0=0.5*c0|c1=c1"

merge subtile to video

# mergeSubtile.sh

#!/bin/sh

set -e

INFILE=$1
SUBTITLES=$2

# if arguments are not passed, show usage and exit
if [ $# -ne 2 ]; then
    echo "Usage: $0 <inputfile> <subtitlefile>"
    exit 1
fi

echo $INFILE , $SUBTITLES

ffmpeg -i $SUBTITLES temp.ass && \
BITRATE=$(ffprobe -v error -select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 $INFILE) && \
ffmpeg -i $INFILE -vf ass=temp.ass -vcodec h264_videotoolbox -b:v $BITRATE -c:a copy output_burnedin.mp4

ab benchmark

ab -r -k -s 120 -n 100000 -c 1500  <url>
  • -s timeout, default is 30sec

  • -r Don't exit on socket receive errors.

  • -k Use HTTP KeepAlive feature

    • caution: not work with nodejs. it is a bug of ab , since ab is a http 1.0 client. You should add extra -H "TE: chunked"
  • Post Example

    ab -r -k -s 120 -n 100000 -c 1500 \
        -H 'accept: application/json' -H 'token: asdf' \
        -T application/json -p body.json  \
        'http://localhost:3000/user'
    • the 2nd line is Arbitrary header
    • the 3rd line, -p specify the post file, -T specify content-type

check wheter keep-alive is enabled by server

curl -I <url>

change .pem password

mv config/private.pem config/private_old.pem

openssl rsa -in config/private_old.pem -out config/private.pem -des3

OR

ssh-keygen -p -m PEM -f <path-to-private-key>

tcpdump on OSX

tcpdump on OSX

获取外网ip

curl ifconfig.co

MacOSX add Printer in Windows LAN

  • Advanced
    • Type: Windows printer via spoolss
    • URL: smb://<printer's IP or domain name>/<printer name>

Bash , exit or ret ?

if you execute your bash script with source , exit command will stop the user shell.

to prevent it

[[ "$0" == "$BASH_SOURCE" ]] && ret=exit || ret=return
...
$ret 1

FTP Server

pip3 install pyftpdlib
python3 -m pyftpdlib -w -p 80

[MacOSX] move large files out of system volumn

DockerRaw  ->  ~/Library/Containers/com.docker.docker/Data/vms/0/data
UnityLogs  ->  ~/Library/Logs/Unity

[MacOSX] monitor files changes under current folder

brew install watch

watch -n 1 -d find .

# to skie .git folder
watch -n 1 -d find . -path ./.git  -prune -o -print

[MacOSX] chrome gpu acceleration not work

  1. delete chrome app
  2. delete ~/Library/Application Support/Google/Chrome
  3. reinstall chrome app

check chrome gpu acceleration status

chrome://gpu