Chinaunix首页 | 论坛 | 博客
  • 博客访问: 36467
  • 博文数量: 30
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 310
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-14 22:37
个人简介

------------

文章分类

全部博文(30)

分类: LINUX

2024-08-17 15:14:45

  • VIM
search/replace on selected/visual area/test
'<,'>s/\%V\ /\,0x/g
:version        # show misc info
:scriptnames    # show init scripts loaded


#Insert sequence
g/$/s//\=line('.')
g/^/s//\=line('.')
g/wqc/s//\=line('.')
g/wqc/s//\=line('.')-14/


set foldmethod=syntax
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=2
set foldcolumn=4

  • Screen

  1. #quit screen and terminate all session in it
  2. screen -X -S screen_name quit

  • AWK
  1. #remove dup without sort:
  2. awk '!a[$0]++' file
  • CMAKE
  1. #cmake compile_commands.json
  2. -DCMAKE_EXPORT_COMPILE_COMMANDS=True

  • Bash
  1. #check if bash script is sourced
  2. (return 0 2>/dev/null) && sourced=1 || sourced=0
  3. #Colors: https://www.cnblogs.com/unclemac/p/12783387.html


renice {
    #!/bin/sh


    if [[ x$1 = x--wrap ]]; then
      echo "my pid: $$"
      echo "params: $@"
      shift
      renice -n -20 -p $$
      exe=$(realpath $0)
      exec $exe $@
    fi


    echo "my pid x: $$"
    echo "params: $@"
}
  • Git

  1. git push origin --delete BranchName
  2. git push origin feature-branch:feature-branch
  3. git clone -b --single-branch

  4. # disable core.compression
  5. git config --global core.compression 0
  6. # clone only head
  7. git clone --depth 1 url
  8. # fetch all
  9. git fetch --unshallow
  10. # check with pull
  11. git pull --all


fix 'unable to update local ref' {
    git gc --prune=now
    git pull
    git remote prune origin
}


git show-branch --merge-base
git merge-base branch2 branch3


  • WSL when VPN
  1. #
  2. wsl network when vpn {
        #ref: https://blog.csdn.net/whuisland/article/details/125026163
        #ref:


        set metrics by admin@powershell {
            Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000
            Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1
        }


        ##The InterfaceMetric is a value associated with each adapter that determines the order of those adapters. This allows windows to determine which adapter to prefer over another one.


        ##By setting the interface metric of the Cisco adapter to 4000 and the metric of the WSL adapter to one, we allow the traffic from WSL to flow through the Cisco adapter. To be honest I do not exactly understand why this works but it does.


        get_anyconnect_dns() {
            local DNS_L=""
            local L=""
            local flg=0
            while read L; do
                if [[ flg -eq 0 ]]; then
                    if [[ x"$L" =~ x.*AnyConnect.*Adapter.* ]]; then
                        flg=1
                    fi
                    continue
                fi


                if [[ flg -eq 1 ]]; then
                    if [[ x"$L" =~ x.*DNS[[:space:]]+Server.*:[[:space:]]*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).* ]]; then
                        flg=2
                        DNS_L=${BASH_REMATCH[1]}
                    fi
                    continue
                fi


                if [[ flg -eq 2 ]]; then
                    if [[ x"$L" =~ ^x[[:space:]]*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).* ]]; then
                        DNS_L="$DNS_L ${BASH_REMATCH[1]}"
                    fi
                    break
                fi


            done


            echo $DNS_L
        }


        {
            echo '[network]'
            echo 'generateResolvConf = false'
        } > /etc/wsl.conf


        for d in $(/mnt/c/Windows/system32//ipconfig.exe /all |tr -d '\r' |get_anyconnect_dns); do
            echo "nameserver $d"
        done > /etc/resolv.conf


    }

  • ffmpeg
  1. #
  2. ffmpeg {
        for f in *.png; do
            ##apng -> gif
            ffmpeg -i $f -f apng $f.gif


            ##scale to 0.5 and reserve transparency
            ffmpeg -i $f.gif -filter_complex \
            "[0:v] scale=iw/2:ih/2:flags=neighbor,split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse" ${f}2.gif
        done


        ffmpeg -i $f -vf "scale=iw/2:ih/2" ${f/.gif/}2.gif


  3.     #compress
  4.     ffmpeg -y -i 2_input.mp4 -c:a copy -c:v libx264 -profile:v high -r 30 -crf 30 -b:v 200k -s 1920x1080 -movflags +faststart 2_output.mp4 -hwaccel cuvid -threads 4
  5.     
  6.     #embed subtitle    
        ffmpeg.exe -i C:\Users\qingc\Desktop\菜根谭.mp4 -i C:\Users\qingc\Desktop\ 菜根谭.vtt -c:s mov_text -c:v copy -c:a copy cai-gen-tan.mp4
  7. }

        学者以多方丧生
        大道以歧路亡羊
        佛者觉,菩萨者识
        做佛容易,做菩萨难
        根本智易得,差别智难求
        离一切诸相,即名诸佛
        能施一切法,名诸菩萨






阅读(25) | 评论(0) | 转发(0) |
0

上一篇:ftp get tree

下一篇:没有了

给主人留下些什么吧!~~