promisesaplus.com
产生巨大后果的思想常常是朴素的。——列夫·托尔斯泰 今天刷到一个网站: https://promisesaplus.com/ 对应的组织: https://github.com/promises-aplus/ 对应有一个开源库用来检验是否符合Promise/A+规范: https://github.com/promises-aplus/promises-tests/ 安装: 1npm install promises-aplus-tests -g 然后添加CI脚本 12345678{ "devDependencies": { "promises-aplus-tests": "*" }, "scripts": { "test": "run-my-own-tests && promises-aplus-tests test/my-adapter" ...
ClassPathResource踩坑
不要对一切人都以不信任的眼光看待,但要谨慎而坚定。——德谟克里特 今天看到一个问题 12345678910111213static { try { ClassPathResource resource = new ClassPathResource("ip2region.xdb"); //获取真实文件路径 String path = resource.getURL().getPath(); byte[] cBuff = Searcher.loadContentFromFile(path); SEARCHER = Searcher.newWithBuffer(cBuff); log.info("加载了ip2region.xdb文件,Searcher初始化完成!"); } catch (Exception e) { log.error("初始化ip2region.xdb文件失败,报错...
ip解析ip2region
做人要正直无欺,真实无伪,又要温厚和平,勿太棱角峭历。——陆陇其 https://github.com/lionsoul2014/ip2region 今天分享一个ip解析库ip2region 这里相关的java实现: https://github.com/lionsoul2014/ip2region/tree/master/binding/java maven依赖: 12345<dependency> <groupId>org.lionsoul</groupId> <artifactId>ip2region</artifactId> <version>2.7.0</version></dependency> 然后是完全基于文件的查询 123456789101112131415161718192021222324252627282930313233import org.lionsoul.ip2region.xdb.Searcher;import java.io.*...
webclient负载均衡踩坑
一个人总免不了称为别人的对立面。——乔治·克列孟俊 今天踩坑 123456789101112131415161718192021222324252627282930313233import cn.dev33.satoken.same.SaSameUtil;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import org.springframework.web.reactive.function.client.WebClient;import reactor.core.publisher.Mono;/** * UserClient * * @author VampireAchao<achao @ hutool.cn> */@Servicepublic class UserClient { private final WebClient webClient; @Autowire...
tianai-captcha
笑长命,哭生病。——佚名 分享一个验证码库 在线体验http://captcha.tianai.cloud 使用方式http://doc.captcha.tianai.cloud 源码地址https://gitee.com/dromara/tianai-captcha https://github.com/dromara/tianai-captcha tianai-captcha简称tac,是一款集成滑动类、点选类的一款行为验证码,以使用简单、安全性强、界面美观、接入方便而,是为集好看、功能多、安全性强的一款开源行为验证码工具。 今天tianai-captcha加入dromara,热烈欢迎
参数化单元测试
屋小巧安置,田少勤耕耘,妻贱合夫心,此乃真富裕。——富兰克林 今天进行streampark参数化单元测试,用来测试多个数据库下的兼容情况 12345678910111213141516171819202122232425262728package org.apache.streampark;import com.baomidou.mybatisplus.extension.plugins.pagination.Page;import org.apache.streampark.console.core.entity.Application;import org.apache.streampark.console.core.mapper.ApplicationMapper;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.params.ParameterizedTest;import org.junit.jupiter.params.provider.ValueSource;import org.s...
like concat 兼容h2、mysql、pgsql语法
推动你的事业,不要让你的事业推动你。——爱因斯坦 今天解决 https://github.com/apache/incubator-streampark/issues/3451 时候发现从'%${variable.variableCode}%'改为concat ('%', #{variable.variableCode}, '%') 解决的sql注入问题与postgresql不兼容 于是加了一个CAST解决 https://github.com/apache/incubator-streampark/pull/3457 concat('%', CAST(#{variable.variableCode} AS CHAR), '%') 这样就兼容了h2、mysql和pgsql 这里测试时候首先本地运行h2跑一下,然后用docker启动一个mysql跑一下: 1docker run --name streampark-mysql -e MYSQL_ROOT_PASSWORD=streampark -e ...
xxl-job restful api
谁若与集体脱离,谁的命运就要悲哀。——奥斯特洛夫斯基 昨天对接了xxl-job的restful api,发现其没有提供查询job信息的api,于是自己拓展 在原先com.xxl.job.admin.controller.JobApiController#api添加 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253/** * api * * @param uri * @param data * @return */@RequestMapping("/{uri}")@ResponseBody@PermissionLimit(limit=false)public ReturnT<?> api(HttpServletRequest request, @PathVariable("uri") String uri, @RequestBody(required = fals...
cron-utils获取下几次执行时间
忍耐与温柔是最大的力量。——哈特 首先引入依赖: 12345<dependency> <groupId>com.cronutils</groupId> <artifactId>cron-utils</artifactId> <version>9.2.0</version></dependency> 然后是代码: 12345678910111213141516171819202122232425262728293031323334353637import com.cronutils.model.Cron;import com.cronutils.model.CronType;import com.cronutils.model.definition.CronDefinitionBuilder;import com.cronutils.model.time.ExecutionTime;import com.cronutils.parser.CronParser;im...
open-feign设置全局header
求学犹植树,春天开花朵,秋天结果实。——爱因斯坦 代码如下: 1234567891011121314import feign.RequestInterceptor;import feign.RequestTemplate;@Componentpublic class CustomRequestInterceptor implements RequestInterceptor { @Override public void apply(RequestTemplate template) { // 添加全局Header template.header("Global-Header-Name", "Global-Header-Value"); // 例如,如果您需要添加一个认证令牌,可以这样做: // template.header("Authorization", "Bearer " + authT...
