vue3配置jsx
正如自然忌讳真空一样,人类是讨厌平等的。——《我是猫》 首先按照官方文档创建项目: 1npm init vite hello-vue3 -- --template vue # 或 yarn create vite hello-vue3 --template vue 然后我们安装jsx插件:https://github.com/vuejs/babel-plugin-jsx 1npm install @vue/babel-plugin-jsx -D 然后配置vite.config.js 123456789101112import { defineConfig } from 'vite'import vue from '@vitejs/plugin-vue'import vuejsx from "@vue/babel-plugin-jsx"// https://vitejs.dev/config/export default defineConfig({ plugins: [vue(),...
Collectors.flatMapping
我只想站在比你高的地方,用人类最纯粹的痛苦和烦恼给你一记响亮的耳光。——《阴火》 发现官方竟然没有,那就自己写一个 12345678910public static <T, U, A, R>Collector<T, ?, R> flatMapping(Function<? super T, Stream<? extends U>> mapper, Collector<? super U, A, R> downstream) { BiConsumer<A, ? super U> downstreamAccumulator = downstream.accumulator(); return new Collectors.CollectorImpl<>(downstream.supplier(), (r, t) -> Opp.ofNullable(t).map(mapper).ifPres...
escape、unescape废弃
爱所有人,信任少数人,不负任何人。——莎士比亚 今天看到这个API废弃了,提示使用 encodeURI 或 encodeURIComponent 代替。 但是貌似有部分符号并没有转义成功 最后在示例看到了解决办法 123456789101112131415161718192021222324252627282930var fileName = 'my file(2).txt';var header = "Content-Disposition: attachment; filename*=UTF-8''" + encodeRFC5987ValueChars(fileName);console.log(header);// 输出 "Content-Disposition: attachment; filename*=UTF-8''my%20file%282%29.txt"function encodeRFC5987ValueChars (str) ...
StreamEx
这个世界上没有无用的齿轮,也只有齿轮本身能决定自己的用途。——《嫌疑犯X的献身》 跟昨天介绍的eclipse-collections一样,这是一个同类产品: 仓库地址:https://github.com/amaembo/streamex JavaDoc:http://amaembo.github.io/streamex/javadoc/one/util/streamex/package-summary.html 感受下: 123List<String> userNames = StreamEx.of(users).map(User::getName).toList();Map<Role, List<User>> role2users = StreamEx.of(users).groupingBy(User::getRole);StreamEx.of(1,2,3).joining("; "); // "1; 2; 3" 对比起来好像比eclipse-collections写更少代码 而且更向原生s...
eclipse-collections
志向和热爱是伟大行为的双翼。——歌德 之前分享了vavr,今天在分享一个同类框架eclipse-collections 官方文档:http://www.eclipse.org/collections/ 1234567891011<dependency> <groupId>org.eclipse.collections</groupId> <artifactId>eclipse-collections-api</artifactId> <version>11.0.0</version></dependency><dependency> <groupId>org.eclipse.collections</groupId> <artifactId>eclipse-collections</artifactId> <version>11.0.0</version></dependency&...
List<Map>聚合为单个Map<List>
科学是到处为家的,不过,在任何不播种的地方,是决不会得到丰收的。——赫尔岑 前两天有人给我的项目stream-query提交了PR,新增了一个Collector实现 我稍微研究了一下,发现与Collectors原生命名风格不统一,且不具备Collectors包下面的对象通用性,于是就移除了 但这个功能是可以保留的 我的实现如下: 1234567891011121314151617181920212223242526@Testvoid testReducing() { Set<Map<String, Integer>> nameScoreMapList = Stream.of( new HashMap<String, Integer>() {{ put("苏格拉底", 1); put("特拉叙马霍斯", 3); }}, Co...
reducing和reduce
我的悲伤还来不及出发,就已经到站下车。——《第七天》 在java中,分为Collectors.reducing和Stream#reduce reduce是减少的意思,此处意为聚合 聚合是聚拢、合并的意思 我们来看看这俩函数的区别吧,下方我用了静态导入: 1234567import java.math.BigDecimal;import java.util.*;import java.util.function.BinaryOperator;import java.util.stream.Collector;import java.util.stream.Stream;import static java.util.stream.Collectors.*; 首先是写法差异,对于只有一个参数的,这个参数指定了我们聚合的操作,此处我做一个累加,返回值为Optional证明有可能不存在值,就没有累加 1234Optional<Integer> sumOpt = Stream.iterate(0, i -> ++i).limit(10).collect(reduci...
idea打印断点日志
履不必同,期于适足;治不必同,期于利民。——魏源 先上图 然后开始 水字数 讲解: 我们可以看到当我们debug设置断点时,如果勾选了黄色区域 Log: "Breakpoint hit" message(日志 “断点命中”消息) 此时当我们的断点触发后,会打印断点命中时的信息 1BreakPoint reached at 类名:行号 旁边还有一个Stack trace 和上面的类似,但会打印出堆栈信息
gitee、github、maven图标
人生碌碌,竞短论长,却不道荣枯有数,得失难量。——《浮生六记》 朋友问我stream-query官网这个图标怎么搞: 实际上是这样一个网站生成的:https://shields.io/ 比如我这里搜maven: 可以看到下方的示例,我们点击下面的图标,弹出一个框 填好配置即可 点击Copy Badge URL就可以使用啦! 1https://img.shields.io/maven-central/v/io.github.vampireachao/stream-query?color=%23ff&label=maven%E4%B8%AD%E5%A4%AE%E4%BB%93%E5%BA%93
js让光标选择节点中部分文本
我走得很慢,但我从不后退。——林肯 如题,代码: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152<!DOCTYPE html><html><head> <meta charset="utf-8"> <title></title></head><body> <div id="container">ruben</div> <button>r</button> <button>u</button> <button>b</button> <button>e</button> <button>n</button> &...
