• file-split.sh 文件切割、合并
    netnr 2021-11-24 7
    split -l 100000 -d access.log part/access_ --verbose # 按行切割
    split -b 100m access.log -d part/access_ --verbose # 按字节大小切割
    
    cat part/access_* > access.log  # 合并
    cat part.mp4 >> main.mp4        # 追加 part.mp4 到 main.mp4 末尾
    bash -c "cat part.mp4 >> main.mp4" >> /dev/null # 静默执行
  • fr-remove-watermark.js fr remove watermark
    netnr 2021-10-19 5
    let wm = {
        startDate: Date.now(),
        remove: () => {
            try {
                document.querySelectorAll('.copyrightInfo-div').forEach(c => {
                    c.style.transform = "translateY(9999px)"
                })
    
                document.querySelectorAll('div').forEach(node => {
                    if (node.innerHTML.trim().startsWith("正在试用功能——")) {
  • backup_mysql.sh MySQL 备份脚本
    netnr 2021-09-29 313
    # 配置参数(开始)===
    
    ymd=$(date +%Y%m%d)
    echo "日期:$ymd"
    echo
    keepday=5
    echo "保留最近天数:$keepday"
    echo
    dirsync="/package/autosync/sync"
    echo "同步目录:$dirsync"
  • backup_oracle.sh Oracle 备份脚本
    netnr 2021-09-29 335
    # 配置参数(开始)===
    
    ymd=$(date +%Y%m%d)
    echo "日期:$ymd"
    echo
    keepday=5
    echo "保留最近天数:$keepday"
    echo
    dirsync=/package/autosync/sync
    echo "同步目录:$dirsync"
  • git-clear-history.sh git 彻底清理历史,仅保留最新一份,慎重操作
    netnr 2021-08-28 338
    cat .git/config  # note <github-uri>
    rm -rf .git
    git init
    git branch -M main # 修改分支,可设置默认分支为 main:  git config --global init.defaultBranch main
    git add .
    git commit -m "Initial commit"
    git remote add origin git@github.com:netnr/proxy.git # 改成自己对应的仓库
    git push -u --force origin main
  • git-ssh.sh git clone ssh-key
    netnr 2021-08-15 339
    # 设置用户名、邮箱
    git config --global user.name "netnr"
    git config --global user.email "netnr@netnr.com"
    
    # 查看
    cd ~/.ssh && ls
    
    # 生成密钥(ED25519 更小更快更安全,需要 OpenSSH 6.5 以上,推荐),密钥均为 256 位
    ssh-keygen -t ed25519 -C "netnr"
  • openssl-ssl.sh OpenSSL 生成自签名 SSL 证书
    netnr 2021-08-10 328
    # 生成私钥,4 位以上的密码
    # genra	生成RSA私钥;-des3	des3算法;-out server.key 生成的私钥文件名;2048 私钥长度
    openssl genrsa -des3 -out server.pass.key 2048
    
    # 去除密码
    openssl rsa -in server.pass.key -out server.key
    
    # 生成 CSR (证书签名请求)
    # req 生成证书签名请求;-new 新生成;-key 私钥文件;-out 生成的CSR文件;-subj 生成CSR证书的参数
    openssl req -new -key server.key -out server.csr -subj "/C=CN/ST=Beijing/L=Beijing/O=dev/OU=dev/CN=dev.cn"
  • install-dotnet.sh dotnet 安装脚本
    netnr 2021-08-09 343
    # 脚本安装
    
    wget https://dot.net/v1/dotnet-install.ps1 # PowerShell (Windows)
    
    wget https://dot.net/v1/dotnet-install.sh # Bash (Linux/macOS)
    
    ./dotnet-install.sh # 默认安装 LTS
    ./dotnet-install.sh -c Current # 当前最新
    ./dotnet-install.sh -c 5.0 # 指定版本
  • install-azuresqledge.sh Deploy Azure SQL Edge with Docker
    netnr 2021-08-04 337
    docker pull mcr.microsoft.com/azure-sql-edge:latest # 下载镜像
    
    # 开发版
    docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 --name sqledge -d mcr.microsoft.com/azure-sql-edge
    # 高级版
    docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=yourStrong(!)Password' -e 'MSSQL_PID=Premium' -p 1433:1433 --name sqledge -d mcr.microsoft.com/azure-sql-edge
    
    # 配置
    https://learn.microsoft.com/en-us/azure/azure-sql-edge/configure
  • iptables.sh iptables 规则配置
    netnr 2021-06-23 311
    # 安装
    yum install iptables
    yum update iptables 
    yum install iptables-services
    service iptables status
    
    iptables -L # 列表
    iptables -nL --line
    
    iptables -A INPUT -p tcp --dport ssh -j ACCEPT # 开启 SSH
  • ufw.sh Ubuntu ufw 防火墙
    netnr 2021-06-22 412
    apt install ufw # 安装
    
    ufw disable # 禁用
    
    apt-get remove ufw # 卸载
    apt-get purge ufw # 清除
    
    ufw status # 查看
    
    ufw enable # 启用
  • apache.md Apache 命令和配置
    netnr 2021-06-08 4
    ### Apache 安装及使用
    
    https://blog.51cto.com/itwish/2160492
    
    ### 反向代理 https
    
    https://docs.rapidminer.com/latest/legacy/configure/security/reverse-proxy.html
    
    ```
    <VirtualHost *:80>
  • install-PostgreSQL.sh Linux 安装 PostgreSQL
    netnr 2021-06-02 324
    # docker 安装 12.8
    docker run --restart=always --name=pg \
        -e POSTGRES_PASSWORD=<MySecretPassword> \
        -e PGDATA=/var/lib/postgresql/data/pgdata \
        -v /package/pgdb:/var/lib/postgresql/data \
        -p 5432:5432 -d postgres:12.8
        
    # help
    https://hub.docker.com/_/postgres
  • browserify.sh Browserify 捆绑打包使用 require 代码,就像在 Node 中使用
    netnr 2021-05-11 4
    npm install -g browserify   # 安装      yarn global add browserify
    
    browserify index.js -o bundle.js    # 捆绑打包
    
    # help
    http://browserify.org/
  • dotnet-publish.sh dotnet publish 命令
    netnr 2021-04-07 347
    dotnet publish  # 跨平台环境依赖版
    dotnet publish ~/projects/app1/app1.csproj  # 发布指定项目
    dotnet publish -c Release -r linux-x64  # 发布指定平台 linux-64 独立版
    dotnet publish -c Release -r win-x64 --self-contained false # 发布指定平台环境依赖版
    
    # 参数说明
    # -p:PublishReadyToRun=true         缩短应用程序的启动时间,但代价是增加应用程序的大小
    # -p:PublishSingleFile=true         打包到特定于平台的单个文件可执行文件中
    # -p:PublishTrimmed=true            剪裁未使用的库以减小应用的部署大小
    # --self-contained [true|false]     运行时随应用程序一同发布,默认为 true
  • pd-case-conversion.vbs PowerDesigner 表结构和字段大小写转换
    netnr 2021-01-11 4
    Option Explicit  
    ValidationMode = True  
    InteractiveMode = im_Batch  
    Dim mdl ' 当前模型  
    ' 获取当前模型  
    Set mdl = ActiveModel  
    If (mdl Is Nothing) Then  
       MsgBox "没有打开一个模型" 
    ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then  
       MsgBox "当前模型不是一个PDM"
  • crontab.sh Linux 定时任务 crontab
    netnr 2021-01-06 312
    crontab -l # 列表
    crontab -e # 编辑
    
    vi /etc/crontab # 编辑
    crontab /etc/crontab # 生效
    
    # 注意末尾保留一空行
    
    crontab -h # 帮助
  • vscode-remote-ssh.sh vscode remote 密钥连接
    netnr 2020-12-17 323
    # 生成密钥
    ssh-keygen -t ed25519 -C "netnr"
    
    # 服务器端配置公钥,拷贝客户端公钥 id_ed25519.pub 内容写入服务器
    vi ~/.ssh/authorized_keys
    
    # 其它配置(以上配置完成已经可以了)
    # 文件权限要求
    chmod 600 authorized_keys
    chmod 700 ~/.ssh
  • profile.sh 环境变量
    netnr 2020-10-28 329
    # 全局变量
    vi /etc/profile # 编辑
    PATH=$PATH:/package/app/node/bin
    export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL # 在该行前面加
    source /etc/profile # 生效
    
    # 局部变量
    vi ~/.bash_profile # 编辑
    alias nodejs=/package/app/node/bin
    source ~/.bash_profile # 生效
  • install-mysql-win.md Windows 系统安装 MySQL
    netnr 2020-10-21 4
    - 下载地址:https://dev.mysql.com/downloads/mysql
    - 解压包,放置一个目录下(不含中文或空格的路径)
    - 在 **bin** 同级目录创建 **my.ini** 文件和 **data** 文件夹
    - my.ini 文件内容
    ```
    [mysqld]
    # 设置 3306 端口
    port=3306
    # 设置 mysql 的安装目录
    basedir=E:\\mysql-8.0.22-winx64
  • oracle_expdp_impdp.sh Oracle 数据库导入导出
    netnr 2020-10-14 327
    # 按用户导出
    expdp system/oracle@orcl schemas=$user dumpfile=$dbname.dmp logfile=$dbname.log directory=DATA_PUMP_DIR
    # 按表名导出
    expdp system/oracle@orcl tables=($TABLE1,$TABLE2) dumpfile=$dbname.dmp logfile=$dbname.log directory=DATA_PUMP_DIR
    # 按用户导入(表覆盖)
    impdp system/oracle@orcl schemas=$user dumpfile=$dbname.dmp logfile=$dbname.log directory=DATA_PUMP_DIR table_exists_action=REPLACE
    # 按用户导入(转换空间)
    impdp system/oracle@orcl schemas=$user TRANSFORM=segment_attributes:n dumpfile=$dbname.dmp logfile=$dbname.log directory=DATA_PUMP_DIR table_exists_action=REPLACE
    
    # 导入导出包权限设置
  • netsh-http.bat netsh命令监听IP(可实现IIS、nginx共用80端口)
    netnr 2020-09-18 341
    :: 显示监听的IP列表
    netsh http show iplisten
    
    :: 添加监听IP
    netsh http add iplisten ipaddress=127.0.0.1
    
    :: 删除监听IP
    netsh http delete iplisten 127.0.0.1
  • aspnet_regiis.bat Framework注册IIS
    netnr 2020-09-18 313
    @echo off
    title .NET Framework Register IIS
    color 5f
    
    echo.---------- .NET Framework v2 Register IIS
    echo.
    
    %windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
    %windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -i
  • install-iis.bat 一键安装IIS
    netnr 2020-09-18 320
    @echo off
    title Install IIS
    color 5f
    
    echo.---------- Install IIS about 3-5 Minutes
    echo.
    
    dism /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment	/FeatureName:IIS-ASP	/FeatureName:IIS-ASPNET    /FeatureName:IIS-BasicAuthentication    /FeatureName:IIS-CGI    /FeatureName:IIS-ClientCertificateMappingAuthentication    /FeatureName:IIS-CommonHttpFeatures    /FeatureName:IIS-CustomLogging    /FeatureName:IIS-DefaultDocument    /FeatureName:IIS-DigestAuthentication   /FeatureName:IIS-DirectoryBrowsing   /FeatureName:IIS-FTPExtensibility   /FeatureName:IIS-FTPServer   /FeatureName:IIS-FTPSvc   /FeatureName:IIS-HealthAndDiagnostics   /FeatureName:IIS-HostableWebCore   /FeatureName:IIS-HttpCompressionDynamic   /FeatureName:IIS-HttpCompressionStatic   /FeatureName:IIS-HttpErrors   /FeatureName:IIS-HttpLogging   /FeatureName:IIS-HttpRedirect   /FeatureName:IIS-HttpTracing   /FeatureName:IIS-IIS6ManagementCompatibility   /FeatureName:IIS-IISCertificateMappingAuthentication   /FeatureName:IIS-IPSecurity   /FeatureName:IIS-ISAPIExtensions   /FeatureName:IIS-ISAPIFilter   /FeatureName:IIS-LegacyScripts   /FeatureName:IIS-LegacySnapIn   /FeatureName:IIS-LoggingLibraries   /FeatureName:IIS-ManagementConsole   /FeatureName:IIS-ManagementScriptingTools   /FeatureName:IIS-ManagementService   /FeatureName:IIS-Metabase   /FeatureName:IIS-NetFxExtensibility   /FeatureName:IIS-ODBCLogging   /FeatureName:IIS-Performance   /FeatureName:IIS-RequestFiltering   /FeatureName:IIS-RequestMonitor   /FeatureName:IIS-Security   /FeatureName:IIS-ServerSideIncludes   /FeatureName:IIS-StaticContent   /FeatureName:IIS-URLAuthorization   /FeatureName:IIS-WebDAV   /FeatureName:IIS-WebServer   /FeatureName:IIS-WebServerManagementTools   /FeatureName:IIS-WebServerRole   /FeatureName:IIS-WindowsAuthentication   /FeatureName:IIS-WMICompatibility   /FeatureName:WAS-ConfigurationAPI   /FeatureName:WAS-NetFxEnvironment   /FeatureName:WAS-ProcessModel   /FeatureName:WAS-WindowsActivationService
    dism /online /enable-feature /featurename:IIS-ISAPIFilter
    dism /online /enable-feature /featurename:IIS-ISAPIExtensions