xud6的笔记本

MACOS 修复应用修改后代码签名问题,即xxx.app已损坏

 •  Filed under mac

创建代码签名证书

打开钥匙串访问
打开菜单栏-钥匙串访问-证书助理创建证书
证书类型选代码签名,名称取个终端中容易输入的,创建。
找到刚创建的证书,打开后在信任中代码签名修改为始终信任。

重签名有问题的app

sudo codesign --deep --force --verify --verbose --sign "XXXXXcodesign" /Applications/YYYYY.app

XXXXXcodesign为刚才创建的证书名
YYYYY.app为需要签名的app

H3C下载账号

 • 

用户名:yx800
密码:01230123

apt限制同时下载数量

 •  Filed under linux, debian

Queue-Mode 设置选项

默认值为 host 对每个host发起一个连接。当设为access时,对每个URI类型发起一个连接。由于大部分为http,因此也大致满足要求

永久设置

echo 'Acquire::Queue-Mode "access";' >/etc/apt/apt.conf.d/75download

临时设置

apt -o Acquire::Queue-mode=access upgrade

STM32 HAL UART循环发送缓存

 •  Filed under Embedded
#define UART_SEND_BUFF_SIZE		100
uint8_t UARTSendBuff[UART_SEND_BUFF_SIZE + 2] = {0};
uint16_t UARTSendBuffDataPos = 0;
uint16_t UARTSendBuffUsedPos = 0;
uint8_t UARTSendBuff_FlagSendBusy = 0;
void UARTSendBuff_putData(uint8_t * data,uint16_t len){
    while(len){
        UARTSendBuffDataPos++;
        if(UARTSendBuffDataPos > UART_SEND_BUFF_SIZE){
            UARTSendBuffDataPos = 1;
        }
        UARTSendBuff[UARTSendBuffDataPos] = *data;

        len --;
        data++;
    }
}

void UARTSendBuff_StartSend(){
    if(UARTSendBuff_FlagSendBusy == 0){
        if(UARTSendBuffDataPos == UARTSendBuffUsedPos){
            return;
        }else if(UARTSendBuffDataPos > UARTSendBuffUsedPos){
            UARTSendBuff_FlagSendBusy = 1;
            HAL_UART_Transmit_IT(&huart2,&UARTSendBuff[UARTSendBuffUsedPos + 1],(UARTSendBuffDataPos-UARTSendBuffUsedPos));
            UARTSendBuffUsedPos = UARTSendBuffDataPos;
        }else if(UARTSendBuffDataPos < UARTSendBuffUsedPos){
            if(UARTSendBuffUsedPos == UART_SEND_BUFF_SIZE){
                UARTSendBuffUsedPos = 0;
                UARTSendBuff_FlagSendBusy = 1;
                HAL_UART_Transmit_IT(&huart2,&UARTSendBuff[UARTSendBuffUsedPos + 1],(UARTSendBuffDataPos-UARTSendBuffUsedPos));
                UARTSendBuffUsedPos = UARTSendBuffDataPos;
            }else{
                UARTSendBuff_FlagSendBusy = 1;
                HAL_UART_Transmit_IT(&huart2,&UARTSendBuff[UARTSendBuffUsedPos + 1],(UART_SEND_BUFF_SIZE-UARTSendBuffUsedPos));
                UARTSendBuffUsedPos = 0;
            }
        }
    }
}

void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart){
    UARTSendBuff_FlagSendBusy = 0;
    UARTSendBuff_StartSend();
}

void UARTSEndBuff_Send(uint8_t * data,uint16_t len){
    UARTSendBuff_putData(data,len);
    UARTSendBuff_StartSend();
}

Powershell 卸载程序

 •  Filed under windows, powershell
function Uninstall-Application {
    $appName = $($args[0])
    Write "application to uninstall: $appName"
    $uninstall32 = gci "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -Match $appName }
    $uninstall64 = gci "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match $appName }

    if($uninstall32){
        if($uninstall32.QuietUninstallString){
            Write ("uninstall32 Quiet: " + $uninstall32.QuietUninstallString)
            Start-Process -FilePath cmd.exe -ArgumentList '/c', $uninstall32.QuietUninstallString  -Wait
        }else{
            Write ("uninstall32 Normal: " + $uninstall32.UninstallString)
            Start-Process -FilePath cmd.exe -ArgumentList '/c', $uninstall32.UninstallString  -Wait
        }
    }
    if($uninstall64){
        if($uninstall64.QuietUninstallString){
            Write ("uninstall64 Quiet: " + $uninstall64.QuietUninstallString)
            Start-Process -FilePath cmd.exe -ArgumentList '/c', $uninstall64.QuietUninstallString  -Wait
        }else{
            Write ("uninstall64 Normal: " + $uninstall64.UninstallString)
            Start-Process -FilePath cmd.exe -ArgumentList '/c', $uninstall64.UninstallString  -Wait
        }
    }
}

Uninstall-Application("application name*")

PowerShell 自动提权

 • 

添加至脚本头

param([switch]$Elevated)

function Test-Admin {
    $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
    $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}

if ((Test-Admin) -eq $false)  {
    if ($elevated) {
        # tried to elevate, did not work, aborting
    } else {
        Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
    }
    exit
}

'running with full privileges'