Beautiful Life

果酱 发布的文章

果酱 in C#
May 28, 2024

SemaphoreSlim误用导致锁失效的BUG

BUGinternal class Program { static SemaphoreSlim semaphoreSlim = new SemaphoreSlim(1,1); public async Task foo(CancellToken cancelltoken) { try{ //超时会释放锁,进入后序代码执行,不会报错停止执行 ...
May 20, 2024

Spring Jackson 序列化反序列化

基于SpringBoot默认的Jackson对处理Json,要实现RequestBody反序列化,ResponseBody序列化,全局配置。主要是反序列化输入难处理方法一spring.jackson.date-format=yyyy-MM-dd HH:mm:ss 这个只对输出有效方法二@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")...
April 29, 2024

JavaScript求真值t => !!t

v.split(';').filter(t => !!t); 在 JS中,filter 方法通常用于过滤数组中的元素。在这种情况下,t => !!t 是一个箭头函数,其作用是对数组中的每个元素 t 进行筛选,只保留那些转换为布尔值后为真的元素。具体来说:!t 将 t 转换为布尔值,并取其相反值,即如果 t 是假值(如null, undefined, 0, '', false),则...
April 18, 2024

shell输入参数和内部菜单实现

在shell外的参数,生成usage#!/usr/bin/env bash # grep " .)\ #" $0 === grep " .)\ #" 文件名, 打印出对应行 # p)# Specify p value. # s)# Specify strength, either 45 or 90. # h|*)# Display ...
April 12, 2024

一个由shell实现的网络探活工具

#! /bin/bash #检测网络连接 #设置检测的IP initIp(){ #echo $1 if [ -n "$1" ];then ip=$1 else ip=10.1.2.1 fi echo 初始化ip=$ip } #循环检查 pingCheck(){ retry=0...