mac新电脑安装开发环境工具

brew安装

/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"\n

oh-my-zsh安装

sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"\n

item2安装

brew install item2 --cask

node安装

brew install node
npm install -g n
sudo n install 12.13.1
brew uninstall node

watchman安装

brew install watchman

cocoapods安装

brew install cocoapods

go安装

brew install go

hugo安装

brew install hugo

xcode 命令行切换

sudo xcode-select -r

sudo xcode-select --switch /Library/Developer/CommandLineTools

Esp32c3 flash 分区最大化的OTA分区表

测试环境为esp32c3 4MB flash

# ESP-IDF Partition Table
# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x4000,
otadata,  data, ota,     0xd000,  0x2000,
phy_init, data, phy,     0xf000,  0x1000,
ota_0,  app,  ota_0,   0x10000, 1980K,
ota_1,    app,  ota_1,   0x200000, 1980K,
*******************************************************************************
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,16K,
otadata,data,ota,0xd000,8K,
phy_init,data,phy,0xf000,4K,
ota_0,app,ota_0,0x10000,1980K,
ota_1,app,ota_1,0x200000,1980K,
*******************************************************************************

0x8000,位置烧录分区表

0x0,烧录bootloader

0x0: bootloader.bin

0x8000: partition-table.bin

0xd000: ota_data_initial.bin

Golang_platform_name

Golang文件名命名规则

在golang源代码中,经常看到各种文件名,比如: bolt_windows.go。

下面对文件名命令规则的说明: 1、平台区分 文件名_平台。

例: file_windows.go, file_unix.go

可选为:windows, unix, posix, plan9, darwin, bsd, linux, freebsd, nacl, netbsd, openbsd, solaris, dragonfly, bsd, notbsd, android,stubs

2、测试单元 文件名test.go或者 文件名平台_test.go。 例: path_test.go, path_windows_test.go

3、版本区分(猜测) 文件名_版本号等。 例:trap_windows_1.4.go

4、CPU类型区分, 汇编用的多 文件名_(平台:可选)_CPU类型. 例:vdso_linux_amd64.go 可选:amd64, none, 386, arm, arm64, mips64, s390,mips64x,ppc64x, nonppc64x, s390x, x86,amd64p32

Esp32c3烧写

//察除
esptool.py --chip esp32c3 --port /dev/ttyUSB0 erase_flash

// 烧录
esptool.py --chip esp32c3 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x0 esp32c3-20220117-v1.18.bin

idf.py set-target esp32c3

idf.py menuconfig

idf.py build

idf.py -p PORT [-b BAUD]

idf.py -p PORT monitor

Linux发送UDP报文

echo "hello" | socat - udp4-datagram:192.168.31.229:8011
apt install socat

tcpdump -D 获取网络适配器列表,以下是在Ubuntu上获取到的结果:

tcpdump -i <需要监控的网络适配器编号>,例如我想监控我的无线网卡wlan0,则使用tcpdump -i 2。

使用无线网卡wlan0监控IP地址为172.16.86.111上443端口的tcp协议:   tcpdump -i 2 host 172.16.86.111 and tcp port 443

如果想要显示数据包的内容,需要使用-X参数,如,我想要显示捕获的https数据包http header的内容:   tcpdump -X -i 2 host 172.16.86.111 and tcp port 443

Spring_boot使用Example对象做条件查询

基本使用方法

 @GetMapping("/subwayLines")
    public ResponseListBase<SubwayLine> list(@RequestParam(required = false, defaultValue = "0") int page,
                                             @RequestParam(required = false, defaultValue = "20") int size,
                                             @RequestParam(required = false, defaultValue = "") String lineNo,
                                             @RequestParam(required = false, defaultValue = "") String lineName) {

        SubwayLine subwayLine = new SubwayLine();

        ExampleMatcher em = ExampleMatcher.matching();

        if(lineNo != null && !lineNo.equals("")) {
            subwayLine.setLineNo(lineNo);
            em = em.withMatcher("lineNo", GenericPropertyMatcher::startsWith);
        }
        if(lineName != null && !lineName.equals("")) {
            subwayLine.setLineName(lineName);
            em = em.withMatcher("lineName", GenericPropertyMatcher::startsWith);
        }
        Page<SubwayLine> subwayLinePage = repository.findAll(Example.of(subwayLine, em), PageRequest.of(page, size));

        return new ResponseListBase<>(subwayLinePage);
    }

注意事项:官方用例写法:

ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("firstname", match -> match.endsWith())
.withMatcher("firstname", match -> match.startsWith());

自己的写法:

ExampleMatcher em = ExampleMatcher.matching();
em = exampleMatcher.withMatcher("lineNo", ExampleMatcher.GenericPropertyMatcher::startsWith);

其中重新付值是必须的,查看withMatcher代码会发现,返回一个新的对象,如果不做赋值,会导致没有配置模糊查询

第二个注意点是其中的lineNo必须和对象的名称一致,如果 line_no导致模糊查询不生效。

SpringBoot3.0 使用Spring Security

以前版本使用方式

@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Override
    public void configure(WebSecurity web) {
        web.ignoring().antMatchers("/ignore1", "/ignore2");
    }
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
            .anyRequest().authenticated()
            .and()
            .httpBasic(withDefaults());
    }
}

新版使用

@Configuration
// 不需要继承WebSecurityConfigurerAdapter
public class SecurityConfiguration {
    @Bean
    public WebSecurityCustomizer webSecurityCustomizer() {
        return (web) -> web.ignoring().requestMatchers("/ignore1", "/ignore2");
    }
    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http
            .authorizeHttpRequests((authz) -> authz
                .anyRequest().authenticated()
            )
            .httpBasic(withDefaults());
        return http.build();
    }
}