js惰性函数
要深入了解人的方法只有一个,就是不急于下定论。——圣·普波 在js中我们可以使用惰性函数,用于重新定义函数自身的行为 例如: 12345678910111213141516171819202122function addEvent(type, el, fn) { if (window.addEventListener) { addEvent = function(type, el, fn) { el.addEventListener(type, fn, false); } } else if (window.attachEvent) { addEvent = function(type, el, fn) { el.attachEvent('on' + type, fn); } } else { addEvent = function(type, el, fn) { el['...
spring-state-machine动态构建
习惯的力量是巨大的。——西塞罗 文档: https://docs.spring.io/spring-statemachine/docs/current/reference/#state-machine-via-builder 此处表明状态机不仅可以通过配置类的方式进行配置,还可以通过建造者模式动态构建 123456789StateMachine<String, String> buildMachine1() throws Exception { Builder<String, String> builder = StateMachineBuilder.builder(); builder.configureStates() .withStates() .initial("S1") .end("SF") .states(new HashSet<String>(Arrays.asList("S1","S2","S3",&q...
Hello 算法
为了保忠祖国,即便经受非人的磨难,甚至同死亡之神的接吻还是快活的。——显客微友 分享一个开源项目,讲算法的 https://github.com/krahets/hello-algo https://www.hello-algo.com/ 两年前,作者在力扣上分享了《剑指 Offer》系列题解,受到了许多同学的喜爱和支持。在与读者的交流期间,最常收到的一个问题是“如何入门学习算法”作者逐渐对这个问题产生了浓厚的兴趣。 两眼一抹黑地刷题似乎是最受欢迎的方法,简单直接且有效。刷题就如同玩“扫雷”游戏,自学能力强的同学能够顺利地将地雷逐个排掉,而基础不足的同学很可能被炸的满头是包,并在挫折中步步退缩。通读教材书籍也是一种常见做法,但对于面向求职的同学来说,毕业季、投递简历、准备笔试面试已经占据了大部分精力,厚重的书籍往往变成了一项艰巨的挑战。 如果你也面临类似的困扰,那么很幸运这本书找到了你。本书是作者对此问题的给出的答案,即使不是最优解,也至少是一次积极的尝试。这本书虽然不足以让你直接拿到 Offer ,但会引导你探索数据结构与算法的“知识地图”,带你了解不同“地雷”的形状大...
spring-state-machine持久化
天底下只有一个方法可以影响人,就是提到他们的需要,并且让他们知道怎么去获得。——卡耐基 文档如下: https://docs.spring.io/spring-statemachine/docs/current/reference/#statemachine-examples-datapersist 代码示例如下: https://github.com/spring-projects/spring-statemachine/tree/main/spring-statemachine-samples/persist 状态机持久化主要解决服务端重启后会话丢失问题 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610...
spring-state-machine守卫
是非之声,无翼而飞;损益之名,无胫而走。——白居易 文档: https://docs.spring.io/spring-statemachine/docs/current/reference/#configuring-guards 说白了守卫是用来判断事件执行后能否更新到下一个状态的 这里按之前提到的代码示例来示范 首先是配置为返回true,发现下面一路正常打印 然后是return false 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485package com.ruben.parent;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configura...
open-feign自定义反序列化decoder
人受谏,则圣。木受绳,则直。金就砺,则利。——孔子 主要是解决map类型擦除的问题,GlobalResponse继承了Map 代码如下: 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465import cn.hutool.core.util.TypeUtil;import com.fasterxml.jackson.core.type.TypeReference;import com.fasterxml.jackson.databind.JsonNode;import feign.RequestTemplate;import feign.Response;import feign.Util;import feign.codec.DecodeException;import feign.codec.Decoder;import feign.codec.EncodeException;imp...
macos查看本机所有java路径
勤劳乃成功之母,——小林多喜二 学到个命令: 12345678Github-Id-VampireAchao:~ achao$ /usr/libexec/java_home -VMatching Java Virtual Machines (5): 21.0.1 (arm64) "Oracle Corporation" - "OpenJDK 21.0.1" /Users/achao/Library/Java/JavaVirtualMachines/openjdk-21.0.1/Contents/Home 20.0.2 (arm64) "Oracle Corporation" - "OpenJDK 20.0.2" /Users/achao/Library/Java/JavaVirtualMachines/openjdk-20.0.2/Contents/Home 17.0.8.1 (arm64) "Azul Systems, Inc." - "Zulu 1...
Motrix开源下载管理器
怒伤肝,思伤脾,忧伤肺,恐伤肾。——佚名 官网: https://motrix.app/ 源码: https://github.com/agalwood/Motrix chrome插件: https://github.com/gautamkrishnar/motrix-webextension 前两天用XCode下载IOS模拟器半天都下载不下来,之后去官网下,也老断开,最后用这个下载管理器 安装完插件需要配置: 之后重启浏览器即可让Motrix接管下载
idea下载不下来maven三方库源码处理
没有信仰,则没有名副其实的品行和生命;没有信仰,则没有名副其实的国土。——惠特曼 只需要执行: 1mvn dependency:resolve -Dclassifier=sources 即可下载源码
r2dbc事务处理
劳动创造了人本身。——恩格斯 官方demo: https://github.com/spring-projects/spring-data-examples/blob/main/r2dbc/example/src/main/java/example/springdata/r2dbc/basics/TransactionalService.java 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152/* * Copyright 2019-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy...
