Geek Stuff Blog

世事皆有机缘,不争不显不露,若没遇上便也甘之如饴!

Java 8 CompletableFuture 详解

Java 8引入了CompletableFuture<T>以及它的接口CompletionStage<T>作为对Future<T>的增强,它可以让你使用回调驱动的方式表达不同任务的信息流。CompletableFuture用来定义单个任务事件的计算。本文主要介绍其用法以及常见的工具方法。 CompletableFuture<T> API 1、...

Python numpy 学习笔记

1、数组创建 np.set_printoptions(precision=6, linewidth=320, suppress=True, threshold=np.inf) # 生成[0,1)之间的数据 np.random.random(10) np.random.rand(4, 2) np.random.rand(4, 3, 2) # 标准正态分布 np.random.rand...

Python 必要代码片段

1、自定义数据类型 t = np.dtype([('name', np.str_, 40), ('numitems', np.int32), ('price', np.float32)]) itemz = np.array([('Meaning of life DVD', 42, 3.14), ('Butter', 13, 2.72)], dtype=t) 2、打印完整数组 np.set...

SQL 必要代码片段

1、full outer join 替换方式 select * from t1 left join t2 on t1.id = t2.id union select * from t1 right join t2 on t1.id = t2.id 2、每组取最大的topK group_concat & find_in_set select t1.* from bo...

Java 必要代码片段

0、包装类型比较使用equals,而不是== Long a = 11L; Long b = 11L; a.equals(b); int result = Long.compare(a, b) a>b result>0 a=b result=0 a<b result<0 1、得到当前的方法名 String methodName = Thread.currentThr...

Java 8 Lambda 学习笔记

本笔记部分是根据leveluplunch的博客整理的关于Java 8 lambda的知识。 1、统计汇总 DoubleSummaryStatistics stats = companies.stream().mapToDouble((x) -> x.getRevenue()).summaryStatistics(); DoubleSummaryStatistics stats...

Google Guava 学习笔记

Joiner Joiner.on("|").skipNulls().join(stringList); Joiner.on("|").useForNull("no value").join(stringList); Joiner.on("#").withKeyValueSeparator("=").join(stringMap); Splitter Splitter.on(Patte...

常用工具及快捷键

Latex Templates and Sample Files Getting Started with LaTeX Online tutorials on LaTeX Not so short LaTeX-Online-Help 在线编辑LaTex Mathpix Snoipping Tool MAC 删除 反向删除:Fn+Delete 删...

awk 使用技巧

初始入门 cat awk.txt Item1,200 Item2,500 Item3,900 Item2,800 Item4,500 Item1,400 Item2,200 Item3,700 Item4,800 Item1,600 第二列求和 awk -F","'{x+=$2}END{print x}' awk.txt 5600 对某个Item求和 ...

常用命令汇总

中文乱码 /etc/sysconfig/i18n,LANG="zh_CN.UTF-8" 查看环境变量 env 查看当前用户的计划任务 crontab -l 查看所有分区 fdisk -l #查看挂载的设备,以及这些设备的文件系统 lsblk -f 查看各分区使用情况 # df从整体上反映文件系统对节点和磁盘块的使用情况,du主要统计目录或文件所占磁盘空间的大小。 # ...