Skip to content

Latest commit

 

History

History
348 lines (201 loc) · 8.02 KB

workingTips.md

File metadata and controls

348 lines (201 loc) · 8.02 KB

...menustart

...menuend

工作 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

youtube-dl -c --write-auto-sub --sub-lang=en --ignore-errors -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' '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
  • -c means resume downloading
  • --ignore-errors 忽略下载错误,比如 private vidoe

re-download youtube auto sub

youtube-dl --write-auto-sub --skip-download --sub-lang=en  ...

youtube-dl download mp3 audio only

youtube-dl -x --audio-format mp3  'your-url'

Or list all support format, and pick one audio-only format

$ youtube-dl -F  'your-url'
format code  extension  resolution note
249          webm       audio only tiny   53k , webm_dash container, opus @ 53k (48000Hz), 1.10MiB
250          webm       audio only tiny   72k , webm_dash container, opus @ 72k (48000Hz), 1.49MiB
140          m4a        audio only tiny  127k , m4a_dash container, mp4a.40.2@127k (44100Hz), 2.60MiB
251          webm       audio only tiny  140k , webm_dash container, opus @140k (48000Hz), 2.87MiB
278          webm       256x144    144p   97k , webm_dash container, vp9@  97k, 13fps, video only, 2.00MiB
160          mp4        256x144    144p  108k , mp4_dash container, avc1.42c00c@ 108k, 13fps, video only, 2.23Mi

$ youtube-dl -f 140  '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"

ab testing

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"

check wheter keep-alive is enabled by server

  • url -lv -k <url> <url> 2>&1 | grep "Re-using"
$ curl -lv -k https://xxx.com/ https://xxx.com/  2>&1 | grep  "Re-using"
* Re-using existing connection! (#0) with host xxx.com

change .pem password

mv config/private.pem config/private_old.pem

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

Python NTLM proxyserver

ntlm download

share-a-proxied-network on MacOSX

获取外网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

check port using

Linux:

netstat -tunlp | grep 8080

The closest equivalent you can get on macOS is:

netstat -p tcp -van | grep '^Proto\|LISTEN' | grep 8080

Or use lsof (list opened files)

sudo lsof -i:8080

NOTE: lsof just list files opened by current users, you need add sudo if you want to see all opened files.

Check process

ps -ef | grep tomcat
  • -e : all processes
  • -f : full