├── README.md ├── DB ├── Mysql │ ├── README.md │ ├── MySQL Connector Configuration.md │ └── MySql-常用.md ├── DB-GUI.md ├── Cache │ ├── README.md │ ├── Redis │ │ └── 常用.md │ └── memcached │ │ └── Memcached安装及使用.md └── ZooKeeper │ └── ZooKeeper注意事项.md ├── DistributedStorage ├── HDFS.md ├── SeaweedFS.md ├── GlusterFS.md ├── 选型.md └── Ceph.md ├── Web ├── Browser │ ├── Plugins.md │ └── Firefox │ │ └── 常用.md ├── JS │ ├── SourceMap.md │ ├── iView.md │ ├── 插件列表.md │ ├── grunt-contrib-watch(gaze)创建文件BUG.md │ ├── Webpack.md │ ├── jquery-plugins │ │ └── Select2.md │ ├── Less.md │ └── Cookie详解.md ├── SSG │ ├── Jamstack.md │ └── Static-Site-Generator.md ├── ServerPush-WebSocket.md └── Web-常用.md ├── Security ├── Java反序列化漏洞.md ├── Clickjacking.md ├── Session Fixation Attack.md ├── CSRF - CrossSiteRequestForgery.md ├── XSS - CrossSiteScripting.md ├── Token │ └── Token介绍.md ├── OAuth2 │ └── OAuth2介绍.md ├── CORS - CrossOriginResourceSharing.md └── 汇总.md ├── Java ├── 分库分表 │ └── README.md ├── Sitemesh │ ├── Sitemesh │ │ ├── imgs │ │ │ └── sitemesh.png │ │ └── 自由控制body页的代码片段.md │ └── Sitemesh3+Freemarker+SpringMVC整合.md ├── Servlet │ ├── servlet-mapping映射规则和顺序.md │ ├── Servlet-常用.md │ └── Nginx+Tomcat 环境下response.sendRedirect URL地址错乱.md ├── Spring │ ├── Webflux.md │ ├── SpringCloud │ │ ├── CircuitBreaker.md │ │ ├── 限流.md │ │ └── SpringCloud.md │ ├── SpringMVC.md │ ├── SpringBoot │ │ ├── SpringBoot.md │ │ └── Fat-Jar排除指定包.md │ └── SpringDataRedis.md ├── Java-类型详解.md ├── 分布式事务 │ ├── ServiceCombPack.md │ └── 总览.md ├── Java-Mapping-Framework.md ├── JdbcConnectionPool │ └── HikariCP.md ├── JLine │ └── JLine3.md ├── Thread │ └── ThreadLocal.md ├── Maven │ ├── Maven Wrapper(统一Maven版本).md │ └── 项目支持多版本JDK编译.md ├── Reactive │ └── Reactive.md ├── Attach-Instrumentation.md ├── Validator │ └── JakartaBeanValidation.md ├── Java文件锁-FileLock.md ├── Office软件 │ └── Excel.md ├── APT-AnnotationProcessingTool.md ├── OSGi - Jigsaw.md └── Hessian │ └── Hessian和SpringMVC集成.md ├── Template&MarkupLanguage ├── Markdown.md ├── YAML.md ├── Template │ ├── 常用.md │ └── Freemarker.md └── JSON │ └── Jackson.md ├── Tools ├── IDE │ ├── WebStorm │ │ ├── imgs │ │ │ ├── 1.png │ │ │ ├── 2.png │ │ │ ├── 3.png │ │ │ ├── 4.png │ │ │ └── 5.png │ │ └── WebStorm调试Grunt.md │ ├── VisualStudio │ │ └── VS.md │ ├── IDEA │ │ ├── IDEA terminal集成Shell.md │ │ └── IDEA生成Getter-Setter Boolean兼容Eclipse.md │ └── Eclipse │ │ └── Eclipse常用配置及插件.md ├── HTTPie.md ├── 有道.md ├── 设计 │ ├── 在线设计.md │ └── TextCodeDesignTools.md ├── 推荐网站.md ├── EasyPdf.md ├── SCM │ ├── Svn常用.md │ ├── pre-receive │ └── Sourcegraph.md ├── 图片处理 │ └── 图片处理.md ├── 文档工具.md └── Xterm │ └── MobaXterm.md ├── imgs └── QuartzRescheduleCronJob导致立即执行原理.png ├── DevOps └── Ansible.md ├── linux ├── CPU.md ├── 发送邮件.md ├── Firewalld.md └── 关闭TransparentHugePages (THP).md ├── .gitignore ├── Microservice ├── OpenServiceBrokerAPI │ └── Open Service Broker API.md ├── K8S │ ├── Kompose.md │ └── Telepresence.md ├── Docker │ ├── Docker常用.md │ ├── Docker容器内执行Docker命令.md │ └── Docker-compose安装及使用.md ├── Dubbo │ ├── Dubbo泛化调用.md │ └── Dubbo.md └── 分布式ID.md ├── Proxy ├── Nginx │ ├── 常用.md │ ├── modules │ │ ├── ngx_http_random_index_module.md │ │ ├── ngx_http_index_module.md │ │ └── ngx_http_autoindex_module.md │ └── directives │ │ ├── location.md │ │ └── proxy.md └── Keepalived │ └── Keepalived安装及使用.md ├── Test ├── 压测工具.md ├── JMeter.md ├── Katalon.md └── 抓包工具.md ├── 学科 └── 数学.md ├── Algorithm └── 算法.md ├── Terms └── 术语.md ├── CodeStyle ├── 阿里规范.md ├── Jacoco.md └── CodeStyle-IDE.md ├── 网络传输协议 └── 网络传输协议.md ├── Monitor ├── Zipkin.md └── 综合.md ├── API └── API-常用.md └── Workflow └── Workflow.md /README.md: -------------------------------------------------------------------------------- 1 | # docs 2 | 共享文档 3 | -------------------------------------------------------------------------------- /DB/Mysql/README.md: -------------------------------------------------------------------------------- 1 | # mysql 2 | mysql文档 3 | -------------------------------------------------------------------------------- /DistributedStorage/HDFS.md: -------------------------------------------------------------------------------- 1 | # HDFS 2 | 3 | ## 参考 4 | -------------------------------------------------------------------------------- /Web/Browser/Plugins.md: -------------------------------------------------------------------------------- 1 | # 浏览器插件 2 | 3 | ## Circle 阅读助手 4 | 5 | * [官网](http://circlereader.com/) -------------------------------------------------------------------------------- /Security/Java反序列化漏洞.md: -------------------------------------------------------------------------------- 1 | ## Java反序列化漏洞 2 | 3 | * [深入理解 JAVA 反序列化漏洞](https://paper.seebug.org/312/) 4 | -------------------------------------------------------------------------------- /Java/分库分表/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | ## 文档 4 | 5 | * [分库分表简介](https://www.hollischuang.com/archives/6701) -------------------------------------------------------------------------------- /Template&MarkupLanguage/Markdown.md: -------------------------------------------------------------------------------- 1 | ## Markdown 2 | 3 | * [官方手册](https://spec.commonmark.org/) 4 | 5 | -------------------------------------------------------------------------------- /Tools/IDE/WebStorm/imgs/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WangXiaoJin/docs/HEAD/Tools/IDE/WebStorm/imgs/1.png -------------------------------------------------------------------------------- /Tools/IDE/WebStorm/imgs/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WangXiaoJin/docs/HEAD/Tools/IDE/WebStorm/imgs/2.png -------------------------------------------------------------------------------- /Tools/IDE/WebStorm/imgs/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WangXiaoJin/docs/HEAD/Tools/IDE/WebStorm/imgs/3.png -------------------------------------------------------------------------------- /Tools/IDE/WebStorm/imgs/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WangXiaoJin/docs/HEAD/Tools/IDE/WebStorm/imgs/4.png -------------------------------------------------------------------------------- /Tools/IDE/WebStorm/imgs/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WangXiaoJin/docs/HEAD/Tools/IDE/WebStorm/imgs/5.png -------------------------------------------------------------------------------- /DistributedStorage/SeaweedFS.md: -------------------------------------------------------------------------------- 1 | # SeaweedFS 2 | 3 | ## 参考 4 | 5 | * [Github地址](https://github.com/chrislusf/seaweedfs) 6 | -------------------------------------------------------------------------------- /Java/Sitemesh/Sitemesh/imgs/sitemesh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WangXiaoJin/docs/HEAD/Java/Sitemesh/Sitemesh/imgs/sitemesh.png -------------------------------------------------------------------------------- /imgs/QuartzRescheduleCronJob导致立即执行原理.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WangXiaoJin/docs/HEAD/imgs/QuartzRescheduleCronJob导致立即执行原理.png -------------------------------------------------------------------------------- /DevOps/Ansible.md: -------------------------------------------------------------------------------- 1 | # Ansible 2 | 3 | ## 参考文档 4 | 5 | * [Ansible Documentation](https://docs.ansible.com/) - 【官网】 6 | * [Ansible中文权威指南](http://www.ansible.com.cn/index.html) -------------------------------------------------------------------------------- /linux/CPU.md: -------------------------------------------------------------------------------- 1 | # CPU 2 | 3 | ## 文档 4 | 5 | * [CPU高速缓存行与内存关系及并发MESI协议](https://www.cnblogs.com/jokerjason/p/9584402.html) 6 | 7 | * [Gallery of Processor Cache Effects](http://igoro.com/archive/gallery-of-processor-cache-effects/) -------------------------------------------------------------------------------- /Tools/HTTPie.md: -------------------------------------------------------------------------------- 1 | # HTTPie 2 | 3 | HTTPie is a user-friendly command-line HTTP client for the API era. It comes with JSON support, syntax highlighting, 4 | persistent sessions, wget-like downloads, plugins, and more. 5 | 6 | ## 文档 7 | 8 | * [官网](https://httpie.io/) -------------------------------------------------------------------------------- /Tools/有道.md: -------------------------------------------------------------------------------- 1 | ## 有道词典提示网络已断开 2 | 3 | 1. 可能是由于您使用代理引起的问题,关闭代理可以了; 4 | 5 | 2. 有朋友说是因为IE的脱机工作引起的,关闭脱机工作就OK了; 6 | 7 | 3. 最简单暴力的方法是设置有道词典网络连接,使用代理。 8 | 9 | 开始菜单 ==> 设置 ==> 软件设置 ==> 网络连接 ==> 勾选使用代理服务器 ==> 地址:dict.youdao.com 端口:80 ==> 点击测试,测试成功 ==> 保存设置 10 | -------------------------------------------------------------------------------- /Java/Servlet/servlet-mapping映射规则和顺序.md: -------------------------------------------------------------------------------- 1 | ## servlet-mapping映射规则和顺序 2 | 3 | 4 | 总是忘记servlet-mapping的规则,固记录两篇关于servlet-mapping映射的文章,讲的比较详细: 5 | 6 | 1. 7 | 2. -------------------------------------------------------------------------------- /Template&MarkupLanguage/YAML.md: -------------------------------------------------------------------------------- 1 | ## YAML 2 | 3 | * [YAML官方文档](https://yaml.org/spec/1.2/spec.html) 4 | * [SnakeYAML Documentation](https://bitbucket.org/snakeyaml/snakeyaml/wiki/Documentation) 5 | * [YAML 简易教程](http://www.ruanyifeng.com/blog/2016/07/yaml.html) 6 | 7 | -------------------------------------------------------------------------------- /Tools/设计/在线设计.md: -------------------------------------------------------------------------------- 1 | # 在线设计 2 | 3 | ## Excalidraw 4 | 5 | Excalidraw是一款非常轻量的在线白板工具,可以直接在浏览器打开,轻松绘制具有手绘风格的图形。 6 | 7 | > [官网](https://excalidraw.com/) 8 | 9 | ## Diagrams 10 | 11 | Security-first diagramming for teams. 12 | 13 | > [官网](https://www.diagrams.net/) -------------------------------------------------------------------------------- /DistributedStorage/GlusterFS.md: -------------------------------------------------------------------------------- 1 | # GlusterFS 2 | 3 | ## 参考 4 | 5 | * [GlusterFS分布式存储学习笔记](https://www.cnblogs.com/kevingrace/p/8709544.html) 6 | * [GlusterFS配置为K8S PersistentVolume](https://jimmysong.io/kubernetes-handbook/practice/using-glusterfs-for-persistent-storage.html) -------------------------------------------------------------------------------- /Java/Spring/Webflux.md: -------------------------------------------------------------------------------- 1 | # Webflux 2 | 3 | 4 | ## 参考文档 5 | 6 | * [Set a Timeout in Spring 5 Webflux WebClient](https://www.baeldung.com/spring-webflux-timeout) 7 | * [设置 Reactor-Netty 超时时间](https://projectreactor.io/docs/netty/release/reference/index.html#_timeout_configuration) -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | 14 | /.idea 15 | *.iml 16 | -------------------------------------------------------------------------------- /Tools/推荐网站.md: -------------------------------------------------------------------------------- 1 | # 推荐网站 2 | 3 | ## 书单网 4 | 5 | 书单网是一个非常好用的电子书搜索网站,它主要的特点是聚合了 7 个搜索网站,你可以得到 7 个网站的搜索结果。 6 | 7 | 它的界面清新简洁,没有任何多余的东西,它的使用方法非常简单,搜索速度很快,实际体验非常出色;它支持多种电子书格式, 8 | 包括:Pdf 、Mobi 、Epub 、Azw3 格式,你可以选择你需要的格式直接下载。 9 | 10 | 11 | ## 书栈网 12 | 13 | 提供各种语言的学习资料 14 | 15 | > [书栈网](https://www.bookstack.cn/) 16 | 17 | -------------------------------------------------------------------------------- /Tools/EasyPdf.md: -------------------------------------------------------------------------------- 1 | # EasyPdf 2 | 3 | EasyPdf 是一个完全免费的 PDF 转换编辑网站,它主要的特点包括:完全免费、不需要登录注册、无限制使用、保证文件的安全。 4 | 5 | 它支持无限制使用,部分功能 PDF 数量和文件大小都没有限制,部分功能只是 PDF 数量没有限制,但是 PDF 大小有 50M 的限制,你需要具体查看每个功能下面的文字描述。 6 | 7 | 它支持 OCR 文字识别功能,并且识别效果非常出色;例如 PDF 转换为 Word 功能,支持 OCR 文字识别功能,你生成的 Word 文件里面不是图片, 8 | 是 OCR 识别之后的文字,是可以进行编辑的,相信这个亮点功能应该是很多人刚需的。 9 | -------------------------------------------------------------------------------- /Tools/SCM/Svn常用.md: -------------------------------------------------------------------------------- 1 | # Svn常用 2 | 3 | ### 根据日期查询历史操作记录 4 | 5 | ```bash 6 | > svn log -vg -r{2019-06-14}:{2019-06-30T23:59:59} 7 | ``` 8 | 9 | ### 参考 10 | 11 | * [Svn详解 - 看云](https://www.kancloud.cn/i281151/svn/197162) 12 | * [Are SVNKit methods reenterable?](http://vcs.atspace.co.uk/2012/09/21/are-svnkit-methods-reenterable/) 13 | -------------------------------------------------------------------------------- /DB/Mysql/MySQL Connector Configuration.md: -------------------------------------------------------------------------------- 1 | ## MySQL Connector Configuration 2 | 3 | ### 官方文档 4 | 5 | * [Configuration Properties](https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html) 6 | * [MySQL Configuration - HikariCP建议配置](https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration) 7 | -------------------------------------------------------------------------------- /Security/Clickjacking.md: -------------------------------------------------------------------------------- 1 | ## Clickjacking 2 | 3 | * [使用`X-Frame-Options: DENY`](https://docs.spring.io/spring-security/site/docs/5.1.4.RELEASE/reference/htmlsingle/#headers-frame-options) 4 | * [Content Security Policy (CSP) - 使用此方案避免加载非法站点数据及上报异常至服务器](https://docs.spring.io/spring-security/site/docs/5.1.4.RELEASE/reference/htmlsingle/#headers-csp) -------------------------------------------------------------------------------- /Security/Session Fixation Attack.md: -------------------------------------------------------------------------------- 1 | ## Session Fixation Attack 2 | 3 | * [漏洞:会话固定攻击(session fixation attack)](https://www.jianshu.com/p/a5ed607cb48b) 4 | * [Tomcat的SessionID引起的Session Fixation和Session Hijacking问题](https://www.cnblogs.com/softidea/p/6040283.html) 5 | * [spring security防御会话伪造session攻击](https://www.cnblogs.com/wenjieyatou/p/6118585.html) 6 | -------------------------------------------------------------------------------- /Microservice/OpenServiceBrokerAPI/Open Service Broker API.md: -------------------------------------------------------------------------------- 1 | ## Open Service Broker API 2 | 3 | 4 | * [官网](https://www.openservicebrokerapi.org/) 5 | * [Specification - 官方规范](https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md) 6 | * [Translate a Docker Compose File to Kubernetes Resources](https://kubernetes.io/docs/tools/kompose/user-guide/) 7 | 8 | -------------------------------------------------------------------------------- /Proxy/Nginx/常用.md: -------------------------------------------------------------------------------- 1 | # 常用 2 | 3 | ## 常见问题 4 | 5 | ### 1. nf_conntrack: table full, dropping packet 6 | 7 | * [性能常识 [踩坑总结] nf_conntrack: table full, dropping packet](https://testerhome.com/topics/15824) 8 | * [nf_conntrack: table full, dropping packet](https://morganwu277.github.io/2018/05/26/Solve-production-issue-of-nf-conntrack-table-full-dropping-packet/) 9 | 10 | -------------------------------------------------------------------------------- /Web/JS/SourceMap.md: -------------------------------------------------------------------------------- 1 | ## SourceMap 2 | 3 | ### 参考文档 4 | 5 | * [JavaScript Source Map 详解 - 阮一峰](http://www.ruanyifeng.com/blog/2013/01/javascript_source_map.html) 6 | * [Introduction to JavaScript Source Maps - `Ryan Seddon`](https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/) 7 | * [细说 js 压缩、sourcemap、通过 sourcemap 查找原始报错信息](https://segmentfault.com/a/1190000016987829) -------------------------------------------------------------------------------- /Security/CSRF - CrossSiteRequestForgery.md: -------------------------------------------------------------------------------- 1 | ## Cross Site Request Forgery (CSRF) 2 | 3 | * [Spring Security官方诠释及例子](https://docs.spring.io/spring-security/site/docs/5.1.4.RELEASE/reference/htmlsingle/#csrf) 4 | * [浅谈CSRF(Cross-site request forgery)跨站请求伪造](https://www.cnblogs.com/liuqingzheng/p/9505044.html) 5 | * [CSRF漏洞详解,一文看懂CSRF](https://blog.csdn.net/fageweiketang/article/details/80671474) -------------------------------------------------------------------------------- /DB/DB-GUI.md: -------------------------------------------------------------------------------- 1 | # DB GUI 2 | 3 | ## franchise 4 | 5 | 简易SQL GUI,优点是可以直接解析Excel,然后执行SQL语句,把过滤出的数据导出Excel、JSON等格式。 6 | 7 | > [官方链接](https://franchise.cloud/) 8 | 9 | ## DBeaver 10 | 11 | > [官网链接](https://dbeaver.io/) 12 | 13 | ## Beekeeper Studio 14 | 15 | > [官网链接](https://www.beekeeperstudio.io/) 16 | 17 | ## Chat2DB 18 | 19 | > [官网链接](https://chat2db.opensource.alibaba.com/) 20 | 21 | -------------------------------------------------------------------------------- /Tools/图片处理/图片处理.md: -------------------------------------------------------------------------------- 1 | # 图片处理 2 | 3 | ## imgproxy 4 | 5 | * [imgproxy - Github](https://github.com/imgproxy/imgproxy) 6 | 7 | 8 | ## thumbor 9 | 10 | * [thumbor - Github](https://github.com/thumbor/thumbor) 11 | 12 | 13 | ## 参考文档 14 | 15 | * `imgproxy` vs `thumbor` vs `imaginary` vs `pilbox` vs `picfit` vs `imageproxy` - [参考连接](https://gist.github.com/DarthSim/9d971d2859f3714a29cf8ce094b3fc55) -------------------------------------------------------------------------------- /Microservice/K8S/Kompose.md: -------------------------------------------------------------------------------- 1 | ## Kompose 2 | 3 | ####Kubernetes + Compose = Kompose 4 | 5 | `Kompose`能把`Docker Compose`配置文件转换成Kubernetes(或OpenShift)所需的配置文件,同时提供了类似`Docker Compose` 6 | 的功能:`kompose up`、`kompose down`。 7 | 8 | 安装及使用文档: 9 | 10 | * [官网](http://kompose.io/) 11 | * [Translate a Docker Compose File to Kubernetes Resources](https://kubernetes.io/docs/tools/kompose/user-guide/) 12 | 13 | -------------------------------------------------------------------------------- /Tools/IDE/VisualStudio/VS.md: -------------------------------------------------------------------------------- 1 | # VS 2 | 3 | ## 配置 4 | 5 | * `工具 | 选项 | 文本编辑器` 6 | * `常规` 7 | * 启用大括号对着色 8 | * `所有语言` 9 | * 常规 - 勾选`自动换行` 10 | * 制表符 - 勾选`插入空格` 11 | 12 | * `工具 | 选项 | 环境` 13 | * `键盘` 14 | * `编辑.完成单词`(编码提示) - `Alt+右键头` 15 | * `编辑.删除行` - `Ctrl+Shift+L` 16 | 17 | ## 插件 18 | 19 | * ReSharper - 快速重构;高亮显示错误;智能提示、智能复制;便捷的导航、搜索 20 | * Output enhancer - 将output窗口的输出的文字添加颜色 21 | -------------------------------------------------------------------------------- /Tools/IDE/IDEA/IDEA terminal集成Shell.md: -------------------------------------------------------------------------------- 1 | ## IDEA Window环境terminal集成Shell 2 | 3 | IDEA的terminal可以集成Git Bash或者Cygwin,这里主要说下集成Git Bash。非常的简单。 4 | 5 | 1. 下载安装Git客户端,这个非常简单,就不详说了。 6 | 7 | 2. `File -> Settings -> Tools -> Terminal`界面`Shell path` 选项输入`"C:\Program Files\Git\bin\sh.exe" -login -i`,不要忘记引号,保存就OK了。 8 | 9 | > 注:当你系统中运行了有道词典时,且开启了“划词”功能,这时你拖动IDEA的终端时会触发一次`CTRL + C`的效果。非常让人抓狂, 10 | 这时只需要关闭有道的“划词”功能或干脆关闭有道软件即可。 11 | 12 | -------------------------------------------------------------------------------- /Java/Java-类型详解.md: -------------------------------------------------------------------------------- 1 | # Java 类型详解 2 | 3 | ## 浮点类型 4 | 5 | ### 参考文档 6 | 7 | * [浮点数的底层原理和精度损失问题](https://zhuanlan.zhihu.com/p/269619376) 8 | * [小数在内存中是如何存储的?](https://blog.51cto.com/u_10984944/2475898) 9 | * [IEEE 754 - WIKI](https://zh.wikipedia.org/wiki/IEEE_754) 10 | * [舍入误差(`round-off error`) - WIKI](https://zh.wikipedia.org/wiki/%E6%8D%A8%E5%85%A5%E8%AA%A4%E5%B7%AE) 11 | * [IEEE 754](https://docs.oracle.com/cd/E19957-01/806-3568/ncg_math.html) -------------------------------------------------------------------------------- /Java/分布式事务/ServiceCombPack.md: -------------------------------------------------------------------------------- 1 | # ServiceComb Pack 2 | 3 | Apache ServiceComb Pack is an eventually data consistency solution for micro-service applications. 4 | ServiceComb Pack currently provides TCC and Saga distributed transaction co-ordination solutions 5 | by using Alpha as a transaction coordinator and Omega as an transaction agent . 6 | 7 | 8 | ## 文档 9 | 10 | * [ServiceComb Pack](https://github.com/apache/servicecomb-pack) - GitHub -------------------------------------------------------------------------------- /Security/XSS - CrossSiteScripting.md: -------------------------------------------------------------------------------- 1 | ## Cross Site Scripting(XSS) 2 | 3 | * [详解跨站点脚本攻击(XSS)](https://lisongfeng.cn/post/xss-essentail.html) 4 | * [Web安全之 XSS 攻击与防御](https://www.jianshu.com/p/2c0e0d71e533) 5 | * [前端安全之XSS](https://www.cnblogs.com/unclekeith/p/7750681.html) 6 | * `X-XSS-Protection: 1; mode=block` 7 | * [Content Security Policy (CSP) - 使用此方案避免加载非法站点数据及上报异常至服务器](https://docs.spring.io/spring-security/site/docs/5.1.4.RELEASE/reference/htmlsingle/#headers-csp) 8 | -------------------------------------------------------------------------------- /Web/SSG/Jamstack.md: -------------------------------------------------------------------------------- 1 | # Jamstack 2 | 3 | Jamstack is an architecture designed to make the web faster, more secure, and easier to scale. It builds on many of the 4 | tools and workflows which developers love, and which bring maximum productivity. 5 | 6 | The core principles of pre-rendering, and decoupling, enable sites and applications to be delivered with greater 7 | confidence and resilience than ever before. 8 | 9 | ## 参考 10 | 11 | * [官网](https://jamstack.org/) 12 | -------------------------------------------------------------------------------- /DB/Cache/README.md: -------------------------------------------------------------------------------- 1 | # Cache 2 | 3 | ## Java缓存组件 4 | 5 | * [OHC - An off-heap-cache](https://github.com/snazy/ohc) 6 | * Why off-heap memory? 7 | * Why not use ByteBuffer.allocateDirect()? 8 | 9 | * [Ehcache](https://www.ehcache.org/) 10 | 11 | ## 文档 12 | 13 | * 数据库及缓存不一致的问题及解决思路 14 | * [问题](https://www.hollischuang.com/archives/6663) 15 | * [解决思路](https://www.hollischuang.com/archives/6681) 16 | * [老生常谈的 Redis 雪崩、击穿、穿透、预热、降级一次全安排](https://www.hollischuang.com/archives/6257) -------------------------------------------------------------------------------- /Proxy/Nginx/modules/ngx_http_random_index_module.md: -------------------------------------------------------------------------------- 1 | ## ngx_http_random_index_module介绍 2 | 3 | ##### `【原创】` 4 | --- 5 | 6 | ngx_http_random_index_module模块处理以(`/`)结尾的请求,随机选择该目录下任意文件作为index file。这个模块在`ngx_http_index_module`之前执行。开启该功能,需要在编译时增加`--with-http_random_index_module`参数。 7 | 8 | #### 例子: 9 | 10 | ```nginx 11 | location / { 12 | random_index on; 13 | } 14 | ``` 15 | 16 | ```nginx 17 | Syntax: random_index on | off; 18 | Default: random_index off; 19 | Context: location 20 | ``` 21 | -------------------------------------------------------------------------------- /DB/Cache/Redis/常用.md: -------------------------------------------------------------------------------- 1 | # 常用 2 | 3 | ## 参考文档 4 | 5 | * [Redis Transactions - spring-data-redis](https://github.com/spring-projects/spring-data-redis/blob/master/src/main/asciidoc/reference/redis-transactions.adoc) - 6 | 讲解spring-data-redis怎么使用Redis事务及怎么集成JDBC事务`@Transactional` 7 | 8 | 9 | 10 | ## Redis Client GUI 11 | 12 | * [AnotherRedisDesktopManager](https://github.com/qishibo/AnotherRedisDesktopManager/releases) - 推荐 13 | * [QuickRedis](https://github.com/quick123official/quick_redis_blog/releases) -------------------------------------------------------------------------------- /Security/Token/Token介绍.md: -------------------------------------------------------------------------------- 1 | ## Basic and Digest 2 | 3 | * [Basic and Digest Access Authentication - 【IETF官网】](https://tools.ietf.org/html/rfc2617) 4 | 5 | 6 | ## JSON Web Token 7 | 8 | * [JSON Web Token (JWT) - 【IETF官网】](https://tools.ietf.org/html/rfc7519) 9 | * [Introduction to JSON Web Tokens](https://jwt.io/introduction/) 10 | * [JSON Web Token 入门](http://www.ruanyifeng.com/blog/2018/07/json_web_token-tutorial.html) 11 | 12 | 13 | ## Bearer Token 14 | 15 | * [Bearer Token - 【IETF官网】](https://tools.ietf.org/html/rfc6750) 16 | -------------------------------------------------------------------------------- /Java/Spring/SpringCloud/CircuitBreaker.md: -------------------------------------------------------------------------------- 1 | # Circuit Breaker 2 | 3 | ## resilience4j 4 | 5 | * [官方文档](https://resilience4j.readme.io/docs) 6 | * [集成 SpringBoot2](https://resilience4j.readme.io/docs/getting-started-3) 7 | 8 | ## Spring Cloud Circuit Breaker 9 | 10 | * [Spring Cloud Circuit Breaker](https://docs.spring.io/spring-cloud-circuitbreaker/docs/current/reference/html/) 11 | * [Spring Cloud Circuit Breaker - spring-cloud-commons](https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#spring-cloud-circuit-breaker) -------------------------------------------------------------------------------- /Java/Java-Mapping-Framework.md: -------------------------------------------------------------------------------- 1 | # Java Mapping Framework 2 | 3 | ## 1. MapStruct 4 | 5 | > 推荐 6 | 7 | ## 2. ModelMapper 8 | 9 | ## 3. Jackson 10 | 11 | ## 4. Apache Commons BeanUtils 12 | 13 | ## 5. Spring BeanUtils 14 | 15 | 16 | ## 文档 17 | 18 | * [Performance of Java Mapping Frameworks](https://www.baeldung.com/java-performance-mapping-frameworks) 19 | * Dozer 20 | * Orika 21 | * MapStruct 22 | * ModelMapper 23 | * JMapper 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Test/压测工具.md: -------------------------------------------------------------------------------- 1 | # 压测工具 2 | 3 | 4 | ## ab - Apache Bench 5 | 6 | 上传文件 7 | ```shell script 8 | # 安装 9 | > apk add apache2-utils 10 | # 压测 11 | > ab -n 100 -c 100 -s 120 -T 'application/octet-stream' -H 'X-Secret-Key: 7f84dac9d1e74a5fb235dfa8a41be8e0' -p xxx.jar http://localhost:8080/upload 12 | ``` 13 | 14 | 15 | ## wrk - a HTTP benchmarking tool 16 | 17 | * [github地址](https://github.com/wg/wrk) 18 | 19 | 20 | ## File system 21 | 22 | * [File system Performance Benchmarking](https://docs.gitlab.com/ee/administration/operations/filesystem_benchmarking.html) 23 | * fio 24 | * 系统自带建议功能 -------------------------------------------------------------------------------- /学科/数学.md: -------------------------------------------------------------------------------- 1 | # 数学 2 | 3 | ## 常用 4 | 5 | * [三角函数六边形记忆法](https://zhuanlan.zhihu.com/p/162297688) - `sec`/`tan`/`sin`/`cos`/`cot`/`csc` 6 | * [三角函数公式汇总](https://zhuanlan.zhihu.com/p/390928056) 7 | * 极限/微分/积分 8 | * [极限-常用等价无穷小推导](https://zhuanlan.zhihu.com/p/463746935) 9 | * [基本初等函数导数推导](https://zhuanlan.zhihu.com/p/89843248) 10 | * [不定积分与定积分有什么区别?](https://www.zhihu.com/question/29210349) 11 | * [二元复合函数求导(偏导)的运算法则的证明](https://zhuanlan.zhihu.com/p/85147199) 12 | * [不定积分大集合——方法篇](https://zhuanlan.zhihu.com/p/337382736) 13 | * [不定积分大集合——技巧篇(十分详细)](https://zhuanlan.zhihu.com/p/339728442) 14 | 15 | 16 | -------------------------------------------------------------------------------- /Tools/IDE/Eclipse/Eclipse常用配置及插件.md: -------------------------------------------------------------------------------- 1 | ## IDEA常用配置及插件 2 | 3 | ### 快捷键 4 | 5 | ### 常用配置 6 | 7 | * 创建Java类,自动生成`@author`/`@date` JavaDoc 8 | 9 | `Window | Preferences | Java | Code Style | Code Templates | Comments | Types | Edit` 10 | 11 | 配置内容如下: 12 | 13 | ``` 14 | /** 15 | * @author ${user} 16 | * @date ${d:date('yyyy-MM-dd HH:mm')} 17 | * 18 | * ${tags} 19 | */ 20 | ``` 21 | 22 | > 注:勾选`Automatically add comments for new methods and types`,让创建类时自动生成。 23 | 24 | ### Plugins 25 | 26 | * CheckStyle-IDEA - CheckStyle 27 | * SonarLint 28 | 29 | -------------------------------------------------------------------------------- /Java/JdbcConnectionPool/HikariCP.md: -------------------------------------------------------------------------------- 1 | # HikariCP 2 | 3 | * `HikariConfig.validateNumerics()`方法用于验证各个配置项,配置的不合理会自动调整 4 | 5 | ### 官方文档 6 | 7 | * [配置详解](https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby) 8 | * [MBean (JMX) Monitoring and Management](https://github.com/brettwooldridge/HikariCP/wiki/MBean-(JMX)-Monitoring-and-Management) 9 | * [MySQL Configuration - HikariCP建议配置](https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration) 10 | * [Configuration Properties - MySQL官方详细配置](https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html) 11 | 12 | -------------------------------------------------------------------------------- /Algorithm/算法.md: -------------------------------------------------------------------------------- 1 | # 算法 2 | 3 | ## 1. 压缩算法 4 | 5 | ### zstd(Zstandard) 6 | 7 | ### lz4 8 | 9 | ### snappy 10 | 11 | ### gzip 12 | 13 | ### zlib 14 | 15 | ## 2. 负载均衡算法 16 | 17 | ### 权重平滑轮询算法 18 | 19 | * [nginx平滑的基于权重轮询算法分析 - tenfy](https://tenfy.cn/2018/11/12/smooth-weighted-round-robin/) 20 | 21 | ## 3. TDigest 算法 22 | 23 | TDigest是一个简单,快速,精确度高,可并行化的近似百分位算法,被Spark,ES,Kylin等系统使用。 24 | 25 | * [T-Digest 概念簡介](https://op8867555.github.io/posts/2018-04-09-tdigest.html) 26 | * [ElasticSearch 如何使用 TDigest 算法计算亿级数据的百分位数](https://blog.csdn.net/csdnnews/article/details/116246540) 27 | * 开源实现:https://github.com/tdunning/t-digest -------------------------------------------------------------------------------- /Java/JLine/JLine3.md: -------------------------------------------------------------------------------- 1 | # JLine3 2 | 3 | ## 简介 4 | 5 | JLine is a Java library for handling console input. It is similar in functionality to 6 | [BSD editline](http://www.thrysoee.dk/editline/) and [GNU readline](http://www.gnu.org/s/readline/) 7 | but with additional features that bring it in par with 8 | [ZSH line editor](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html). People familiar with 9 | the readline/editline capabilities for modern shells (such as bash and tcsh) will find most of the 10 | command editing features of JLine to be familiar. 11 | 12 | ## 文档 13 | 14 | * [官网](https://github.com/jline/jline3/wiki) 15 | -------------------------------------------------------------------------------- /Terms/术语.md: -------------------------------------------------------------------------------- 1 | # 术语 2 | 3 | ## 参考 4 | 5 | * CAP 6 | * [CAP theorem](https://en.wikipedia.org/wiki/CAP_theorem) 7 | * [CAP 定理的含义](https://www.ruanyifeng.com/blog/2018/07/cap.html) 8 | 9 | * 异或 10 | * [如何理解「异或」的含义?](https://www.zhihu.com/question/31116687) 11 | 12 | * RAID 13 | * [RAID详解[RAID0/RAID1/RAID5]](https://www.cnblogs.com/klb561/p/9218455.html) 14 | * [RAID6与RAID5数据安全性对比](https://support.huawei.com/enterprise/zh/knowledge/EKB1000149118) 15 | 16 | * 纠删码 - Erasure Code 17 | * [纠删码 Erasure Code](https://zhuanlan.zhihu.com/p/69374970) 18 | 19 | * [4K对齐 - 磁盘分区](https://zhuanlan.zhihu.com/p/34816922) 20 | -------------------------------------------------------------------------------- /Java/Spring/SpringCloud/限流.md: -------------------------------------------------------------------------------- 1 | # 限流 2 | 3 | ## resilience4j-ratelimiter 4 | 5 | * [官方文档](https://resilience4j.readme.io/docs/ratelimiter) 6 | 7 | ## Bucket4j 8 | 9 | Bucket4j is a Java rate-limiting library that is mainly based on the token-bucket algorithm. 10 | 11 | * [官方文档](https://bucket4j.com/8.1.0/toc.html) 12 | * [Rate Limiting a Spring API Using Bucket4j](https://www.baeldung.com/spring-bucket4j) 13 | 14 | ## Sentinel 15 | 16 | * [官方文档](https://sentinelguard.io/zh-cn/docs/introduction.html) 17 | 18 | ## Traefik RateLimit 19 | 20 | * [文档](https://doc.traefik.io/traefik/v2.0/middlewares/ratelimit/) 21 | 22 | ## Guava RateLimiter 23 | 24 | ## Redisson RateLimiter 25 | -------------------------------------------------------------------------------- /Web/ServerPush-WebSocket.md: -------------------------------------------------------------------------------- 1 | # ServerPush-WebSocket 2 | 3 | ## 参考文献 4 | 5 | * [Spring MVC 3.2 Preview: Techniques for Real-time Updates](https://spring.io/blog/2012/05/08/spring-mvc-3-2-preview-techniques-for-real-time-updates/) 6 | * Traditional Polling 7 | * Long Polling 8 | * HTTP Streaming 9 | * WebSocket Protocol 10 | * [How HTML5 Web Sockets Interact With Proxy Servers](https://www.infoq.com/articles/Web-Sockets-Proxy-Servers/) 11 | * Explain how HTML5 Web Sockets interact with proxy servers, load balancing routers, and firewalls. 12 | * [WebSocket API](https://www.w3.org/TR/websockets) 13 | * [WebSocket protocol](https://tools.ietf.org/html/rfc6455) 14 | -------------------------------------------------------------------------------- /Template&MarkupLanguage/Template/常用.md: -------------------------------------------------------------------------------- 1 | # 常用 2 | 3 | ## 模板引擎 4 | 5 | ### [handlebars.java](https://github.com/jknack/handlebars.java) 6 | 7 | Logic-less and semantic Mustache templates with Java 8 | 9 | 10 | ### [MVEL](http://mvel.documentnode.com/) 11 | 12 | MVEL has largely been inspired by Java syntax, but has some fundamental differences aimed at making it more efficient 13 | as an expression language, such as operators that directly support collection, array and string matching, as well 14 | as regular expressions. MVEL is used to evaluate expressions written using Java syntax. 15 | 16 | 17 | 18 | ## 文档 19 | 20 | * [spring-comparing-template-engines - Spring集成各模板引擎性能对比](https://github.com/jreijn/spring-comparing-template-engines) 21 | -------------------------------------------------------------------------------- /CodeStyle/阿里规范.md: -------------------------------------------------------------------------------- 1 | ## 阿里规范 2 | 3 | ### 文档 4 | 5 | * [P3C-PMD](https://github.com/alibaba/p3c/tree/master/p3c-pmd) 6 | * [Eclipse插件使用文档](https://github.com/alibaba/p3c/wiki/Eclipse%E6%8F%92%E4%BB%B6%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3) 7 | * [IDEA插件使用文档](https://github.com/alibaba/p3c/wiki/IDEA%E6%8F%92%E4%BB%B6%E4%BD%BF%E7%94%A8%E6%96%87%E6%A1%A3) 8 | 9 | ### 参考链接 10 | * [扩展阿里巴巴Java开发规约插件](http://www.wuqingjian.org/2018/01/29/%E6%89%A9%E5%B1%95%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4Java%E5%BC%80%E5%8F%91%E8%A7%84%E7%BA%A6%E6%8F%92%E4%BB%B6/) 11 | * [sonar-pmd 插件添加 P3C 支持](http://younian.net.cn/article/143) 12 | * [sonar-p3c-pmd -【参考】](https://github.com/mrprince/sonar-p3c-pmd) 13 | * [Eclipse导入P3C CodeStyle](https://blog.csdn.net/byzh4/article/details/79478494) 14 | 15 | -------------------------------------------------------------------------------- /DistributedStorage/选型.md: -------------------------------------------------------------------------------- 1 | # 选型 2 | 3 | ## 参考 4 | 5 | * [分布式文件系统对比与选型参考 - GFS/HDFS/Ceph/Lustre/MooseFS/MogileFS/FastDFS/GlusterFS/TFS/GridFS](https://blog.csdn.net/yym373872996/article/details/105650908) 6 | 7 | * [对象存储方案选型 - Ceph/Minio/Hadoop Ozone/HBase MOB](https://zhuanlan.zhihu.com/p/138249069) 8 | 9 | * [聊一聊分布式对象存储解决方案 - Swift/Ceph/Minio](https://cloud.tencent.com/developer/article/1488461) 10 | 11 | * [分布式文件存储 MinIO/SeaweedFS/FastDFS 对比总结](http://blog.zollty.com/b/archive/comparison-of-distributed-file-storage-MinIO-SeaweedFS-FastDFS.html) 12 | 13 | * [ceph rgw VS minio VS swift](http://aspirer.wang/?p=1514) 14 | 15 | * [Ceph vs Swift - 架构剖析](http://dockone.io/article/410) 16 | 17 | * [分布式文件系统架构对比 - GlusterFS/CephFS/GFS/HDFS/MooseFS/JuiceFS](https://juejin.im/entry/6844903630991032327) -------------------------------------------------------------------------------- /Java/分布式事务/总览.md: -------------------------------------------------------------------------------- 1 | # 总览 2 | 3 | ## Hmily 4 | 5 | Hmily是一款高性能,零侵入,金融级分布式事务解决方案,目前主要提供柔性事务的支持,包含 TCC, TAC(自动生成回滚SQL) 方案,未来还会支持 XA 等方案。 6 | 7 | * [官网](https://dromara.org/zh/projects/hmily/overview/) 8 | 9 | ## 文档 10 | 11 | * [分布式事务最经典的七种解决方案](https://segmentfault.com/a/1190000040321750) 12 | * 两阶段提交/XA (eXtended Architecture) 13 | * SAGA 14 | * TCC (Try-Confirm-Cancel) 15 | * 本地消息表 16 | * 事务消息 17 | * 二阶段消息 18 | * AT事务模式 (Automatic Transaction) 19 | * [两天,我把分布式事务搞完了](https://jishuin.proginn.com/p/763bfbd2df6b) 20 | * 2PC 21 | * 3PC 22 | * XA 23 | * TCC 24 | * 本地消息表 25 | * 事务消息 26 | * Seata 27 | * MySQL XA 28 | * [XA Transactions 官方文档](https://dev.mysql.com/doc/refman/8.0/en/xa.html) 29 | * [MySQL对分布式事务(XA Transactions)的支持](http://www.asktheway.org/2020/04/26/266/) -------------------------------------------------------------------------------- /Java/Thread/ThreadLocal.md: -------------------------------------------------------------------------------- 1 | # ThreadLocal 2 | 3 | ## Transmittable ThreadLocal(TTL) 4 | 5 | 三种解决方案: 6 | 1. 修饰Runnable和Callable 7 | 2. 修饰线程池 8 | 3. 使用Java Agent来修饰JDK线程池实现类 9 | 10 | * [TTL - Github主页](https://github.com/alibaba/transmittable-thread-local) 11 | * TTL Agent与其它Agent(如Skywalking、Promethues)配合使用时不生效? 12 | 13 | * [需求场景](https://github.com/alibaba/transmittable-thread-local/blob/master/docs/requirement-scenario.md) 14 | * 分布式跟踪系统 15 | * 日志收集记录系统上下文 16 | * Log4j2 MDC的TTL集成 17 | * Logback MDC的TTL集成 18 | * Session级Cache 19 | * 应用容器或上层框架跨应用代码给下层SDK传递信息 20 | 21 | 22 | ## 参考链接 23 | 24 | * [ThreadLocal垮线程池传递数据解决方案:TransmittableThreadLocal【享学Java】](https://cloud.tencent.com/developer/article/1600754) 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Tools/IDE/WebStorm/WebStorm调试Grunt.md: -------------------------------------------------------------------------------- 1 | ## WebStorm调试Grunt 2 | 3 | ##### `【原创】` :heart_eyes: 4 | --- 5 | 6 | 最近刚玩NodeJS,选择了WebStorm作为开发工具。用的是最新版的WebStorm。本来想进入Debug模式看看源码的属性值及代码逻辑的,妹的,立马碰到了两个问题: 7 | 1、怎么开启Grunt Debug模式 8 | 2、进入Debug模式后,发现modules下的lib源码打了断点后,Debug模式的step over尽然没用 - -! 也是醉了 9 | 10 | ###解决方案 11 | 12 | 1. **进入Grunt Debug模式:** 13 | 14 | 在WebStorm的右上角点击Edit Configurations 15 | 16 | ![](imgs/1.png) 17 | 18 | 在弹出框中点击“+”按钮,选择Grunt.js 19 | 20 | ![](imgs/2.png) 21 | 22 | 输入Name、Tasks等属性 23 | 24 | ![](imgs/3.png) 25 | 26 | 上面的操作干完后,点击`小虫子`图标,恭喜你已经进入debug模式 27 | 28 | 2. **解决step over:** 29 | 30 | 当你进入Debug模式且在lib源码库打了个断点,你会遇到个很蛋疼的问题,`Step Over`、`Step Into`、`Step Out`都没用了,只有`Force Step Into`选项还有用。不知道WebStorm的团队是为了性能考虑还是为了用户体验考虑,才默认关闭这个功能。这咱先不管,也不想管。直接上解决方案 31 | 32 | 选择Settings选项卡 33 | 34 | ![](imgs/4.png) 35 | 36 | 不用勾选`Do not step into library scripts`选项 37 | 38 | ![](imgs/5.png) 39 | -------------------------------------------------------------------------------- /Tools/设计/TextCodeDesignTools.md: -------------------------------------------------------------------------------- 1 | # Text Code Design Tools 2 | 3 | ## Kroki 4 | 5 | Kroki provides a unified API with support for BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag, PacketDiag, RackDiag), BPMN, 6 | Bytefield, C4 (with PlantUML), Ditaa, Erd, Excalidraw, GraphViz, Mermaid, Nomnoml, Pikchr, PlantUML, SvgBob, UMLet, Vega, 7 | Vega-Lite, WaveDrom... and more to come! 8 | 9 | > [Kroki](https://kroki.io/) 10 | 11 | 12 | ## Mermaid 13 | 14 | Mermaid lets you create diagrams and visualizations using text and code. 15 | 16 | It is a Javascript based diagramming and charting tool that renders Markdown-inspired text definitions to create and modify diagrams dynamically. 17 | 18 | > [Mermaid](https://mermaid-js.github.io/mermaid/#/) 19 | 20 | 21 | ## PlantUML 22 | 23 | > [PlantUML](https://plantuml.com/zh/) 24 | 25 | 26 | ## KaTeX 27 | 28 | 函数生成JS库 29 | 30 | > [KaTeX](https://katex.org/) 31 | 32 | -------------------------------------------------------------------------------- /Tools/文档工具.md: -------------------------------------------------------------------------------- 1 | # Office办公软件 2 | 3 | ## 1. 在线文档编辑 4 | 5 | ### OnlyOffice 6 | 7 | ### Collabora Online 8 | 9 | * [官网](https://www.collaboraoffice.com/) 10 | * [SDK文档](https://sdk.collaboraonline.com/contents.html) 11 | 12 | ### LibreOffice 13 | 14 | ### WPS Online 15 | 16 | ## 2. Word模板 17 | 18 | ### Poi-tl 19 | 20 | ## 3. 文档转换工具 21 | 22 | ### Gotenberg 23 | 24 | Gotenberg provides a developer-friendly API to interact with powerful tools like Chromium and LibreOffice 25 | for converting numerous document formats (HTML, Markdown, Word, Excel, etc.) into PDF files, and more! 26 | 27 | ### JODConverter 28 | 29 | JODConverter, the Java OpenDocument Converter, converts documents between different office formats. 30 | It leverages Apache OpenOffice or LibreOffice, which provide arguably the best free import/export filters 31 | for OpenDocument and Microsoft Office formats available today. 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /网络传输协议/网络传输协议.md: -------------------------------------------------------------------------------- 1 | # 网络传输协议 2 | 3 | ## RSocket 4 | 5 | RSocket is an application protocol providing [Reactive Streams](http://www.reactive-streams.org/) semantics over an asynchronous, binary boundary. 6 | 7 | It enables the following symmetric interaction models via async message passing over a single connection: 8 | 9 | * request/response (stream of 1) 10 | * request/stream (finite/infinite stream of many) 11 | * fire-and-forget (no response) 12 | * channel (bi-directional streams) 13 | 14 | It also supports connection resumption to allow resuming long-lived streams across different transport connections. 15 | This is particularly useful for mobile<->server communication when network connections drop, switch, and reconnect frequently. 16 | 17 | 18 | ## TCP 19 | 20 | * [超超超详细讲解TCP三次握手与四次挥手(大图解),值得收藏](https://zhuanlan.zhihu.com/p/591865232) 21 | * [一文彻底搞懂 TCP三次握手、四次挥手过程及原理](https://zhuanlan.zhihu.com/p/108504297) 22 | 23 | -------------------------------------------------------------------------------- /linux/发送邮件.md: -------------------------------------------------------------------------------- 1 | ## 发送邮件 2 | 3 | > 注:此测试基于CentOS release 6.7 (Final) 4 | 5 | 发送邮件方式有几种: 6 | 7 | 1. 直接通过`mail`命令发送邮件 8 | 邮件的发件人格式为:`登录的用户`@`本机hostname`。邮件服务商可能会把它视为垃圾邮件来处理,想解决此问题,需要配的东西太多,懒得动。 9 | 10 | ```bash 11 | # 此邮件会被视为垃圾邮件 12 | shell> echo 'This is mail content.' | mail -s 'mail subject' xxx@qq.com 13 | ``` 14 | 15 | 可以通过`-S from=`来修改邮件发送方的显示名,单这根本改变不了被视为垃圾邮件的命运。 16 | 17 | ```bash 18 | shell> echo 'This is mail content.' | mail -s 'mail subject' -S from=xjwang@qq.com xxx@qq.com 19 | ``` 20 | 21 | 2. 使用外部SMTP服务发送邮件(如公司的邮件服务器),方便,快捷,更不会被视为垃圾邮件。 22 | 23 | ```bash 24 | shell> vim /etc/mail.rc 25 | # 添加如下配置 26 | set from=111@xxx.com smtp=mail.xxx.com 27 | set smtp-auth-user=111@xxx.com smtp-auth-password=password smtp-auth=login 28 | ``` 29 | 30 | **说明:** 31 | **from** 显示的发送方的邮件地址 32 | **smtp** 外部smtp服务器的地址 33 | **smtp-auth-user** 外部smtp服务器认证的用户名 34 | **smtp-auth-password** 外部smtp服务器认证的用户密码 35 | **smtp-auth** 邮件认证的方式 36 | 37 | > 添加好配置后,直接调用上面的mail发送邮件就OK了。 38 | -------------------------------------------------------------------------------- /Java/Spring/SpringMVC.md: -------------------------------------------------------------------------------- 1 | # Spring MVC 2 | 3 | ## 集成Freemarker 4 | 5 | * 查看Freemarker所有可用的变量 6 | * `AbstractView#render()` - 配置了`exposePathVariables`/`staticAttributes`/`requestContextAttribute` 7 | * `AbstractTemplateView#renderMergedOutputModel()` - 配置了`exposeRequestAttributes`/`exposeSessionAttributes`/`exposeSpringMacroHelpers` 8 | * `FreeMarkerView#doRender()` - 注入了`JspTaglibs`/`Session`/`Application`/`Request`/`RequestParameters`等对象 9 | 10 | * Freemarker获取变量值顺序如下,直到找到位置。参考:`freemarker.ext.servlet.AllHttpScopesHashModel#get(key)` 11 | 1. 从`Mvc Model`中获取 12 | 2. 通过`request.getAttribute(key)`获取 13 | 3. 通过`session.getAttribute(key)`获取 14 | 4. 通过`context.getAttribute(key)`获取 15 | 5. 还没找到则返回`null` 16 | 17 | ## `ForwardedHeaderFilter` 18 | 19 | 从请求头中提取 `Forwarded` 、`X-Forwarded-*` 值, 用于 `getServerName()`、`getServerPort()`、`getScheme()`、`isSecure()` 20 | 从对应的 `Forwarded` 头信息中获取,且 `sendRedirect(String)` 也会从`Forwarded`中取相关信息。 21 | 22 | > 用于代理更改了域名相关信息的场景,此时应用通过上面方法获取的信息与浏览器最初的请求信息不一致。通过 `ForwardedHeaderFilter` 可解决此问题。 23 | -------------------------------------------------------------------------------- /Tools/Xterm/MobaXterm.md: -------------------------------------------------------------------------------- 1 | # MobaXterm 2 | 3 | Enhanced terminal for Windows with X11 server, tabbed SSH client, network tools and much more. 4 | 5 | ## 安装 6 | 7 | 进入 [下载](https://mobaxterm.mobatek.net/download-home-edition.html) 页面下载` MobaXterm Portable`免安装版本。 8 | 9 | ## 配置 10 | 11 | 点击 `Settings` -> `Configuration` 12 | 13 | ### 1. 配置 Password 14 | 15 | `General` -> `MobaXterm passwords management` -> 选择`Credentials` Tab -> 点击`New`添加用户 -> 点击`OK` 16 | 17 | * `Name` - 表示此用户的标识名 18 | * `Username` - 连接目标地址的用户名 19 | * `Password` - 连接目标地址的密码 20 | 21 | > 注:添加用户后,新建Session时可以选择已添加的用户,而无需再输入用户名、密码。 22 | 23 | > 注:下面的`Master Password settings`是配置整个软件的密码。 24 | 25 | ### 2. 修改 Session 默认配置 26 | 27 | `General` -> `Edit my sessions presets` -> `SSH` 28 | 29 | * `Specify username` -> 选择默认用户,使用此用户连接SSH 30 | * `Advanced SSH settings` -> 勾选`Follow SSH path` - 作用:当终端进入另一个目录时,SFTP会自动跟随。 31 | * `Advanced SSH settings` -> 勾选`Use private key` - 作用:尝试使用此私钥连接SSH 32 | 33 | ### 3. 配置SSH默认登录用户名 34 | 35 | `SSH` -> `SSH settings` -> Default login - 作用:`Specify username`功能的备选功能,只起到简化输入用户名 36 | -------------------------------------------------------------------------------- /Template&MarkupLanguage/Template/Freemarker.md: -------------------------------------------------------------------------------- 1 | # Freemarker 2 | 3 | ### 总结 4 | 5 | * 不存在值检测操作符: 6 | * `unsafe_expr??` 7 | * `(unsafe_expr)??` 8 | * `exp1?exists` - 已废弃 9 | 10 | * escape 11 | * escape directive:[`escape`, `noescape`](http://freemarker.foofun.cn/ref_directive_escape.html) 12 | * escape sequences:[字符窜](http://freemarker.foofun.cn/dgui_template_exp.html#dgui_template_exp_direct_string) 13 | * escaping 14 | * output: [html](http://freemarker.foofun.cn/ref_builtins_string.html#ref_builtin_html), 15 | [rtf](http://freemarker.foofun.cn/ref_builtins_string.html#ref_builtin_rtf), 16 | [xhtml](http://freemarker.foofun.cn/ref_builtins_string.html#ref_builtin_xhtml), 17 | [xml](http://freemarker.foofun.cn/ref_builtins_string.html#ref_builtin_xml) 18 | * URL: [url](http://freemarker.foofun.cn/ref_builtins_string.html#ref_builtin_url) 19 | * URL path: [url_path](http://freemarker.foofun.cn/ref_builtins_string.html#ref_builtin_url_path) 20 | 21 | ### 文档 22 | 23 | * [Freemarker中文官方手册](http://freemarker.foofun.cn/) 24 | -------------------------------------------------------------------------------- /Proxy/Nginx/modules/ngx_http_index_module.md: -------------------------------------------------------------------------------- 1 | ## ngx_http_index_module介绍 2 | 3 | ##### `【原创】` 4 | --- 5 | 6 | ngx_http_index_module模块处理以(`/`)结尾的请求。这些请求也能被`ngx_http_autoindex_module`和`ngx_http_random_index_module`处理。注:三个模块的处理顺序是 `ngx_http_random_index_module` --> `ngx_http_index_module` --> `ngx_http_autoindex_module` 7 | 8 | #### 例子: 9 | 10 | ```nginx 11 | location / { 12 | index index.$geo.html index.html index.htm; 13 | } 14 | ``` 15 | 16 | ```nginx 17 | Syntax: index file ...; 18 | Default: index index.html; 19 | Context: http, server, location 20 | ``` 21 | 22 | index指令的值是按照顺序查找的。index最后一个参数可以使用绝对路径:`/index.html` 23 | ```nginx 24 | location /test { 25 | index index.htm /index.html; 26 | } 27 | ``` 28 | 29 | **注:**index指令实际上会产生一个内部跳转请求(`internal redirect`),`internal redirect`可以跳转到另一个`location`。例: 30 | 31 | ```nginx 32 | location = / { 33 | default_type text/plain; 34 | index index_eq.html; 35 | #echo deng; 36 | } 37 | location / { 38 | default_type text/plain; 39 | #index index.html; 40 | echo xiegang; 41 | } 42 | ``` 43 | 上面的例子会返回`xiegang`,而不会返回index_eq.html页面。分析:当请求`http://localhost`时首先会被`location = /`捕获到,然后请求`/index_eq.html`,`/index_eq.html`的请求会被`location /`捕捉到,此时返回`xiegang`内容。 -------------------------------------------------------------------------------- /Java/Sitemesh/Sitemesh/自由控制body页的代码片段.md: -------------------------------------------------------------------------------- 1 | ## 自由控制body页的代码片段 2 | 3 | 当碰到下图这种情况时,你需要考虑把私有JS挪动到公用JS后面。因为私有JS依赖于通用JS,而JS又是按照先后顺序执行的,所以运行私有JS会报错: 4 | 5 | ![](./imgs/sitemesh.png) 6 | 7 | 1. 第一个方案是把所有的私有JS都放到app.js里(名字随意取),然后把app.js放到通用JS后面。这是最垃圾的做法,建议不要使用。 8 | 9 | 2. 如果你用的是sitemesh2的话,有一种方案可以帮你,网上很难找到相关的资料,不看源码很才知道有这种解决方案的。 10 | 11 | **body页面** 12 | 13 | ```html 14 | 15 | 16 | XXX 17 | 18 | 19 | ...... 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 33 | ``` 34 | 35 | **装饰页面** 36 | 37 | ```html 38 | 39 | 40 | <decorator:title /> 41 | 42 | 43 | 44 | ...... 45 | 46 | 47 | 48 | 49 | 50 | ``` 51 | 52 | > content标签的tag名随意取,只要确保装饰页面的decorator:getProperty标签里面的值于其相同就行 53 | 54 | 3. 如果你使用的是sitemesh3的话,还有另一种解决方案,就是自定义标签,可以达到同样的效果。这种网上例子比较多,就不列举了。 55 | 56 | -------------------------------------------------------------------------------- /Microservice/Docker/Docker常用.md: -------------------------------------------------------------------------------- 1 | # Docker常用 2 | 3 | ### 删除所有的 ``(dangling) 镜像 4 | 5 | ```bash 6 | > docker rmi $(docker images -f "dangling=true" -q) 7 | ``` 8 | [参考文档](https://docs.docker.com/engine/reference/commandline/images/) 9 | 10 | ### Docker - Import/export/load/save 11 | * [Docker — Import vs load](https://medium.com/bb-tutorials-and-thoughts/docker-import-vs-load-91d418f0073c) 12 | * [Docker — export vs save](https://medium.com/bb-tutorials-and-thoughts/docker-export-vs-save-7053504546e5) 13 | 14 | ### gosu 15 | 16 | > [为什么你应该在docker 中使用gosu?](https://zhuanlan.zhihu.com/p/151915585) 17 | > [Docker using gosu vs USER](https://stackoverflow.com/questions/36781372/docker-using-gosu-vs-user) 18 | 19 | ### 搜索 alpine 指令和安装包依赖关系 20 | 21 | > [alpine指令和安装包依赖关系](https://pkgs.alpinelinux.org/contents) 22 | 23 | 24 | ### Watchtower 25 | 26 | With watchtower you can update the running version of your containerized app simply by pushing a new image to the 27 | Docker Hub or your own image registry. Watchtower will pull down your new image, gracefully shut down your existing 28 | container and restart it with the same options that were used when it was deployed initially. 29 | 30 | > [官网](https://containrrr.dev/watchtower/) 31 | -------------------------------------------------------------------------------- /Proxy/Nginx/modules/ngx_http_autoindex_module.md: -------------------------------------------------------------------------------- 1 | ## ngx_http_autoindex_module介绍 2 | 3 | ##### `【原创】` 4 | --- 5 | 6 | ngx_http_autoindex_module模块处理以(`/`)结尾的请求,显示该目录下的文件列表。当`ngx_http_index_module`没有找到index file时,才会执行此功能。 7 | 8 | #### 例子: 9 | 10 | ```nginx 11 | location / { 12 | autoindex on; 13 | autoindex_exact_size off; 14 | } 15 | ``` 16 | 17 | 命令参考手册 18 | --- 19 | 20 | ```nginx 21 | Syntax: autoindex on | off; 22 | Default: autoindex off; 23 | Context: http, server, location 24 | ``` 25 | 开启、关闭文件列表功能 26 | 27 | ```nginx 28 | Syntax: autoindex_exact_size on | off; 29 | Default: autoindex_exact_size on; 30 | Context: http, server, location 31 | ``` 32 | 供`autoindex_format=html`使用。指定文件是否以`B`准备的显示文件大小。当关闭此功能后,文件将会转换成近似的`KB`/`MB`/`GB`格式。 33 | 34 | ```nginx 35 | Syntax: autoindex_format html | xml | json | jsonp; 36 | Default: autoindex_format html; 37 | Context: http, server, location 38 | #This directive appeared in version 1.7.9. 39 | ``` 40 | 设置目录列表的格式。当指定jsonp时需要传有callback参数,不指定callback参数或为空值时将被当做json格式。当你想要输出xml格式时可以考虑使用`ngx_http_xslt_module`模块。 41 | 42 | ```nginx 43 | Syntax: autoindex_localtime on | off; 44 | Default: autoindex_localtime off; 45 | Context: http, server, location 46 | ``` 47 | 供`autoindex_format=html`使用。确定文件的时间属性是以`本地时间格式`还是`UTC`显示。 48 | 49 | -------------------------------------------------------------------------------- /CodeStyle/Jacoco.md: -------------------------------------------------------------------------------- 1 | ## Jacoco 2 | 3 | #### Jacoco 4 | 5 | * Jacoco统计维度:[官方解释 - 重要](https://www.jacoco.org/jacoco/trunk/doc/counters.html) 6 | * Instructions (C0 Coverage) 7 | * Branches (C1 Coverage) 8 | * Cyclomatic Complexity 9 | * Lines 10 | * Methods 11 | * Classes 12 | 13 | * 文档 14 | * [官网地址](https://www.jacoco.org/index.html) 15 | * [下载地址](https://www.jacoco.org/jacoco/index.html) 16 | * [Jacoco官方文档](https://www.jacoco.org/jacoco/trunk/doc/) 17 | * [各种方式集成Jacoco](https://www.jacoco.org/jacoco/trunk/doc/integrations.html) 18 | * [Java API](https://www.jacoco.org/jacoco/trunk/doc/api.html) 19 | * [Ant](https://www.jacoco.org/jacoco/trunk/doc/ant.html) 20 | * [Maven](https://www.jacoco.org/jacoco/trunk/doc/maven.html) 21 | * 使用`mvn help:describe -Dplugin=org.jacoco:jacoco-maven-plugin -Ddetail`查看帮助信息 22 | * 使用`mvn jacoco:help -Ddetail=true -Dgoal=`查看帮助信息 23 | * 其他 24 | 25 | 26 | #### Eclipse集成EclEmma 27 | 28 | * [官方文档](https://www.jacoco.org/installation.html) 29 | * [文件显示代码覆盖率标识 - 重要](https://www.jacoco.org/userdoc/decorators.html) 30 | 31 | #### IDEA默认已支持Code Coverage 32 | 33 | * [IDEA Code Coverage使用文档 - 官网](https://www.jetbrains.com/help/idea/code-coverage.html) 34 | 35 | 36 | -------------------------------------------------------------------------------- /Java/Servlet/Servlet-常用.md: -------------------------------------------------------------------------------- 1 | # Servlet-常用 2 | 3 | ## 文件上传 4 | 5 | * tomcat在处理`javax.servlet.http.HttpServletRequest`参数之前会执行`org.apache.catalina.connector.Request.parseParameters()`, 6 | 此方法里面包含了解析`multipart/form-data`逻辑,此逻辑会把请求体中的文件数据存到临时目录中,并把相关信息保存至`javax.servlet.http.Part` 7 | 8 | * SpringMVC的`spring.servlet.multipart.resolve-lazily: true`会让SpringMVC延迟上述`javax.servlet.http.Part`解析, 9 | 但如果在在此之前调用了HttpServletRequest获取参数还是会提前触发Part解析。参考源码:`org.springframework.web.servlet.DispatcherServlet.checkMultipart()` 10 | 11 | ## Request/Response Stream 可重复读 12 | 13 | 参考`logback-access`的`TeeFilter`/`TeeHttpServletRequest`/`TeeServletOutputStream` 14 | 15 | ## SpringBoot注册Filter、Servlet、Listener机制 16 | 17 | SpringBoot支持自动注册下面的Bean至Servlet容器中: 18 | 19 | * Servlet 20 | * Filter 21 | * ServletRegistrationBean 22 | * FilterRegistrationBean 23 | * DelegatingFilterProxyRegistrationBean 24 | * ServletListenerRegistrationBean 25 | * ServletContextInitializer 26 | * ServletContextAttributeListener 27 | * ServletRequestListener 28 | * ServletRequestAttributeListener 29 | * HttpSessionAttributeListener 30 | * HttpSessionListener 31 | * ServletContextListener 32 | 33 | 源码路线图: 34 | 1. 获取上面可注册Bean及排序规则参考`ServletContextInitializerBeans` 35 | 2. `org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getServletContextInitializerBeans()` -------------------------------------------------------------------------------- /Microservice/Docker/Docker容器内执行Docker命令.md: -------------------------------------------------------------------------------- 1 | ## Docker容器内执行Docker命令 2 | 3 | 1. Docker容器内安装Docker服务,即常说的`docker-in-docker`,此方案比较重。 4 | 5 | > [Docker-in-Docker 参考文档](https://blog.docker.com/2013/09/docker-can-now-run-within-docker/) 6 | [Docker-in-Docker Image](https://docs.docker.com/samples/library/docker/) 7 | 8 | 2. Docker容器内安装`statically linked docker binary`,可以理解成Docker容器内只有Docker Client的可执行文件, 9 | 通过这个Docker Client与宿主机的docker服务进行通信。此方案非常适合构建服务部署在容器内。 10 | 11 | ```bash 12 | shell> mkdir docker-build #创建构建镜像目录 13 | shell> wget https://download.docker.com/linux/static/stable/x86_64/docker-17.09.0-ce.tgz #下载`statically linked docker binary` 14 | shell> tar zxf docker-17.09.0-ce.tgz 15 | shell> rm -f docker-17.09.0-ce.tgz 16 | shell> cat << EOF > Dockerfile 17 | FROM base-image 18 | COPY docker/* /usr/bin/ 19 | EOF 20 | shell> docker build -t test-inner-docker . 21 | shell> docker run -d -v /var/run/docker.sock:/var/run/docker.sock test-inner-docker 22 | # 此时你就可以在容器中执行docker命令了 23 | ``` 24 | 25 | > 注:必须使用静态的二进制可执行文件。[下载地址](https://download.docker.com/linux/static/stable/x86_64/) 26 | 参考地址: 27 | https://github.com/moby/moby/issues/22608 28 | https://docs.docker.com/engine/reference/commandline/run/#mount-volume--v-read-only 29 | 30 | -------------------------------------------------------------------------------- /Test/JMeter.md: -------------------------------------------------------------------------------- 1 | ## JMeter 2 | 3 | ### 文档 4 | 5 | Documentation 6 | * [Get Started](https://jmeter.apache.org/usermanual/get-started.html) 7 | * [User's Manual](https://jmeter.apache.org/usermanual/index.html) - to understand how to use it 8 | * [Best Practices](https://jmeter.apache.org/usermanual/best-practices.html) 9 | * [Component reference](https://jmeter.apache.org/usermanual/component_reference.html) - to have detailed information for every Test element 10 | * [Functions reference](https://jmeter.apache.org/usermanual/functions.html) - to have detailed information and examples for every function 11 | * [Properties reference](https://jmeter.apache.org/usermanual/properties_reference.html) - for all properties that allow you to customize JMeter 12 | * [JMeter Wiki](https://cwiki.apache.org/confluence/display/JMETER/Home) - 可以找到你想要的资源 13 | 14 | Tutorials 15 | * [Distributed Testing](https://jmeter.apache.org/usermanual/jmeter_distributed_testing_step_by_step.html) 16 | * [Recording Tests](https://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.html) 17 | * [JUnit Sampler](https://jmeter.apache.org/usermanual/junitsampler_tutorial.html) 18 | * [Access Log Sampler](https://jmeter.apache.org/usermanual/jmeter_accesslog_sampler_step_by_step.html) 19 | * [Extending JMeter](https://jmeter.apache.org/usermanual/jmeter_tutorial.html) 20 | 21 | 22 | -------------------------------------------------------------------------------- /Security/OAuth2/OAuth2介绍.md: -------------------------------------------------------------------------------- 1 | ## OAuth2介绍 2 | 3 | 4 | * 文档 5 | * [官网](https://oauth.net/2/) 6 | 7 | * [Why is the hash part of the URL not available on the server side?](https://stackoverflow.com/questions/3664257/why-is-the-hash-part-of-the-url-not-available-on-the-server-side) 8 | * [理解OAuth 2.0 - 入门篇](http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html) 9 | * [OAuth 2.0 原理及请求响应字段剖析](http://tutorials.jenkov.com/oauth2/index.html) 10 | * [OAuth 2 Simplified](https://aaronparecki.com/oauth-2-simplified/) 11 | * [OAuth 2.0 - 【官网文档 - 详细】](https://tools.ietf.org/html/rfc6749) 12 | * [Secure a Spring Microservices Architecture with Spring Security and OAuth 2.0](https://developer.okta.com/blog/2018/02/13/secure-spring-microservices-with-oauth) 13 | 14 | * [Why is there an “Authorization Code” flow in OAuth2 when “Implicit” flow works so well?](https://stackoverflow.com/questions/13387698/why-is-there-an-authorization-code-flow-in-oauth2-when-implicit-flow-works-s) 15 | 16 | * [OAuth 2.0 Threat Model and Security Considerations](https://tools.ietf.org/html/rfc6819) 17 | 18 | ## Token 19 | 20 | * [JSON Web Token (JWT) - 【IETF官网】](https://tools.ietf.org/html/rfc7519) 21 | * [JSON Web Encryption (JWE) - 【IETF官网】](https://tools.ietf.org/html/rfc7516) 22 | 23 | * [Bearer Token - 【IETF官网】](https://tools.ietf.org/html/rfc6750) 24 | 25 | ## OpenID Connect 26 | 27 | * [OpenID Connect官网](https://openid.net/connect/) 28 | * [OpenID Connect:OAuth 2.0协议之上的简单身份层](https://www.cnblogs.com/XiongMaoMengNan/p/7381326.html) -------------------------------------------------------------------------------- /Java/Maven/Maven Wrapper(统一Maven版本).md: -------------------------------------------------------------------------------- 1 | ## Maven Wrapper(统一Maven版本) 2 | 3 | 使用`Maven Wrapper`便于项目统一使用Maven版本号,当使用`Maven Wrapper`执行Maven命令时,首先在本地查找有无对应的 4 | 版本号的Maven,没有则下载,意味着你本地不需要提前安装Maven。 5 | 6 | #### 安装 7 | 8 | ```bash 9 | shell> cd yourmavenproject 10 | shell> mvn -N io.takari:maven:wrapper 11 | ``` 12 | 13 | 指定使用Maven版本号: 14 | ```bash 15 | shell> cd yourmavenproject 16 | shell> mvn -N io.takari:maven:wrapper -Dmaven=3.3.9 17 | ``` 18 | 19 | 指定Maven的下载地址: 20 | ```bash 21 | shell> cd yourmavenproject 22 | shell> mvn -N io.takari:maven:wrapper -DdistributionUrl=http://server/path/to/maven/distro.zip 23 | ``` 24 | 25 | > 注:默认下载地址为:`https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip`, 26 | 版本号不是固定的,此下载地址会比较慢,你可以替换成官网提供的镜像地址`http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.zip`。 27 | 替换URL地址有两种方案:1)通过`-DdistributionUrl=`参数 2)手动修改`maven-wrapper.properties` 28 | 29 | > 注:`Maven Wrapper`支持缺少`.mvn/wrapper/maven-wrapper.jar`jar包,`mvnw`脚本发现缺少此jar,会通过`./mvn/wrapper/MavenWrapperDownloader.java` 30 | 下载jar包。下载的地址依据`maven-wrapper.properties`的`wrapperUrl`参数,没有此参数则使用`mvnw`脚本中的默认值。 31 | 32 | #### 升级 33 | 34 | * 再次执行安装命令 35 | * 手动修改`.mvn/wrapper/maven-wrapper.properties`文件的`distributionUrl`参数 36 | 37 | #### 使用 38 | 39 | ```bash 40 | shell> ./mvnw clean install 41 | ``` 42 | 43 | > 注:用法和`mvn`完全一样 44 | 45 | #### 文档 46 | 47 | * [maven-wrapper Github地址](https://github.com/takari/maven-wrapper) 48 | * [A Quick Guide to Maven Wrapper](https://www.baeldung.com/maven-wrapper) 49 | -------------------------------------------------------------------------------- /Web/JS/iView.md: -------------------------------------------------------------------------------- 1 | # iView 2 | 3 | ## 常见问题 4 | 5 | ### RESTful 动态路由匹配问题 6 | 7 | 两种解决方案: 8 | 9 | ```javascript 10 | data() { 11 | return { 12 | loaded: false 13 | } 14 | }, 15 | created() { 16 | this.loaded = true; 17 | this.loadData(this.$route.params); 18 | }, 19 | beforeRouteUpdate (to, from, next) { 20 | // loadData 方法中不能直接使用 this.$route.params,用了只会获取 from 路由的参数,所以这里需要通过传参的方式传给 loadData 21 | this.loadData(to.params); 22 | next(); 23 | }, 24 | activated () { 25 | // 如果缓存启用时,从别的路由跳到此路由时,会触发 created、activated 钩子函数,所以需要判断有没有加载过数据 26 | if (!this.loaded) { 27 | this.loadData(this.$route.params); 28 | } 29 | this.loaded = false; 30 | }, 31 | ``` 32 | 33 | ```javascript 34 | watch: { 35 | '$route' (to, from) { 36 | // 1. 当此组件没有配置 name,或者配置的 name 和 to.name 相等,则刷新数据 37 | // 2. 当此组件不配置 name 时,页面缓存肯定无效,在不同路由间切换时不会触发 watch.$route 函数 38 | // 3. 当此组件配置了name,且路由名和此值一致,并且缓存开启的情况下,从当前组件路由切换至其他路由时会触发 watch.$route 函数, 39 | // 所有需要判断出口路由是否是此组件,如果是此组件则才需要刷新数据 40 | if (!this.$options.name || this.$options.name === to.name) { 41 | // 此 loadData方法中可以使用 this.$route.params,此值和 to.params 相同,这与 beforeRouteUpdate 不同, 42 | // 由 watch、beforeRouteUpdate 触发时机决定的。 43 | this.loadData(); 44 | } 45 | } 46 | } 47 | ``` 48 | 49 | > [参考文档](https://router.vuejs.org/zh/guide/essentials/dynamic-matching.html) 50 | 51 | 52 | ## 文档 53 | 54 | * [`iView` - 基于Vue](https://www.iviewui.com/docs/guide/install) 55 | * [`iView-Admin`](https://github.com/iview/iview-admin) 56 | * [文档](https://lison16.github.io/iview-admin-doc/#/) 57 | 58 | -------------------------------------------------------------------------------- /Proxy/Nginx/directives/location.md: -------------------------------------------------------------------------------- 1 | ## location介绍 2 | 3 | 请求在执行`location`之前,会干以下事情 4 | 5 | 1. 解码被encoded(`"%XX"`)的内容 6 | 2. 转换相对路径,去掉路径中的`"."`、`".."` 7 | 3. 合并多个斜杠(`"/"`)为一个斜杠 8 | 9 | 10 | 命令参考手册 11 | --- 12 | 13 | ``` 14 | Syntax: location [ = | ~ | ~* | ^~ ] uri { ... } 15 | location @name { ... } 16 | Default: — 17 | Context: server, location 18 | ``` 19 | * **=** 精确匹配 20 | * **~** 正则,区分大小写 21 | * __~*__ 正则,不区分大小写 22 | * **^~** 前缀匹配,普通字符窜 23 | 24 | location的匹配顺序如下。下面的序号只是`匹配顺序`,不代表`优先级`: 25 | 26 | 1. 匹配有 `=` 修饰符的location(`= /v1`),匹配成功则跳出匹配,否则执行第2步骤 27 | 2. 依次匹配所有`非正则`location(`/v1`),记住最长匹配的那个location,如果最长匹配规则为`location ^~`, 28 | 则使用当前`location ^~`规则且跳过下面的匹配规则,否则执行第3步骤。注意:因为`location ^~ /v1` 也在`非正则location`这个范围。 29 | 3. 按照配置文件中的location顺序执行`正则匹配`,只要匹配成功就跳出匹配。如果整个配置文件的正则都试完了,就是没匹配成功,只能用第二步中`记住`的`非正则location`,然后跳出匹配。 30 | 31 | 上面说了很多的废话,来点更直接的表面现象(`优先级`): 32 | `=` ==> `^~` ==> `第一个匹配成功正则` ==> `/xx(普通非正则)` 33 | 34 | * `location = /api` 只匹配`/api`,不会匹配`/api/`、`/apixx` 35 | * `location = /api/` 只匹配`/api/`,不会匹配`/api`、`/apixx` 36 | * `location /api/` 只匹配`/api/`、`/api/xx`,不会匹配`/api` 37 | * `location /api` 匹配`/api`、`/apixx`、`/api/`、`/api/xx` 38 | * `location ^~ /api` 匹配以`/api`开头的URI,即匹配`/api`、`/apixx`、`/api/`、`/api/test` 39 | * `location ~ /api` / `location ~ ^/api` 都是使用正则匹配以`/api`开头的URI 40 | * `location ~ /api$` 匹配以`/api`结尾的URI 41 | * `location ^~ /v1`属于`非正则匹配`;`location ~ ^/v1`属于`正则匹配` 42 | * `location ^~ /v1`和`location /v1`不能同时出现,否则报错:`duplicate location "/v1" in /data/nginx.conf` 43 | 44 | > 注:Nginx版本为**0.7.1** - **0.8.41**,如果前缀匹配(`/xx`)没有`=`或`^~`修饰符,使用当前匹配规则,终止后面的匹配且不会执行正则匹配。 -------------------------------------------------------------------------------- /Java/Servlet/Nginx+Tomcat 环境下response.sendRedirect URL地址错乱.md: -------------------------------------------------------------------------------- 1 | ## Nginx+Tomcat 环境下response.sendRedirect URL地址错乱 2 | 3 | 4 | 今天发现一个非常诡异的现象。我在测试服务器上部署了一个单点登录系统(CAS),CAS的端口号为8080。然后用Nginx反向代理这个CAS服务,配置如下: 5 | 6 | ```bash 7 | server { 8 | listen 80; 9 | server_name sso.xxx.com; 10 | index index.html index.htm index.jhtml index.jsp; 11 | root /data/webroot/cas/; 12 | location / { 13 | index index.html; 14 | proxy_set_header Host $host; 15 | proxy_set_header X-Real-IP $remote_addr; 16 | proxy_pass http://localhost:8080; 17 | } 18 | } 19 | ``` 20 | 21 | 然后我在本机部署了一个项目,这个项目用到了CAS且端口也设置为8080,访问的地址为`http://localhost:8080/pro`。登录的地址为:`http://sso.xxx.com/login?service=http://localhost:8080/pro/login`。 22 | 正常来说,当登录成功后浏览器会302到`http://localhost:8080/pro/login?ticket=ST`。但是实际上302的重定向地址竟然改为:`http://sso.xxx.com/pro/login?ticket=ST`,就是说sso.xxx.com替换掉了localhost:8080。 23 | 24 | 当时我以为是CAS的代码写的有问题,看了下CAS的源码发现根本就没问题,CAS的redirect地址明明就是`http://localhost:8080/pro/login?ticket=ST`啊。 25 | 怎么就会无缘无故变成`http://sso.xxx.com/pro/login?ticket=ST`呢? 26 | 27 | 搞不清状况下,我把本地的项目端口号改为8081,然后抱着侥幸心理登录,妹的,这回竟然重定向正确了。难道是Nginx的中`proxy_pass http://localhost:8080`配置在作祟? 28 | 然后我试着不用域名访问CAS,改成用IP地址访问CAS,即不走Nginx的反向代理,发现又重定向正确了。这什么鬼???Nginx + Tomcat的Redirect的内部原理到底是什么,希望有人能指点指点!!! 29 | 30 | 最后我又试了另一种情况,在Nginx新增代理了另外一个项目,配置为`proxy_pass http://localhost:8081`,然后本地项目的端口号也改成8081。主要是想测试最终会不会Redirect到服务器上`localhost:8081`这个项目中。最终测试结果是:一切都正常,CAS也OK,Redirect也正确。 31 | 32 | 最后只能自己修改服务上CAS服务的端口号为不常用的,要是有人知道其他的解决方案或者了解其原理的话,求指点。 33 | -------------------------------------------------------------------------------- /Java/Reactive/Reactive.md: -------------------------------------------------------------------------------- 1 | # Reactive 2 | 3 | ## Reactive Streams 4 | 5 | The purpose of Reactive Streams is to provide a standard for asynchronous stream processing with non-blocking backpressure. 6 | 7 | * [官网](http://www.reactive-streams.org/) 8 | * [Reactive Streams 介绍](http://ypk1226.com/2019/07/01/reactive/reactive-streams/) 9 | 10 | 11 | ## Reactor 12 | 13 | Reactor is a fourth-generation reactive library, based on the `Reactive Streams` specification, for building non-blocking applications on the JVM. 14 | 15 | > [官网](https://projectreactor.io/) 16 | 17 | ### Reactor Core 18 | 19 | * [Reactor Core](https://projectreactor.io/docs/core/release/reference/) 20 | * [Debugging](https://projectreactor.io/docs/core/release/reference/#debugging) 21 | * [Metrics](https://projectreactor.io/docs/core/release/reference/#metrics) 22 | * [Context](https://projectreactor.io/docs/core/release/reference/#context) 23 | * [Cleanup](https://projectreactor.io/docs/core/release/reference/#cleanup) 24 | 25 | 26 | ### Reactor Netty 27 | 28 | * [Reactor Netty](https://projectreactor.io/docs/netty/release/reference/docs/index.html) 29 | 30 | 31 | ### Reactor RabbitMQ 32 | 33 | * [Reactor RabbitMQ](https://projectreactor.io/docs/rabbitmq/release/reference/) 34 | 35 | 36 | ### Reactor Kafka 37 | 38 | * [Reactor Kafka](https://projectreactor.io/docs/kafka/release/reference/) 39 | 40 | 41 | ## ReactiveX 42 | 43 | An API for asynchronous programming with observable streams. 44 | 45 | 基于Java的实现: `RxJava` 46 | 47 | * [官网](https://reactivex.io/) 48 | 49 | 50 | ## 综合 51 | 52 | * [八个层面比较 Java 8, RxJava, Reactor](https://cloud.tencent.com/developer/article/1356284) 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /Java/Attach-Instrumentation.md: -------------------------------------------------------------------------------- 1 | # Attach Instrumentation 2 | 3 | 使用 Instrumentation,使得开发者可以构建一个独立于应用程序的代理程序(Agent),用来监测和协助运行在 JVM 上的程序, 4 | 甚至能够替换和修改某些类的定义。 5 | 6 | ## [Byte Buddy Agent](https://bytebuddy.net/#/tutorial) 7 | 8 | The Byte Buddy agent provides a JVM Instrumentation in order to allow Byte Buddy the redefinition of already loaded classes. 9 | 10 | 使用`Instrumentation instrumentation = ByteBuddyAgent.install()`,可以在当前程序中获取`Instrumentation`来重定义Class, 11 | 或者直接使用`ByteBuddy`重定义Class: 12 | 13 | ```java 14 | ByteBuddyAgent.install(); 15 | 16 | Foo foo = new Foo(); 17 | new ByteBuddy() 18 | .redefine(Bar.class) 19 | .name(Foo.class.getName()) 20 | .make() 21 | .load(Foo.class.getClassLoader(), ClassReloadingStrategy.fromInstalledAgent()); 22 | assertThat(foo.m(), is("bar")); 23 | ``` 24 | 25 | 26 | ## 文档 27 | 28 | * JavaDoc 29 | * [VirtualMachine - JavaDoc](https://docs.oracle.com/javase/7/docs/jdk/api/attach/spec/com/sun/tools/attach/VirtualMachine.html) 30 | * [Package java.lang.instrument - JavaDoc](https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/package-summary.html) 31 | 32 | * [Java Attach机制](https://www.jianshu.com/p/542e50edc8e3) 33 | 34 | * [javaagent使用指南](https://www.cnblogs.com/rickiyang/p/11368932.html) 35 | * [基于Java Instrument的Agent实现](https://www.jianshu.com/p/b72f66da679f) 36 | * [Java程序员必知:深入理解Instrument](https://www.jianshu.com/p/5c62b71fd882) 37 | * [JVM源码分析之javaagent原理完全解读](https://www.infoq.cn/article/javaagent-illustrated) 38 | * Java Agent入门实战 39 | * [Java Agent入门实战(一)-Instrumentation介绍与使用](https://juejin.im/post/6844904035305127950) 40 | * [Java Agent入门实战(二)-Instrumentation源码概述](https://juejin.im/post/6844904038622838797) 41 | * [Java Agent入门实战(三)-JVM Attach原理与使用](https://juejin.im/post/6844904039830781966) 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Tools/SCM/pre-receive: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # git pre-receive hook例子,把修改数据发送至web服务,通过web服务判断有没有权限提交。 3 | 4 | set -euo pipefail 5 | 6 | if [[ "$GL_USERNAME" =~ ^root|admin$ ]]; then 7 | # root或admin用户任何情况下都有权限 8 | exit 0 9 | fi 10 | 11 | # hash-object为0的对象,代表git库中无此对象 12 | zero=$(git hash-object --stdin &2 19 | exit 1 20 | else 21 | if [ "$old_obj" = "$zero" ]; then 22 | # 新建分支 23 | range="$new_obj" 24 | else 25 | # 更新已有分支 26 | range="$old_obj..$new_obj" 27 | fi 28 | # 提取变更文件 29 | files=$(git diff --name-only "$range") 30 | # 需要把jq命令拷贝至 /var/opt/gitlab/gitlab-shell目录下,或者直接在镜像中安装jq指令 31 | post_data=$(echo $post_data | /var/opt/gitlab/gitlab-shell/jq --compact-output --arg ref "$ref" --arg files "$files" '.changes += [{branch: $ref, files: ($files / "\n")}]') 32 | fi 33 | done 34 | 35 | # 通过Web服务验证权限,发送数据格式: 36 | # {"user": "${GL_USERNAME}", "project": "${GL_PROJECT_PATH}", "changes": [{"branch": "master", "files": ["xxx", "yyy"]}, {"branch": "branch1", "files": ["zzz", "aaa"]}]} 37 | # Web服务可响应字符窜数据,此数据会显示给用户 38 | response=$(curl -X POST -Ss -w "%{http_code}" "http://xxx.com/debug" -H 'Content-Type: application/json' -d"$post_data" 2>&1) 39 | # 提取最后三位的状态码 40 | http_code=${response: -3} 41 | # 截取最后三位的http状态码 42 | response=${response%$http_code} 43 | 44 | if ((http_code >= 200 && http_code < 300)); then 45 | echo "您有权限推送此次提交" 46 | if [ -n "$response" ]; then 47 | echo "$response" 48 | fi 49 | exit 0 50 | else 51 | if [ -n "$response" ]; then 52 | echo "GL-HOOK-ERR: $response" >&2 53 | else 54 | echo "GL-HOOK-ERR: 您没有权限推送此次提交。" >&2 55 | fi 56 | exit 1 57 | fi 58 | -------------------------------------------------------------------------------- /Java/Validator/JakartaBeanValidation.md: -------------------------------------------------------------------------------- 1 | # Jakarta Bean Validation 2 | 3 | ## Jakarta Bean Validation 4 | 5 | ### Changes between Jakarta Bean Validation 2.0 and Bean Validation 2.0 6 | 7 | There are no changes between Jakarta Bean Validation 2.0 and Bean Validation 2.0 except for the GAV: it is now 8 | `jakarta.validation:jakarta.validation-api`. 9 | 10 | ### Certified implementations - `HibernateValidator:6.0.17.Final` 11 | 12 | ### Jakarta Bean Validation 文档 13 | 14 | * [Jakarta Bean Validation specification 2.0](https://beanvalidation.org/2.0/spec/) 15 | 16 | * 非官方参考 17 | * [@Validated和@Valid的区别?教你使用它完成Controller参数校验](https://blog.csdn.net/f641385712/article/details/97621783) 18 | * [让Controller支持对平铺参数执行数据校验(默认Spring MVC使用@Valid只能对JavaBean进行校验)](https://blog.csdn.net/f641385712/article/details/97621755) 19 | * [SpringBoot中BeanValidation数据校验与优雅处理详解](https://www.cnblogs.com/summerday152/p/13984576.html) 20 | 21 | ## Hibernate Validator 22 | 23 | ### Annotation Processor 24 | 25 | Hibernate Validator Annotation Processor is the right thing for you. It helps preventing such mistakes by plugging 26 | into the build process and raising compilation errors whenever constraint annotations are incorrectly used. 27 | 28 | 支持多种形式使用:`Maven`/`Gradle`/`javac`/`Apache Ant`/`Eclipse`/`IntelliJ IDEA`/`NetBeans` 29 | 30 | > [Annotation Processor](https://docs.jboss.org/hibernate/validator/6.2/reference/en-US/html_single/#validator-annotation-processor) 31 | 32 | ### Hibernate Validator 文档 33 | 34 | * [官网](https://hibernate.org/validator/) 35 | * [Hibernate Validator 6.1 官方文档](https://docs.jboss.org/hibernate/validator/6.1/reference/en-US/html_single/) 36 | * [占位符配置](https://docs.jboss.org/hibernate/validator/6.1/reference/en-US/html_single/#section-interpolation-with-message-expressions) 37 | * 属性: `{min}` 38 | * 当前验证值: `${validatedValue}` 39 | * 表达式: `${value > 1 ? 's' : ''}` 40 | * 自定义: `${formatter.format('%1$.2f', validatedValue)}` 41 | -------------------------------------------------------------------------------- /Web/JS/插件列表.md: -------------------------------------------------------------------------------- 1 | # 插件列表 2 | 3 | ## util工具 4 | 5 | ### [Lodash](https://lodash.com/docs) 6 | 7 | ### 进度计算 8 | * `big.js`/`bignumber.js`/`decimal.js` 9 | * [big.js vs. bignumber.js vs. decimal.js?](https://github.com/MikeMcl/big.js/issues/45#issuecomment-104211175) 10 | * `bignumber.js`适用于金融系统 11 | * `decimal.js`适用于科学计算 12 | > 这三个组件使用场景不同,日常开发中个人偏向于`bignumber.js` 13 | 14 | * `math.js` - [官网](https://mathjs.org/index.html) 15 | 16 | 三种使用方式: 17 | * `Regular function` - `math.add(math.sqrt(4), 2)` 18 | * `Evaluating expressions` - `math.evaluate('sqrt(4) + 2')` 19 | * `Chaining operations` - `math.chain(4).sqrt().add(2)` 20 | 21 | `math.js`支持`Expressions`/`Numbers`/`BigNumbers`/`Fractions`/`Complex Numbers`/`Matrices`/`Units`,功能 22 | 非常全面,注意事项: 23 | * 输入类型决定了输出类型,当输入类型不能确定时,则使用配置值`number`(可配置为`BigNumber`)。number为JS原生类型,存在精度丢失 24 | * 批量使用`Expressions`功能时,先编译(`compile`)再执行(`evaluate`)有助于提升性能 25 | * `Expressions`中的数组索引默认从 1 开始,`math.index()`从0开始 26 | 27 | > `math.js`提供的功能较全面,`Expressions`能明确展示计算表达式,但体量太大,注意事项多。非常适用于`科学计算`。 28 | 29 | ### WorkerPool 30 | 31 | workerpool offers an easy way to create a pool of workers for both dynamically offloading computations as well 32 | as managing a pool of dedicated workers. 33 | 34 | workerpool runs on node.js, Chrome, Firefox, Opera, Safari, and IE10+. 35 | 36 | > [workerpool - Github地址](https://github.com/josdejong/workerpool) 37 | 38 | ## 表单验证 39 | 40 | * [`vuelidate` - 基于Vue](https://github.com/monterail/vuelidate) 41 | * [`VeeValidate` - 基于Vue](http://vee-validate.logaretm.com/) 42 | 43 | ## UI 44 | 45 | * [`iView` - 基于Vue](https://www.iviewui.com/docs/guide/install) 46 | * [`iView-Admin`](https://github.com/iview/iview-admin) 47 | * [文档](https://lison16.github.io/iview-admin-doc/#/) 48 | 49 | ## 终端交互 50 | 51 | * [Xterm.js](https://github.com/xtermjs/xterm.js/) - Xterm.js is a front-end component written in TypeScript that lets applications bring fully-featured terminals to their users in the browser. -------------------------------------------------------------------------------- /linux/Firewalld.md: -------------------------------------------------------------------------------- 1 | ## 防火墙 2 | 3 | ### CentOS7 - Firewall 4 | 5 | 1. 开放防火墙端口 6 | 7 | 列出指定zone的开放端口(不会显示`--add-services`开放的端口): 8 | ```bash 9 | shell> firewall-cmd --zone=public --list-ports 10 | ``` 11 | 12 | `public` zone开放端口: 13 | ```bash 14 | # 立即生效,firewalld reload、service restart或系统重启后会丢失此配置 15 | shell> firewall-cmd --zone=public --add-port=8080/tcp 16 | 17 | # 持久化配置,不会立即生效,firewalld reload、service restart或系统重启后才会生效 18 | shell> firewall-cmd --zone=public --add-port=8080/tcp --permanent 19 | 20 | # 扩大端口范围 21 | shell> firewall-cmd --zone=public --add-port=5060-5061/udp 22 | ``` 23 | 24 | > 注:如果命令中没有`--zone=`参数则使用默认zone,默认zone可配置。默认zone为`public`,所以上述的`--zone=`参数可省略。 25 | 26 | 1. 显示防火墙的状态 27 | 28 | ```bash 29 | shell> firewall-cmd --state 30 | ``` 31 | 32 | 1. 显示当前已激活`zones`的`interfaces` 33 | 34 | ```bash 35 | shell> firewall-cmd --get-active-zones 36 | public 37 | interfaces: em1 38 | ``` 39 | 40 | 1. 显示指定`zone`的`interfaces` 41 | 42 | ```bash 43 | shell> firewall-cmd --zone=public --list-interfaces 44 | ``` 45 | 46 | 1. 显示指定`zone`的所有配置 47 | 48 | ```bash 49 | shell> firewall-cmd --zone=public --list-all 50 | ``` 51 | 52 | 1. 显示指定`zone`的信息,加上`-v`显示详情信息 53 | 54 | ```bash 55 | shell> firewall-cmd --info-zone=public -v 56 | ``` 57 | 58 | 1. 显示当前已经加载的`services` 59 | 60 | ```bash 61 | shell> firewall-cmd --get-services 62 | ``` 63 | 64 | 1. 显示持久化的`services` 65 | 66 | ```bash 67 | shell> firewall-cmd --permanent --get-services 68 | ``` 69 | 70 | 1. 显示`service`配置 71 | 72 | ```bash 73 | shell> firewall-cmd --info-service=ftp 74 | ``` 75 | 76 | 1. reload firewall 77 | 78 | reload firewall不会中断用户连接(不丢失状态信息),在reload阶段Service可能会被破坏 79 | ```bash 80 | shell> firewall-cmd --reload 81 | ``` 82 | 83 | > 注:[Firewall - 官方文档](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html-single/security_guide/index#sec-Using_Firewalls) 84 | -------------------------------------------------------------------------------- /Web/Browser/Firefox/常用.md: -------------------------------------------------------------------------------- 1 | ## 常用 2 | 3 | * 控制台技巧 - [官方文档](https://developer.mozilla.org/en-US/docs/Tools/Web_Console/The_command_line_interpreter) 4 | 5 | * 控制台JS脚本换行 - **`Shift` + `Enter`** 会出现换行效果,当你的脚本并没有结束时,敲`Enter`也会换行 6 | 7 | * 进入到iframes 8 | 9 | ```javascript 10 | // DOM element 11 | cd(document.getElementById("frame1")); 12 | 13 | // CSS selector 14 | cd("#frame1"); 15 | 16 | // contentWindow 17 | cd(document.getElementById("frame1").contentWindow); 18 | 19 | // 没有任何参数,回到顶级 window 20 | cd(); 21 | ``` 22 | 23 | * `$(selector, element)` - 返回第一个匹配的node 24 | 25 | * `$$(selector, element)` - 返回所有匹配的node 26 | 27 | * `$0` - The currently-inspected element in the page. 28 | 29 | * `$_` - Stores the result of the last expression executed in the console's command line. For example, if you type "2+2 ", then "$_ ", the console will print 4. 30 | 31 | * `$x(xpath, element)` - Evaluates the [XPath](https://developer.mozilla.org/en-US/docs/XPath) `xpath` expression in the context of `element` and returns an array of matching nodes. If unspecified, `element` defaults to `document`. 32 | 33 | * `keys()` - Given an object, returns a list of the keys (or property names) on that object. This is a shortcut for [Object.keys](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys). 34 | 35 | * `values()` - Given an object, returns a list of the values on that object; serves as a companion to `keys()`. 36 | 37 | * `clear()` - Clears the console output area. 38 | 39 | * `inspect()` - Given an object, opens the object inspector for that object. 40 | 41 | * `pprint()` - Formats the specified value in a readable way; this is useful for dumping the contents of objects and arrays. 42 | 43 | * `copy()` - New in Firefox 38. Copy the argument to the clipboard. If the argument is a string, it's copied as-is. If the argument is a DOM node, its [outerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML) is copied. Otherwise, [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) will be called on the argument, and the result will be copied to the clipboard. -------------------------------------------------------------------------------- /Tools/IDE/IDEA/IDEA生成Getter-Setter Boolean兼容Eclipse.md: -------------------------------------------------------------------------------- 1 | ## IDEA生成Getter/Setter Boolean兼容Eclipse 2 | 3 | IDEA默认生成Boolean规则如下: 4 | 5 | ```java 6 | class Test { 7 | 8 | private boolean isAdmin; 9 | 10 | private Boolean isLeader; 11 | 12 | public boolean isAdmin() { 13 | return isAdmin; 14 | } 15 | 16 | public void setAdmin(boolean admin) { 17 | isAdmin = admin; 18 | } 19 | 20 | public Boolean getLeader() { 21 | return isLeader; 22 | } 23 | 24 | public void setLeader(Boolean leader) { 25 | isLeader = leader; 26 | } 27 | } 28 | ``` 29 | 30 | `IDEA` `boolean`类型的生成规则和`Eclipse`一样。`IDEA` `Boolean`处理流程和`boolean`一样, 31 | 而`Eclipse`则不会处理`Boolean`类型的`is`前缀。如果想让IDEA处理`Boolean`和`Eclipse`一样,则配置如下: 32 | 33 | 在POJO类中 `右键` --> `Generate...` --> `Getter and Setter` --> 点击`Getter template`/`Setter template`右侧按钮 --> 34 | 点击`+`按钮 --> 分别添加如下模板: 35 | 36 | * Name:`Boolean Getter - Eclipse` 37 | ``` 38 | #if($field.modifierStatic) 39 | static ## 40 | #end 41 | $field.type ## 42 | #set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))) 43 | #if ($field.boolean && $field.primitive) 44 | is## 45 | #elseif($field.boolean && $StringUtil.startsWithIgnoreCase($field.name, "is")) 46 | getIs## 47 | #else 48 | get## 49 | #end 50 | ${name}() { 51 | return $field.name; 52 | } 53 | ``` 54 | 55 | * Name:`Boolean Setter - Eclipse` 56 | ``` 57 | #set($paramName = $helper.getParamName($field, $project)) 58 | #if($field.modifierStatic) 59 | static ## 60 | #end 61 | #set($name = $StringUtil.capitalizeWithJavaBeanConvention($StringUtil.sanitizeJavaIdentifier($helper.getPropertyName($field, $project)))) 62 | #if($field.boolean && !$field.primitive && $StringUtil.startsWithIgnoreCase($field.name, "is")) 63 | #set($name = "Is" + $name) 64 | #set($paramName = $field.name) 65 | #end 66 | void set${name}($field.type $paramName) { 67 | #if ($field.name == $paramName) 68 | #if (!$field.modifierStatic) 69 | this.## 70 | #else 71 | $classname.## 72 | #end 73 | #end 74 | $field.name = $paramName; 75 | } 76 | ``` 77 | 78 | > 注:更好的方案是POJO中禁止`boolean/Boolean`类型的属性以`is`开头,属性名用形容词格式。 79 | -------------------------------------------------------------------------------- /Microservice/K8S/Telepresence.md: -------------------------------------------------------------------------------- 1 | # Telepresence 2 | 3 | 4 | ## 参考文档 5 | 6 | * [Intercept a service in your own environment](https://www.getambassador.io/docs/telepresence/latest/howtos/intercepts) 7 | * [Share development environments with personal intercepts](https://www.getambassador.io/docs/telepresence/latest/howtos/personal-intercepts) 8 | * [Proxy outbound traffic to my cluster](https://www.getambassador.io/docs/telepresence/latest/howtos/outbound) 9 | * 配置 10 | * [Laptop-side configuration](https://www.getambassador.io/docs/telepresence/latest/reference/config) 11 | * [Cluster-side configuration](https://www.getambassador.io/docs/telepresence/latest/reference/cluster-config) 12 | * [Environment variables](https://www.getambassador.io/docs/telepresence/latest/reference/environment) - Telepresence can import environment variables from the cluster pod when running an intercept. 13 | * Intercepts 14 | * [Configuring intercept using CLI](https://www.getambassador.io/docs/telepresence/latest/reference/intercepts/cli) 15 | * [Configuring intercept using specifications](https://www.getambassador.io/docs/telepresence/latest/reference/intercepts/specs) 16 | * [FAQs](https://www.getambassador.io/docs/telepresence/latest/faqs) 17 | * What operating systems does Telepresence work on? 18 | * What protocols can be intercepted by Telepresence? 19 | * When using Telepresence to intercept a pod, are the Kubernetes cluster environment variables proxied to my local machine? 20 | * When using Telepresence to intercept a pod, can the associated pod volume mounts also be mounted by my local machine? 21 | * When connected to a Kubernetes cluster via Telepresence, can I access cluster-based services via their DNS name? 22 | * When connected to a Kubernetes cluster via Telepresence, can I access cloud-based services and data stores via their DNS name? 23 | * What components get installed in the cluster when running Telepresence? 24 | * How can I remove all the Telepresence components installed within my cluster? 25 | * How does Telepresence connect and tunnel into the Kubernetes cluster? 26 | * [Troubleshooting](https://www.getambassador.io/docs/telepresence/latest/troubleshooting) 27 | * Creating an intercept did not generate a preview URL 28 | * `too many files open error` when running `telepresence connect` on Linux 29 | * Connected to cluster via VPN but IPs don't resolve 30 | -------------------------------------------------------------------------------- /Web/JS/grunt-contrib-watch(gaze)创建文件BUG.md: -------------------------------------------------------------------------------- 1 | ## grunt-contrib-watch(gaze)创建文件BUG 2 | 3 | ##### `【参考】` 4 | --- 5 | 6 | grunt-contrib-watch:v0.6.1 7 | gaze:v0.5.2 8 | 9 | 当使用grunt-contrib-watch模块监听文件变动时,你可能会碰到创建新文件时,并没有触发`added`事件。这个问题归根于grunt-contrib-watch模块使用了`gaze`模块,而`gaze`存在如下问题: 10 | 11 | 1. 当路径以`./`开头,不触发`added`事件(**解决方案**:去除`./`) 12 | 2. 当路径为绝对路径`'/data/html/css/**/*.css'`,不触发`added`事件(**解决方案**:换成相对路径`'../html/css/**/*.css'`) 13 | 3. 当被监听的路径为空文件夹,不触发`added`事件。例如:当监听路径为`'css/**/*.css'`且`css`为空文件夹时,不触发`added`事件。(**解决方案**:监听路径改为`['css', 'css/**/*.css']`) 14 | 15 | > `gaze(v0.5.2)` 使用时需要注意两点: 16 | > 1、`'js/**/*.js'`路径只会监听有文件后缀名为`.js`所在文件夹,只有在此文件夹下创建文件或文件夹才会触发事件。例如:有真是路径为`js/a/b/file.js`,且`js/a`文件夹里没有后缀为`.js`的文件,当你`js/a`文件夹下面创建文件或文件夹是不会触发`added`事件的,但是在`js/a/b`文件夹下面创建就会触发`added`事件,因为其下面`file.js`符合规则。这一点非常重要,总有人会以为上面的匹配规则能监听`js/`下面所有的目录。如果要监听指定目录下面的所有子层级目录,则必须使用 `js/**` 。 17 | > 2、监听规则有可继承性。即`js/a/b/file.js`匹配路径规则时,在`js/a/b`下面创建的文件夹及其子文件('*.js'格式)也会被监听,会触发相同事件、相同`tasks`。 18 | 19 | ###例子 20 | 21 | 1、 **无效写法:** 22 | 23 | ```javascript 24 | watch: { 25 | css: { 26 | files: ['./css/**/*.css', '!./css/**/*.min.css'], 27 | tasks: ['cssmin:batch'] 28 | } 29 | } 30 | ``` 31 | 32 | **有效写法:** 33 | 34 | ```javascript 35 | watch: { 36 | css: { 37 | files: ['css/**/*.css', '!css/**/*.min.css'], 38 | tasks: ['cssmin:batch'] 39 | } 40 | } 41 | ``` 42 | 43 | 2、 **无效写法:** 44 | 45 | ```javascript 46 | watch: { 47 | css: { 48 | files: ['/data/html/css/**/*.css', '!/data/html/css/**/*.min.css'], 49 | tasks: ['cssmin:batch'] 50 | } 51 | } 52 | ``` 53 | 54 | **有效写法:** 55 | 56 | ```javascript 57 | watch: { 58 | css: { 59 | files: ['../html/css/**/*.css', '!../html/css/**/*.min.css'], 60 | tasks: ['cssmin:batch'] 61 | } 62 | } 63 | ``` 64 | 65 | 3、 **无效写法:** 66 | 67 | ```javascript 68 | watch: { 69 | css: { 70 | //css文件夹为空文件夹 71 | files: ['css/**/*.css', '!css/**/*.min.css'], 72 | tasks: ['cssmin:batch'] 73 | } 74 | } 75 | ``` 76 | 77 | **有效写法:** 78 | 79 | ```javascript 80 | watch: { 81 | css: { 82 | files: ['css', 'css/**/*.css', '!css/**/*.min.css'], 83 | tasks: ['cssmin:batch'] 84 | } 85 | } 86 | ``` 87 | -------------------------------------------------------------------------------- /Java/Java文件锁-FileLock.md: -------------------------------------------------------------------------------- 1 | # Java文件锁-FileLock 2 | 3 | ### Java FileLock(文件锁) 4 | 5 | `FileLock`通过`FileChannel`对象获取,简单示例如下: 6 | ```java 7 | try (RandomAccessFile stream = new RandomAccessFile("d:/test-lock", "rw"); 8 | FileChannel channel = stream.getChannel()) { 9 | 10 | // 获取锁。如果有其他进程已经获得锁,则此 channel.lock() 被挂起,直至成功获取锁。 11 | FileLock lock = channel.lock(); 12 | 13 | try { 14 | // 逻辑代码 15 | System.out.println("locked..."); 16 | TimeUnit.SECONDS.sleep(2); 17 | 18 | } catch (InterruptedException e) { 19 | e.printStackTrace(); 20 | } finally { 21 | lock.release(); 22 | } 23 | } catch (IOException e) { 24 | e.printStackTrace(); 25 | } 26 | ``` 27 | 28 | ### `FileChannel`获得锁有两类方法: 29 | * `channel.lock()` - 如果锁被其他进程占有,则会一直等待其他进程释放锁 30 | * `channel.tryLock()` - 如果锁被其他进程占有,会立即返回`null`,并不会一直等待锁的释放 31 | 32 | 33 | ### `FileLock`有两种类型: 34 | 35 | * 排他锁 - `channel.lock()`/`channel.lock(0, Integer.MAX_VALUE, false)` 36 | * 排他锁需要`WritableChannel`,`new RandomAccessFile(file, "rw")`/`new FileOutputStream(file)` 可行, 37 | `new RandomAccessFile(file, "r")`/`new FileInputStream(file)` 会报错。 38 | * 当有进程获得`排他锁`后,另一个进程尝试读此文件会报错。在Windows系统下,使用Notepad打开时,不会报错, 39 | 但你会发现打开的是一个空文件。 40 | * 当有进程获得`排他锁`后,另一个进程尝试获取`排他锁`或`共享锁`都将会被阻塞,直至`排他锁`释放。 41 | 42 | * 共享锁 - `channel.lock(0, Integer.MAX_VALUE, true)` 43 | * 共享锁需要`ReadableChannel`,`new FileInputStream(file)`/`new RandomAccessFile(file, "rw")`/`new RandomAccessFile(file, "r")` 可行, 44 | `new FileOutputStream(file)`会报错。 45 | * 当有进程获得`共享锁`后,另一个进程可以读文件内容,但尝试写文件时会报错(就算`当前`获得锁的线程执行写操作也会`报错`)。 46 | 在Windows系统中,使用Notepad打开文件后,可以看到文件内容,尝试写数据时不会报错,但保存文件后,你再次打开文件发现内容为空。 47 | * 当有进程获得`共享锁`后,另一个进程尝试获取`排他锁`将会被阻塞,直至`共享锁`释放。当另一个进程尝试获取`共享锁`时将会成功。 48 | * 第一个参数`position`:锁的起始位置 49 | * 第二个参数`size`:锁的区域大小,即同一个文件根据锁的不同区域可同时出现多个锁 50 | * 第三个参数`shared`:是否为共享锁 51 | 52 | 53 | ### 注意事项 54 | 55 | 在同一个JVM进程中,一个文件的同区域锁只能获取一次,第二次获取锁时会直接报错(无论是当前线程还是其他线程,只要在同一个JVM进程中就会报错), 56 | 而不会等待第一次获取的锁释放。 57 | 58 | > File locks are held on behalf of the entire Java virtual machine. They are not suitable for controlling access to a file by multiple 59 | threads within the same virtual machine. 60 | 61 | > On some systems, closing a channel releases all locks held by the Java virtual machine on the underlying file regardless of whether the 62 | locks were acquired via that channel or via another channel open on the same file. It is strongly recommended that, within a program, 63 | a unique channel be used to acquire all locks on any given file. 64 | -------------------------------------------------------------------------------- /Monitor/Zipkin.md: -------------------------------------------------------------------------------- 1 | # Zipkin 2 | 3 | ## 文档 4 | 5 | * [zipkin - Github主页](https://github.com/openzipkin/zipkin) 6 | * [zipkin-server](https://github.com/openzipkin/zipkin/tree/master/zipkin-server) - zipkin-server 7 | is a Spring Boot application, packaged as an executable jar. You need JRE 8+ to start 8 | zipkin-server. 9 | * [zipkin-collector](https://github.com/openzipkin/zipkin/tree/master/zipkin-collector) 10 | * `ActiveMQ` 11 | * `Core` 12 | * `Kafka` 13 | * `RabbitMQ` 14 | * `Scribe` - 不推荐 15 | * [zipkin-junit](https://github.com/openzipkin/zipkin/tree/master/zipkin-junit) - This contains 16 | ZipkinRule, a JUnit rule to spin-up a Zipkin server during tests 17 | * [Zipkin-lens](https://github.com/openzipkin/zipkin/tree/master/zipkin-lens) - Zipkin-lens is an 18 | alternative UI for Zipkin, which based on React, Netflix/vizceral and chartjs. 19 | * [zipkin-storage](https://github.com/openzipkin/zipkin/tree/master/zipkin-storage) 20 | * `Cassandra` 21 | * `ElasticSearch` 22 | * `MySql` - 不推荐 23 | * [Zipkin Docker](https://github.com/openzipkin/zipkin/tree/master/docker/examples) - 24 | 使用`docker-compose`简易运行Zipkin需要的各个组件,包含了`Dockerfile`及`examples` 25 | * [Open Zipkin Example](https://github.com/openzipkin?utf8=%E2%9C%93&q=example) - 26 | 包含部分语言集成Zipkin的Demo 27 | 28 | * [Zipkin官网](https://zipkin.io/) 29 | * [Quickstart](https://zipkin.io/pages/quickstart.html) 30 | * [Architecture](https://zipkin.io/pages/architecture.html) 31 | * [Tracers and Instrumentation](https://zipkin.io/pages/tracers_instrumentation.html) - The 32 | libraries provide instrumentation on various platforms. 33 | * [Server extensions and choices](https://zipkin.io/pages/extensions_choices.html) - 34 | Server端的扩展及可替换产品 35 | * `Apache SkyWalking` 36 | * `Jaeger` 37 | * `Pitchfork` 38 | * [Instrumenting a library](https://zipkin.io/pages/instrumenting.html) 39 | 40 | * [zipkin-dependencies](https://github.com/openzipkin/zipkin-dependencies) - Spark job that 41 | aggregates zipkin spans for use in the UI. 42 | 43 | Zipkin Dependencies collects spans from storage, analyzes links between services, and stores them 44 | for later presentation in the web UI (ex. `http://localhost:8080/dependency`). 45 | 46 | This process is implemented as an `Apache Spark job`. This job parses all traces in the current 47 | day in `UTC time`. This means you should schedule it to run just prior to `midnight UTC`. 48 | 49 | * [Distributed Tracing with Zipkin and ELK](https://logz.io/blog/zipkin-elk/) 50 | -------------------------------------------------------------------------------- /Java/Office软件/Excel.md: -------------------------------------------------------------------------------- 1 | # Excel 2 | 3 | ## 注意事项 4 | 5 | * 当读取ClassPath中的Excel时,报类似错误:`NotOLE2FileException: Invalid header signature; read 0xE011BDBFEFBDBFEF, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document`。 6 | 请检查`pom`文件配置`resource`时是否`filtering` Excel文件。正确配置参考如下: 7 | 8 | ```xml 9 | 10 | 11 | true 12 | src/main/resources 13 | 14 | excel/* 15 | 16 | 17 | 18 | src/main/resources 19 | 20 | excel/* 21 | 22 | 23 | 24 | ``` 25 | 26 | * `EasyPoi` `4.1.0` 版本在使用模板导出时,循环表达式下面不能只有一行内容,否则最终生成的Excel文件会缺失最后一行。 27 | 所以要么没有内容,要么为多行内容。如果你确实只需要一行内容,你可以把Excel的多行合并成一行,在合并后的行里填充模板。 28 | 产生此BUG的代码在`ExcelExportOfTemplateUtil#addListDataToExcel()`: 29 | 30 | ```java 31 | if (isShift && datas.size() * rowspan > 1 && cell.getRowIndex() + rowspan < cell.getRow().getSheet().getLastRowNum()) { 32 | int lastRowNum = cell.getRow().getSheet().getLastRowNum(); 33 | cell.getRow().getSheet().shiftRows(cell.getRowIndex() + rowspan, lastRowNum, (datas.size() - 1) * rowspan, true, true); 34 | mergedRegionHelper.shiftRows(cell.getSheet(), cell.getRowIndex() + rowspan, (datas.size() - 1) * rowspan); 35 | templateSumHandler.shiftRows(cell.getRowIndex() + rowspan, (datas.size() - 1) * rowspan); 36 | PoiExcelTempUtil.reset(cell.getSheet(), cell.getRowIndex() + rowspan + (datas.size() - 1) * rowspan, cell.getRow().getSheet().getLastRowNum()); 37 | } 38 | ``` 39 | 40 | > `cell.getRowIndex() + rowspan < cell.getRow().getSheet().getLastRowNum()`比较会出现相等的情况。`cell.getRowIndex()` 当前遍历标签 41 | 的行索引,`rowspan`遍历标签占用的行数,`cell.getRow().getSheet().getLastRowNum()`当前模板的最大行索引数。 42 | 43 | ## 组件 44 | 45 | * [POI](http://poi.apache.org/components/spreadsheet/quick-guide.html) 46 | * [Java Excel API](http://.sourceforge.net/) 47 | * [EasyPoi -【推荐】- 对POI的完整封装,支持注解和模板](https://easypoi.mydoc.io/) 48 | * [JXLS -【推荐】- 使用模板导出,支持`POI`及`Java Excel API`](http://jxls.sourceforge.net/index.html) 49 | * [jxls-demo](https://bitbucket.org/leonate/jxls-demo/src/master/) 50 | * [easyexcel - 对POI的完整封装](https://github.com/alibaba/easyexcel) 51 | 52 | ## 参考文档 53 | 54 | * [java 导出 excel 最佳实践,java 大文件 excel 避免OOM(内存溢出) excel 工具框架](https://juejin.im/post/5bfbfbebe51d4505e64bb392) 55 | * [docx4j](https://www.docx4java.org/trac/docx4j) 56 | -------------------------------------------------------------------------------- /API/API-常用.md: -------------------------------------------------------------------------------- 1 | # API常用 2 | 3 | ## 规范 4 | 5 | * [OpenAPI 规范](https://github.com/OAI/OpenAPI-Specification/tree/main/versions) - Github 6 | * [OpenAPI Guide](https://swagger.io/docs/specification/about/) - Swagger 7 | * [JSON Schema Validation: A Vocabulary for Structural Validation of JSON draft-wright-json-schema-validation-00](https://datatracker.ietf.org/doc/html/draft-wright-json-schema-validation-00) 8 | * [RESTful Web APIs](http://sd.blackball.lv/library/RESTful_Web_APIs_(2013).pdf) 9 | 10 | 11 | ## 组件 12 | 13 | ### Swagger 2.X 14 | 15 | #### swagger-core 16 | * [Swagger 2.X Getting started](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Getting-started) 17 | * [Swagger 2.X Integration and Configuration](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration) 18 | * `Resolve the OpenAPI Definition` 19 | * `Reader` - OpenAPI/Json/Yaml 20 | * `Converter` 21 | * `Context` 22 | * [Swagger 2.X Annotations](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Annotations) - 核心注解 23 | * [Swagger 2.X Extensions](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Extensions) - 自定义扩展 24 | 25 | 26 | #### swagger-samples 27 | * [swagger-samples](https://github.com/swagger-api/swagger-samples) 28 | 29 | #### Swagger UI 30 | 31 | * [Configuration](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/) 32 | * [CORS](https://swagger.io/docs/open-source-tools/swagger-ui/usage/cors/) 33 | * [OAuth 2.0 Configuration](https://swagger.io/docs/open-source-tools/swagger-ui/usage/oauth2/) 34 | * [`deepLinking` parameter](https://swagger.io/docs/open-source-tools/swagger-ui/usage/deep-linking/) 35 | * [Limitations](https://swagger.io/docs/open-source-tools/swagger-ui/usage/limitations/) - Forbidden header names 36 | * [Customization](https://swagger.io/docs/open-source-tools/swagger-ui/customization/overview/) 37 | 38 | #### Tools and Integrations 39 | 40 | * [Tools and Integrations](https://swagger.io/tools/open-source/open-source-integrations/) - 包含所有官方和开源组件 41 | 42 | ### SpringDoc-OpenApi 43 | * [springdoc-openapi - Github](https://github.com/springdoc/springdoc-openapi) 44 | * [官方文档](https://springdoc.org/) 45 | * [Documenting a Spring REST API Using OpenAPI 3.0](https://www.baeldung.com/spring-rest-openapi-documentation) 46 | 47 | ### SpringFox 48 | 49 | * [springfox - Github](https://github.com/springfox/springfox) 50 | * [Setting Up Swagger 2 with a Spring REST API](https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api) 51 | * [Spring Boot整合swagger使用教程](https://www.cnblogs.com/progor/p/13297904.html) -------------------------------------------------------------------------------- /Web/Web-常用.md: -------------------------------------------------------------------------------- 1 | # Web常用 2 | 3 | ## HTTP Caching 4 | 5 | 可缓存StatusCode: 6 | * 200 OK 7 | * 203 Non-Authoritative Information 8 | * 204 No Content 9 | * 206 Partial Content 10 | * 300 Multiple Choices 11 | * 301 Moved Permanently 12 | * 404 Not Found 13 | * 405 Method Not Allowed 14 | * 410 Gone 15 | * 414 URI Too Long 16 | * 501 Not Implemented 17 | 18 | 可缓存HTTP Method: 19 | * GET 20 | * HEAD 21 | * POST - 规范定义为可缓存,多数未实现 22 | 23 | > 参考 - [Which HTTP status codes are cacheable?](https://cassiomolin.com/2016/09/09/which-http-status-codes-are-cacheable/) 24 | 25 | * [HTTP 缓存 - MDN](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Caching) 26 | * [彻底弄懂浏览器缓存策略](https://www.jiqizhixin.com/articles/2020-07-24-12) 27 | 28 | ## HTTP详解 - MDN Web Doc -【重要】 29 | 30 | * [参考文档](https://developer.mozilla.org/zh-CN/docs/Web/HTTP) 31 | * `headers` 32 | * `CORS` 33 | * `response status codes` 34 | * `request methods` 35 | * `redirects` 36 | * `cookies` 37 | * `content negotiation` 38 | * `compression` 39 | * `authentication` 40 | 41 | 42 | ## HTTP2 43 | 44 | * [HTTP2官网](https://http2.github.io/) 45 | * 规范 46 | * [HTTP/2](https://httpwg.org/specs/rfc7540.html) - RFC7540 47 | * [HPACK: Header Compression for HTTP/2](https://httpwg.org/specs/rfc7541.html) - RFC7541 48 | * [HTTP/2 Frequently Asked Questions](https://http2.github.io/faq/) 49 | * [实现HTTP2的组件](https://github.com/httpwg/http2-spec/wiki/Implementations) 50 | * [Java 9和Spring Boot 2.0纷纷宣布支持的HTTP/2到底是什么?](https://mp.weixin.qq.com/s?__biz=MzI3NzE0NjcwMg==&mid=2650120831&idx=1&sn=2bcafb931eff897e2f866bd02dcda680&chksm=f36bbf5ec41c36481c2f5da1f74cf48fca374bb5b5922d26ac4ace7858cf8ede4fc2cefc1584&scene=21#wechat_redirect) 51 | * [HTTP/2做错了什么?刚刚辉煌2年就要被弃用了!?](https://zhuanlan.zhihu.com/p/337196435) 52 | 53 | ## URI 54 | 55 | * [Uniform Resource Identifier (URI): Generic Syntax](https://datatracker.ietf.org/doc/html/rfc3986#section-2.2) - URI规范 56 | * [保留字符](https://datatracker.ietf.org/doc/html/rfc3986#section-2.2) - `:/?#[]@!$&'()*+,;=` - 使用时必须转换为`%格式` 57 | 58 | ## Media Types 59 | 60 | * [Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml) - 最全的格式列表 61 | 62 | ## 参考链接 63 | 64 | * [Web technology (MDN)](https://developer.mozilla.org/en-US/docs/Web) -【重要】Web 参考文献 65 | 66 | * [Is JavaScript Single-Threaded?](https://www.red-gate.com/simple-talk/dotnet/asp-net/javascript-single-threaded/) - 讲解`Event loop`及JS单线程执行原理 67 | 68 | * [URI Template](https://tools.ietf.org/html/rfc6570) - A URI Template is a compact sequence of characters for describing 69 | a range of Uniform Resource Identifiers through variable expansion. 70 | 71 | * [HTML规范](https://whatwg-cn.github.io/html/) - 官网翻译版 -------------------------------------------------------------------------------- /Java/APT-AnnotationProcessingTool.md: -------------------------------------------------------------------------------- 1 | # APT-AnnotationProcessingTool 2 | 3 | 注解处理器(Annotation Processor)是javac的一个工具,它用来在编译时扫描和处理注解(Annotation)。 4 | 5 | 一个注解的注解处理器,以Java代码(或者编译过的字节码)作为输入,生成文件(通常是.java文件)作为输出。 6 | 这具体的含义什么呢?你可以生成Java代码!这些生成的Java代码是在生成的.java文件中,所以你不能修改已经存在的Java类, 7 | 例如向已有的类中添加方法。这些生成的Java文件,会同其他普通的手动编写的Java源代码一样被javac编译。 8 | 9 | An important thing to note is `the limitation of the annotation processing API — it can only be used to generate new 10 | files, not to change existing ones`. 11 | 12 | The notable exception is the `Lombok` library which uses annotation processing as a bootstrapping mechanism to include 13 | itself into the compilation process and modify the AST via some internal compiler APIs. This hacky technique has nothing 14 | to do with the intended purpose of annotation processing and therefore is not discussed in this article. 15 | 16 | ## Lombok 注意事项 17 | 18 | ### 使用Lombok时如果`import内部类`则报`找不到符号 Data符号` 19 | 20 | 编译报错示例: 21 | ```java 22 | import com.banksteel.demo.user.ProbeAutoConfiguration.ProbeProperties.Probe; 23 | import lombok.Data; 24 | 25 | public class ProbeAutoConfiguration { 26 | 27 | public void test(ProbeProperties props) { 28 | Probe liveness = props.getReadiness(); 29 | } 30 | 31 | @Data 32 | public static class ProbeProperties { 33 | 34 | private Probe readiness = new Probe(); 35 | 36 | @Data 37 | public static class Probe { 38 | 39 | private String status; 40 | 41 | } 42 | } 43 | } 44 | ``` 45 | 上述示例使用了`import com.banksteel.demo.user.ProbeAutoConfiguration.ProbeProperties.Probe;`,导致了编译报错,此为 Oracle bug。 46 | 47 | 修正代码: 48 | ```java 49 | import lombok.Data; 50 | 51 | public class ProbeAutoConfiguration { 52 | 53 | public void test(ProbeProperties props) { 54 | // import class 改为 ProbeProperties.Probe 可避免问题 55 | ProbeProperties.Probe liveness = props.getReadiness(); 56 | } 57 | 58 | @Data 59 | public static class ProbeProperties { 60 | 61 | private Probe readiness = new Probe(); 62 | 63 | @Data 64 | public static class Probe { 65 | 66 | private String status; 67 | 68 | } 69 | } 70 | } 71 | ``` 72 | 73 | > [GitHub issue 链接](https://github.com/projectlombok/lombok/issues/1684) 74 | 75 | 76 | 77 | ## 文档 78 | 79 | * [Java注解处理器](https://race604.com/annotation-processing/) 80 | * [Java Annotation Processing and Creating a Builder](https://www.baeldung.com/java-annotation-processing-builder) 81 | * [Using annotation processor in IDE](https://immutables.github.io/apt.html) 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /Security/CORS - CrossOriginResourceSharing.md: -------------------------------------------------------------------------------- 1 | # Cross-Origin Resource Sharing(CORS) 2 | 3 | ## 配置 CORS 4 | 5 | ### SpringBoot集成 Cors 6 | 7 | ```yaml 8 | spring: 9 | cors: 10 | cors-configurations: 11 | "[/test/**]": 12 | allowed-origins: "*" 13 | allowed-methods: "*" 14 | max-age: 1800 15 | "[/api/**]": 16 | allowed-origins: "*" 17 | allowed-methods: [GET, HEAD, POST] 18 | allow-credentials: true 19 | ``` 20 | 21 | ```java 22 | @Configuration 23 | public class CorsConfig { 24 | 25 | private static final String CORS_CONFIG_PREFIX = "spring.cors"; 26 | 27 | @Bean 28 | @ConfigurationProperties(CORS_CONFIG_PREFIX) 29 | public UrlBasedCorsConfigurationSource corsConfigurationSource() { 30 | return new UrlBasedCorsConfigurationSource(); 31 | } 32 | 33 | @Bean 34 | public CorsFilter corsFilter(UrlBasedCorsConfigurationSource corsConfigurationSource) { 35 | return new CorsFilter(corsConfigurationSource); 36 | } 37 | 38 | } 39 | ``` 40 | 41 | > 注:如果想控制 CorsFilter 执行顺序,则使用 FilterRegistrationBean 来配置 42 | 43 | ### SpringBoot + SpringSecurity 集成 Cors 44 | 45 | ```yaml 46 | spring: 47 | cors: 48 | cors-configurations: 49 | "[/test/**]": 50 | allowed-origins: "*" 51 | allowed-methods: "*" 52 | max-age: 1800 53 | "[/api/**]": 54 | allowed-origins: "*" 55 | allowed-methods: [GET, HEAD, POST] 56 | allow-credentials: true 57 | ``` 58 | 59 | ```java 60 | @Configuration 61 | public class SecurityConfig extends WebSecurityConfigurerAdapter { 62 | 63 | private static final String CORS_CONFIG_PREFIX = "spring.cors"; 64 | 65 | @Bean 66 | @ConfigurationProperties(CORS_CONFIG_PREFIX) 67 | public UrlBasedCorsConfigurationSource corsConfigurationSource() { 68 | return new UrlBasedCorsConfigurationSource(); 69 | } 70 | 71 | @Override 72 | protected void configure(HttpSecurity http) throws Exception { 73 | http.requestMatchers().anyRequest() 74 | ... 75 | // 启用 CorsFilter,自动去容器中找 corsFilter、corsConfigurationSource Bean 76 | .and().cors(); 77 | } 78 | } 79 | ``` 80 | 81 | ## 参考 82 | 83 | * [HTTP访问控制(CORS) - 【重要】](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Access_control_CORS) 84 | * [CORS 跨域 实现思路及相关解决方案](https://www.cnblogs.com/sloong/p/cors.html) 85 | * [跨域资源共享 CORS 详解](http://www.ruanyifeng.com/blog/2016/04/cors.html) 86 | * [HTTP 请求头 `Access-Control-*` 文档](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/Access-Control-Max-Age) 87 | * [Using CORS - 跨域请求详解](https://www.html5rocks.com/en/tutorials/cors/) 88 | 89 | -------------------------------------------------------------------------------- /Web/JS/Webpack.md: -------------------------------------------------------------------------------- 1 | ## Webpack 2 | 3 | Webpack用于打包源码,不会修改任何代码(除了`import`/`export`语句),不会转换ES6语法。 4 | 5 | 6 | ### 文档 7 | 8 | * [Webpack相关概念及用法](https://webpack.js.org/concepts/) 9 | 10 | * [Configuration - 配置详解](https://webpack.js.org/configuration/) 11 | 12 | * [CLI及API详细](https://webpack.js.org/api/) 13 | 14 | * [`Loaders`列表](https://webpack.js.org/loaders/) 15 | 16 | * [`Plugins`列表](https://webpack.js.org/plugins/) 17 | 18 | * `Guides` 19 | * [Loading CSS](https://webpack.js.org/guides/asset-management/#loading-css) 20 | * [Loading Images](https://webpack.js.org/guides/asset-management/#loading-images) 21 | * [Loading Fonts](https://webpack.js.org/guides/asset-management/#loading-fonts) 22 | * [Loading Data](https://webpack.js.org/guides/asset-management/#loading-data) 23 | * [Using source maps -【重要】](https://webpack.js.org/guides/development/#using-source-maps) 24 | * [Choosing a Development Tool - 自动编译源码 -【重要】](https://webpack.js.org/guides/development/#choosing-a-development-tool) 25 | * [Cleaning up the `/dist` folder - `clean-webpack-plugin` - 构建之前删除`/dist`目录里文件](https://webpack.js.org/guides/output-management/#cleaning-up-the-dist-folder) 26 | * [Hot Module Replacement](https://webpack.js.org/guides/hot-module-replacement/) 27 | * [Code Splitting](https://webpack.js.org/guides/code-splitting/) 28 | * [Caching - 打包后文件名包含Hash值](https://webpack.js.org/guides/caching/) 29 | * [Authoring Libraries - 编写组件](https://webpack.js.org/guides/author-libraries/) 30 | * [Environment Variables - 执行webpack传递参数](https://webpack.js.org/guides/environment-variables/) 31 | * [Build Performance - 提升性能的措施](https://webpack.js.org/guides/build-performance/) 32 | * [Content Security Policies](https://webpack.js.org/guides/csp/) 33 | * [Dependency Management](https://webpack.js.org/guides/dependency-management/) 34 | * `require with expression` 35 | * `require.context` 36 | * [Tree Shaking - 打包时删除依赖库中没有用到的`export`代码](https://webpack.js.org/guides/tree-shaking/) 37 | * [Production - `开发/生产`环境怎么配置Webpack](https://webpack.js.org/guides/production/) 38 | * [Shimming](https://webpack.js.org/guides/shimming/) 39 | * Shimming Globals 40 | * Granular Shimming 41 | * Global Exports 42 | * Loading Polyfills 43 | * [集成TypeScript](https://webpack.js.org/guides/typescript/) 44 | * [Progressive Web Application - 通过`Service Workers`让应用提供离线功能](https://webpack.js.org/guides/progressive-web-application/) 45 | * [Public Path - 定义BasePath](https://webpack.js.org/guides/public-path/) 46 | * [Integrations - 集成`task runner`(`Grunt`/`Gulp`等)](https://webpack.js.org/guides/integrations/) 47 | 48 | -------------------------------------------------------------------------------- /Microservice/Dubbo/Dubbo泛化调用.md: -------------------------------------------------------------------------------- 1 | # Dubbo泛化调用 2 | 3 | ## 示例 4 | 5 | ```java 6 | import com.alibaba.dubbo.common.utils.PojoUtils; 7 | import com.alibaba.dubbo.config.ApplicationConfig; 8 | import com.alibaba.dubbo.config.ConsumerConfig; 9 | import com.alibaba.dubbo.config.RegistryConfig; 10 | import com.alibaba.dubbo.config.spring.ReferenceBean; 11 | import com.alibaba.dubbo.config.utils.ReferenceConfigCache; 12 | import com.alibaba.dubbo.rpc.service.GenericService; 13 | 14 | public class Test { 15 | 16 | public static void main(String[] args) { 17 | //创建 ApplicationConfig 18 | ApplicationConfig app = new ApplicationConfig(); 19 | // 应用名可自行设定 20 | app.setName("app-test"); 21 | 22 | //创建注册中心配置 23 | RegistryConfig registry = new RegistryConfig(); 24 | registry.setAddress("zookeeper://dubbo1:2181?backup=dubbo2:2181,dubbo3:2181"); 25 | // 可选配置 26 | registry.setClient("curator"); 27 | 28 | //创建注册中心配置 29 | ConsumerConfig consumer = new ConsumerConfig(); 30 | consumer.setCheck(false); 31 | consumer.setRetries(0); 32 | 33 | // 创建 ReferenceBean 34 | ReferenceBean bean = new ReferenceBean<>(); 35 | bean.setApplication(app); 36 | bean.setRegistry(registry); 37 | bean.setConsumer(consumer); 38 | // 调用指定服务 - 指定URL后 registry 可以不用配置 39 | //bean.setUrl("dubbo://192.168.254.104:23000"); 40 | // API接口类名 41 | bean.setInterface("com.xxx.DubboApi"); 42 | // 启用泛化接口调用 43 | bean.setGeneric("true"); 44 | // 初始化 Bean 45 | GenericService service = bean.get(); 46 | try { 47 | // 参数类型 - 如想自动生成类型字符串,使用:ReflectUtils.getName() 48 | String[] paramTypes = new String[]{ 49 | "java.lang.String", 50 | "com.xxx.dto.XxxDTO" 51 | }; 52 | 53 | // 参数值 54 | Object[] params = new Object[]{ 55 | "7f30bdee", 56 | // POJO 转 HashMap 57 | PojoUtils.generalize(new XxxDTO()) 58 | }; 59 | // 调用API接口的 use 方法 60 | Object result = service.$invoke("use", paramTypes, params); 61 | System.out.println(result); 62 | } finally { 63 | // 销毁资源 64 | bean.destroy(); 65 | } 66 | } 67 | } 68 | ``` 69 | 70 | * 泛化调用可以用HashMap代替Pojo传参,只需Map中增加一个`class`属性指明Pojo类型,便于反序列化使用 71 | * `GenericService`对象创建较重,建议使用缓存。可参考`ReferenceConfigCache`类(`ReferenceConfigCache.getCache().get(genericService)`), 72 | 但其存在缓存无限制的弊端。 73 | 74 | 75 | ## 文档 76 | 77 | * [泛化调用(客户端泛化)](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/advanced-features-and-usage/service/generic-reference/) 78 | 79 | 80 | -------------------------------------------------------------------------------- /Microservice/Dubbo/Dubbo.md: -------------------------------------------------------------------------------- 1 | # Dubbo 2 | 3 | ## 配置 4 | 5 | * [配置工作原理](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/config/principle/) 6 | * [配置项参考手册](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/config/properties/) 7 | 8 | ## QOS 9 | 10 | * [QOS 操作手册](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/qos/) 11 | 12 | ## RPC 协议 13 | 14 | * RPC 协议 15 | * [协议概述](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/overview/) 16 | * [Dubbo协议](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/dubbo/) 17 | * [Triple协议](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/triple/) 18 | * [Rest协议](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/rest/) 19 | * [Rest 协议 - 提案](https://cn.dubbo.apache.org/zh-cn/overview/reference/proposals/protocol-http/) 20 | * [gRPC协议](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/grpc/) 21 | * [HTTP协议](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/http/) 22 | * [Rest 协议](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/v3.2_rest_protocol_design/) 23 | * [Thrift协议](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/thrift/) 24 | * [Rmi协议](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/rmi/) 25 | * [Redis协议](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/redis/) 26 | * [Hessian协议](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/hessian/) 27 | * [Webservice协议](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/webservice/) 28 | * [Memcached协议](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/protocol/memcached/) 29 | 30 | * 协议规范 31 | * [Triple 协议设计理念与规范](https://cn.dubbo.apache.org/zh-cn/overview/reference/protocols/triple/) 32 | * [Dubbo2 协议规范](https://cn.dubbo.apache.org/zh-cn/overview/reference/protocols/tcp/) 33 | * [HTTP 协议规范](https://cn.dubbo.apache.org/zh-cn/overview/reference/protocols/http/) 34 | 35 | ## 参考 36 | 37 | * [Apache dubbo 服务自省架构设计](https://mercyblitz.github.io/2020/05/11/Apache-Dubbo-%E6%9C%8D%E5%8A%A1%E8%87%AA%E7%9C%81%E6%9E%B6%E6%9E%84%E8%AE%BE%E8%AE%A1/) 38 | * [扩展点开发指南](https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/spi/description/dubbo-spi/#22-%E5%8A%A0%E8%BD%BD%E8%87%AA%E9%80%82%E5%BA%94%E6%89%A9%E5%B1%95%E7%B1%BB) 39 | * [Dubbo可扩展机制源码解析](https://cn.dubbo.apache.org/zh-cn/blog/2019/05/02/dubbo%E5%8F%AF%E6%89%A9%E5%B1%95%E6%9C%BA%E5%88%B6%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/) 40 | -------------------------------------------------------------------------------- /Test/Katalon.md: -------------------------------------------------------------------------------- 1 | ## Katalon 2 | 3 | 1. 文档 4 | 5 | * [API Documentation - 重要](https://api-docs.katalon.com/index.html) 6 | * [配置Katalon Studio(常用)](https://www.katalon.com/resources-center/tutorials/configure-katalon-studio-web-automation-test-project/) 7 | * [selenium DesiredCapabilities](https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities) 8 | * [自定义keyword](https://www.katalon.com/resources-center/tutorials/create-custom-keyword/) 9 | * [导入第三方jar包](https://www.katalon.com/resources-center/tutorials/import-java-library/) 10 | * 集成GIT 11 | * https://docs.katalon.com/display/KD/Git+Integration 12 | * https://www.katalon.com/resources-center/tutorials/git-integration-introduction/ 13 | * [Resolve Git conflicts using Katalon Studio](https://www.katalon.com/resources-center/tutorials/git-conflict-resolve/) 14 | * [Handling iFrame issue with Katalon Studio](https://www.katalon.com/resources-center/tutorials/handling-iframe-issue/) 15 | * [Solving Pop-up dialog issue with Katalon Studio](https://www.katalon.com/resources-center/tutorials/pop-up-dialog-issue/) 16 | * [How to Handle Alerts](https://www.katalon.com/resources-center/tutorials/handle-alerts/) 17 | * [File Uploads](https://www.katalon.com/resources-center/tutorials/handle-file-uploads/) 18 | * [命令行模式执行测试用例](https://www.katalon.com/resources-center/tutorials/executing-console-mode/) 19 | * 执行自动化测试常见问题 20 | * https://docs.katalon.com/display/KD/Troubleshooting+web+automated+testing 21 | * https://docs.katalon.com/display/KD/Troubleshooting+automated+mobile+testing 22 | * [配置web定位器](https://docs.katalon.com/display/KD/Web+Locators+Settings) 23 | * [Design a Test Suite](https://docs.katalon.com/display/KD/Design+a+Test+Suite) 24 | * [Variable Types](https://docs.katalon.com/display/KD/Variable+Types) 25 | * [Manage Test Object](https://docs.katalon.com/display/KD/Manage+Test+Object) 26 | * [Setup/Teardown for Test Suite and Test Case](https://docs.katalon.com/pages/viewpage.action?pageId=12419091) 27 | * [Test Listeners (Test Hooks)](https://docs.katalon.com/pages/viewpage.action?pageId=5126383) 28 | * [Failure Handling](https://docs.katalon.com/display/KD/Failure+Handling) 29 | * [Troubleshooting common issues related to interacting with an element](https://docs.katalon.com/display/KD/Troubleshooting+common+issues+related+to+interacting+with+an+element) 30 | * [Video Capturing](https://docs.katalon.com/display/KD/Video+Capturing) 31 | * [Parameterize Web/Mobile Test Object Properties](https://docs.katalon.com/pages/viewpage.action?pageId=12419075) 32 | * [Console Mode Execution](https://docs.katalon.com/display/KD/Console+Mode+Execution) 33 | * [Retrieve chromedriver.log and firefoxdriver.log when you run Record/Spy](https://docs.katalon.com/pages/viewpage.action?pageId=13698416) 34 | -------------------------------------------------------------------------------- /Microservice/Docker/Docker-compose安装及使用.md: -------------------------------------------------------------------------------- 1 | ## Docker-compose安装及使用 2 | 3 | ###CentOS安装docker-compose 4 | 5 | 1. 先安装`Docker Engine` 6 | 2. 安装`Docker Compose` 7 | 8 | ```bash 9 | # 从Github上下载Docker Compose 10 | shell> sudo curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose 11 | # 添加可执行权限 12 | shell> sudo chmod +x /usr/local/bin/docker-compose 13 | ``` 14 | 15 | > [安装文档 - 【官网】](https://docs.docker.com/compose/install/) 16 | 注: 如果通过`curl -L`下载的文件有问题可直接通过浏览器下载 17 | 18 | 3. 安装`bash`/`zsh` shell环境下的`command completion`(可选) 19 | 20 | #### Bash 21 | 22 | * 安装`bash-completion` 23 | 24 | Linux: 25 | ```bash 26 | # 查看本地是否已安装 27 | shell> yum list installed | grep bash-completion 28 | # 安装 bash-completion 29 | shell> yum install bash-completion 30 | # 使当前terminal的bash-completion生效(可选操作) 31 | shell> source /etc/profile.d/bash_completion.sh 32 | ``` 33 | 34 | Mac: 35 | ```bash 36 | # 安装 bash-completion 37 | shell> brew install bash-completion 38 | ``` 39 | 40 | * 下载Docker Compose的自动命令补全文件至`/etc/bash_completion.d/`(Mac系统路径为:`/usr/local/etc/bash_completion.d/`) 41 | 42 | ```bash 43 | shell> sudo curl -L https://raw.githubusercontent.com/docker/compose/1.16.1/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose 44 | ``` 45 | 46 | **Mac系统**添加以下脚本至`~/.bash_profile`: 47 | ```bash 48 | if [ -f $(brew --prefix)/etc/bash_completion ]; then 49 | . $(brew --prefix)/etc/bash_completion 50 | fi 51 | ``` 52 | `source ~/.bash_profile`使当前terminal 生效 53 | 54 | #### Zsh 55 | 56 | 下载自动补全脚本至`/path/to/zsh/completion`,例:`~/.zsh/completion/`: 57 | ```bash 58 | shell> mkdir -p ~/.zsh/completion 59 | shell> curl -L https://raw.githubusercontent.com/docker/compose/1.16.1/contrib/completion/zsh/_docker-compose > ~/.zsh/completion/_docker-compose 60 | ``` 61 | 62 | `$fpath`包含目录,例:`~/.zshrc`: 63 | ```bash 64 | fpath=(~/.zsh/completion $fpath) 65 | ``` 66 | 67 | 确保`compinit`已经加载或者把它添加进`~/.zshrc`: 68 | ```bash 69 | autoload -Uz compinit && compinit -i 70 | ``` 71 | 72 | 最后重启shell: 73 | ```bash 74 | exec $SHELL -l 75 | ``` 76 | 77 | > 注:[官方文档](https://docs.docker.com/compose/completion/) 78 | 79 | 4. 测试`Docker Compose` 80 | 81 | ```bash 82 | shell> docker-compose --version 83 | docker-compose version 1.16.1, build 1719ceb 84 | ``` 85 | 86 | > 注:`docker-compose`可以运行在`非swarm`环境中,`docker-compose.yml`的`3.x`版本可以兼容`docker swarm`(`docker stack deploy -c docker-compose.yml hello`) 87 | 88 | ###文档 89 | 90 | * [Get started - 重要](https://docs.docker.com/compose/gettingstarted/) 91 | * [Compose file语法 - 重要](https://docs.docker.com/compose/compose-file/) 92 | 93 | -------------------------------------------------------------------------------- /Java/Spring/SpringBoot/SpringBoot.md: -------------------------------------------------------------------------------- 1 | # Spring Boot 2 | 3 | ### 当使用YAML格式配置日志时,你可能会遇到配置的OFF日志级别无效,因为YAML会把`OFF`/`ON`解析成`Boolean`类型的`false`/`true`。 4 | 5 | **无效配置** 6 | ```yaml 7 | logging: 8 | level: 9 | root: info 10 | com.netflix.discovery: OFF 11 | ``` 12 | 13 | **有效配置**: 14 | ```yaml 15 | logging: 16 | level: 17 | root: info 18 | com.netflix.discovery: 'OFF' 19 | ``` 20 | 21 | ### 动态修改配置 22 | 23 | ``` 24 | POST http://dev.bone-cloud-zuul.banksteel.com/actuator/env 25 | { 26 | "name": "logging.level.org.springframework.security", 27 | "value": "debug" 28 | } 29 | ``` 30 | 31 | ### 开启`tomcat accesslog` 32 | 33 | ```yaml 34 | server: 35 | tomcat: 36 | # 指定tomcat的basedir,没有指定则使用系统临时目录 37 | basedir: "/data/tomcat" 38 | accesslog: 39 | enabled: true 40 | ``` 41 | 42 | ### Yaml Map Key 包含特殊字符,用方括号括起来 43 | 44 | ```yaml 45 | spring: 46 | cors: 47 | cors-configurations: 48 | "[/api/**]": 49 | allowed-origins: "*" 50 | allowed-methods: [GET, HEAD, POST] 51 | ``` 52 | > [Escaping a dot in a Map key in Yaml in Spring Boot - 解决YAML Key包含特殊字符问题](https://stackoverflow.com/questions/34070987/escaping-a-dot-in-a-map-key-in-yaml-in-spring-boot/34082891#34082891) 53 | 54 | ### SpringBoot-2.4 `spring.config.import` 55 | 56 | > [Config file processing in SpringBoot2.4](https://spring.io/blog/2020/08/14/config-file-processing-in-spring-boot-2-4) 57 | 58 | 59 | ### `spring.factories`中`EnableAutoConfiguration`加载顺序 60 | 61 | 1. 通过`ClassLoader`加载所有Jar的`META-INF/spring.factories` 62 | 2. 根据AutoConfiguration类全限定名排序 63 | 3. 通过`@AutoConfigureOrder`排序,默认值:0 64 | 4. 通过`@AutoConfigureBefore`、`@AutoConfigureAfter`排序 65 | 66 | 参考源码: 67 | * `org.springframework.core.io.support.SpringFactoriesLoader#loadSpringFactories(ClassLoader)` 68 | * `org.springframework.boot.autoconfigure.AutoConfigurationSorter#getInPriorityOrder(classNames)` 69 | 70 | ### SpringBoot Class 加载顺序 71 | 72 | `lib`包搜索顺序可以通过`new JarFileArchive(file)`打印出来,打包时默认为pom依赖顺序。高版本SpringBoot可以查看 Fat Jar 的`classpath.idx`文件。 73 | 74 | * [Spring Boot ClassLoader and Class Override](https://dkublik.github.io/2018/01/05/spring-boot-class-loader-and-class-override.html) 75 | 76 | 77 | ### Configuration Metadata 78 | 79 | 借助`spring-boot-configuration-processor`自动生成`spring-configuration-metadata.json`: 80 | ```xml 81 | 82 | org.springframework.boot 83 | spring-boot-configuration-processor 84 | true 85 | 86 | ``` 87 | 88 | #### Nested Properties 89 | 90 | The annotation processor automatically considers **inner classes** as nested properties. 91 | 92 | You can use the `@NestedConfigurationProperty` annotation on a field to indicate that a regular (**non-inner**) class should be treated as if it were nested. 93 | 94 | > This has no effect on `collections` and `maps`, as those types are **automatically** identified, 95 | and a single metadata property is generated for each of them. 所以这两种类型无需配置`@NestedConfigurationProperty`. 96 | 97 | > [参考文档](https://docs.spring.io/spring-boot/docs/current/reference/html/configuration-metadata.html#appendix.configuration-metadata.annotation-processor.automatic-metadata-generation.nested-properties) 98 | -------------------------------------------------------------------------------- /Web/JS/jquery-plugins/Select2.md: -------------------------------------------------------------------------------- 1 | ## Select2笔记 2 | 3 | ##### `【原创】` 4 | --- 5 | 6 | ###1. 自定义search规则 7 | 8 | ```html 9 | 10 | 11 | 12 | 13 | 14 | 15 | 20 | 21 | ``` 22 | 23 | ```javascript 24 | 25 | $("#select").select2({ 26 | //从头部开始匹配 27 | matcher: function(params, data) { 28 | params.term = params.term || ''; 29 | if (data.text.toUpperCase().indexOf(params.term.toUpperCase()) == 0) { 30 | return data; 31 | } 32 | return false; 33 | } 34 | }); 35 | 36 | ``` 37 | 38 | ###2. Ajax获取数据 39 | 40 | 1. HTML 41 | 42 | ```html 43 | 44 | 45 | 46 | 47 | 48 | 49 | 51 | 52 | ``` 53 | 54 | 2. JSON数据 55 | 56 | ```json 57 | { 58 | "total_count": "60", 59 | "items": [ 60 | {"id": "1", "name": "text1"}, 61 | {"id": "2", "name": "text2"}, 62 | {"id": "3", "name": "text3"}, 63 | {"id": "4", "name": "text4"}, 64 | {"id": "5", "name": "text5"}, 65 | {"id": "6", "name": "text6"}, 66 | {"id": "7", "name": "text7"}, 67 | {"id": "8", "name": "text8"}, 68 | {"id": "9", "name": "text9"}, 69 | {"id": "10", "name": "text10"}, 70 | {"id": "11", "name": "text11"}, 71 | {"id": "12", "name": "text12"}, 72 | {"id": "13", "name": "text13"}, 73 | {"id": "14", "name": "text14"}, 74 | {"id": "15", "name": "text15"}, 75 | {"id": "16", "name": "text16"}, 76 | {"id": "17", "name": "text17"}, 77 | {"id": "18", "name": "text18"}, 78 | {"id": "19", "name": "text19"}, 79 | {"id": "20", "name": "text20"} 80 | ] 81 | } 82 | ``` 83 | 84 | 3. JS 85 | 86 | ```javascript 87 | 88 | $("#select").select2({ 89 | ajax: { 90 | url: "./test.json", 91 | dataType: 'json', 92 | //延迟250毫秒后发送请求 93 | delay: 250, 94 | data: function(params) { 95 | return { 96 | name: params.term, 97 | page: params.page 98 | }; 99 | }, 100 | //转换数据格式 101 | processResults: function(data, params) { 102 | params.page = params.page || 1; 103 | return { 104 | results: data.items, 105 | pagination: { 106 | more: (params.page * 20) < data.total_count 107 | } 108 | }; 109 | }, 110 | cache: true 111 | }, 112 | //请求远程数据后格式化数据,Ajax请求必须重写此函数 113 | templateResult: function(repo) { 114 | if (repo.loading) return repo.text; 115 | return repo.name; 116 | }, 117 | //选中后显示的内容,Ajax请求必须重写此函数 118 | templateSelection: function(repo) { 119 | return repo.name; 120 | } 121 | }); 122 | 123 | ``` 124 | -------------------------------------------------------------------------------- /Test/抓包工具.md: -------------------------------------------------------------------------------- 1 | # 抓包工具 2 | 3 | ## mitmproxy 4 | 5 | mitmproxy is a set of tools that provide an interactive, SSL/TLS-capable intercepting proxy for HTTP/1, HTTP/2, and WebSockets. 6 | 7 | * Intercept HTTP & HTTPS requests and responses and modify them on the fly 8 | * Save complete HTTP conversations for later replay and analysis 9 | * Replay the client-side of an HTTP conversation 10 | * Replay HTTP responses of a previously recorded server 11 | * Reverse proxy mode to forward traffic to a specified server 12 | * Transparent proxy mode on macOS and Linux 13 | * Make scripted changes to HTTP traffic using Python 14 | * SSL/TLS certificates for interception are generated on the fly 15 | * Anticache 16 | * Blocklist 17 | * Client-side replay 18 | * Map Local 19 | * Map Remote 20 | * Modify Body 21 | * Modify Headers 22 | * Proxy Authentication 23 | * Server-side replay 24 | * Sticky Auth 25 | * Sticky Cookies 26 | * Streaming 27 | 28 | > [官网 - mitmproxy](https://www.mitmproxy.org/) 29 | 30 | 31 | ## fiddler 32 | 33 | 34 | ## charles 35 | 36 | ## tcpdump 37 | 38 | tcpdump指令常用选项: 39 | 40 | * `-i interface`|`--interface=interface` - 采集指定网卡的数据,`any`指采集所有网卡。 41 | * `-s snaplen`|`--snapshot-length=snaplen` - 采集数据时每个包的最大采集上限,默认值:262144 bytes。 42 | * `-C file_size` - 数据存储至文件时,文件的大小限制。单位:MB(1,000,000 bytes) 43 | * `-G rotate_seconds` - 指定新文件生成的周期。 44 | * `-w file` - 数据写入指定文件,而非控制台。 45 | * `-z postrotate-command` - 周期性生成新文件后对原文件执行的命令,如用`-z gzip`或`-z bzip2`来压缩文件。 46 | * `-n` - 主机地址不转换为对应名称,避免DNS查询。 47 | * `-nn` - 不转换协议、端口、主机地址。 48 | * `-v` - When parsing and printing, produce (slightly more) verbose output. For example, the time to live, identification, 49 | total length and options in an IP packet are printed. Also enables additional packet integrity checks such as verifying 50 | the IP and ICMP header checksum.When writing to a file with the -w option, report, every 10 seconds, the number of packets captured. 51 | * `-vv` - Even more verbose output. For example, additional fields are printed from NFS reply packets, and SMB packets are fully decoded. 52 | * `-vvv` - Even more verbose output. For example, telnet SB ... SE options are printed in full. With -X Telnet options are printed in hex as well. 53 | * `expression` - 数据包的过滤表达式,如`host 192.168.1.1`、`src host 192.168.1.1`、`tcp port 80`。 54 | 参考官方文档:[pcap-filter(7) man page](https://www.tcpdump.org/manpages/pcap-filter.7.html) 55 | 56 | 使用示例: 57 | ```shell 58 | shell> tcpdump -i any -C 50 -G 3600 -w tcpdump-%m-%d-%H.pcap -z gzip host 192.168.100.100 59 | ``` 60 | 61 | > tcpdump相关文章: 62 | > * [抓包神器TCPDUMP的分析总结-涵盖各大使用场景、高级用法](https://cloud.tencent.com/developer/article/1858612) 63 | 64 | > TCP相关文章: 65 | > * [超超超详细讲解TCP三次握手与四次挥手(大图解),值得收藏](https://zhuanlan.zhihu.com/p/591865232) 66 | > * [一文彻底搞懂 TCP三次握手、四次挥手过程及原理](https://zhuanlan.zhihu.com/p/108504297) 67 | 68 | 69 | ## Wireshark 70 | 71 | * [Wireshark - 官方操作手册](https://www.wireshark.org/docs/wsug_html/) 72 | * [wireshark-filter(4) Manual Page](https://www.wireshark.org/docs/man-pages/wireshark-filter.html) - 【重要】Wireshark过滤器文档 73 | 74 | ### Wireshark支持Dubbo协议 75 | 76 | 下载支持Dubbo协议的lua脚本:https://github.com/apache/dubbo/files/12620811/dubbo.txt 。 77 | 下载后重命名为`dubbo.lua`,放置于安装地址的`plugins`目录下,然后重启 Wireshark。 78 | 79 | > 注:此Dubbo脚本只是临时编写,兼容性不佳。 80 | -------------------------------------------------------------------------------- /Monitor/综合.md: -------------------------------------------------------------------------------- 1 | # 综合 2 | 3 | ## APM 4 | 5 | ### Glowroot 6 | [Glowroot](https://github.com/glowroot/glowroot) is a fast, clean, and easy to use open source Java APM. It enables you to trace capture for slow requests and mistakes, 7 | as well as log time follow for every user action, SQL catch, and aggregation. The tool further features a historical roll-up of 8 | all information with configurable maintenance and provides charts to visualize time breakdown and response time percentiles. 9 | With its interactive UI, you can track your app from desktop and mobile devices alike. 10 | 11 | ### Pinpoint 12 | A free and open source APM solution, [Pinpoint](https://github.com/naver/pinpoint) can help you monitor the performance 13 | of complex distributed systems written in Java and PHP. It looks at the structure of your system and how its components 14 | are interconnected, by tracing transactions across distributed applications. You can track active threads in real time, 15 | see request count and response patterns, as well as JVM performance metrics such as CPU and memory usage, garbage collection 16 | and JVM arguments. 17 | 18 | ### JavaMelody 19 | [JavaMelody](https://github.com/javamelody/javamelody) is a free and open source APM tool designed to monitor Java or 20 | Java EE applications in QA and production environments. Seeing as it doesn’t include a database or profiling, JavaMelody 21 | is a lightweight solution which can be easily integrated into most applications. 22 | 23 | ### Scouter 24 | [Scouter](https://github.com/scouter-project/scouter) calls itself the free and open source alternative to New Relic and 25 | AppDynamics’ APM. It shows metrics like user activity, service activity (TPS, response time, SQL profiling, and more), 26 | and resource consumption metrics (CPU, memory usage, heap memory). 27 | 28 | ### Stagemonitor 29 | [Stagemonitor](https://github.com/stagemonitor/stagemonitor) is a community-developed tool designed for clustered application stack. 30 | That means that you can use it to monitor development, testing, and production of Java-based applications that are running on 31 | multiple servers while keeping a low overhead. It integrates with time series databases (TDSB) such as Elasticsearch, Graphite, 32 | and InfluxDB. With Stagemonitor, you can view historical or live data from the cluster or the developer server, create custom alerts, 33 | and set thresholds for each metric. It also allows you to create custom dashboards to visualize and analyze metrics. 34 | 35 | ### MoSKito 36 | [MoSKito](https://github.com/anotheria/moskito) is a complete toolset for DevOps to monitor the performance and behavior 37 | of Java applications. It collects, analyzes, and stores in real time all critical performance metrics such as memory, CPU, threads, 38 | caches, load distribution, and many more. It works with all major app servers such as Tomcat, JBoss, Jetty, WebLogic, doesn’t 39 | require code change and keeps your data private. You can set thresholds and notification alerts, record user activity, 40 | and provides a clean dashboard to monitor all application processes in multi nodes production environments. 41 | 42 | 43 | 44 | ## 参考文档 45 | 46 | * [20+ Best Log Management Tools for Monitoring, Analytics & More: Pros & Cons Comparison [2021]](https://sematext.com/blog/best-log-management-tools/) 47 | 48 | -------------------------------------------------------------------------------- /DB/Cache/memcached/Memcached安装及使用.md: -------------------------------------------------------------------------------- 1 | ## Memcached安装及使用 2 | 3 | ### Memcached安装 4 | 5 | Memcached安装非常简单: 6 | 7 | Debian/Ubuntu: apt-get install libevent-dev Redhat/Centos: yum install libevent-devel 8 | 9 | ```bash 10 | wget http://memcached.org/latest 11 | tar -zxvf memcached-1.x.x.tar.gz 12 | cd memcached-1.x.x 13 | ./configure && make && make test && sudo make install 14 | ``` 15 | 16 | ### Memcached客户端使用 17 | 18 | 满怀热情的看完Memcached及Memcached Client各实现版本,本来想用Memcached做缓存服务器使用的。但具体实用时,发现Memcached做得事情非常有限,归咎于它的设计适用于简单的key - value存储,并没有namespace/group这一说法。只能继续找其他的缓存方案,下面贴出使用例子: 19 | 20 | 客户端使用xmemcached,并使用simple-spring-memcached的注解形式 21 | 22 | 1. pom文件配置 23 | 24 | ```xml 25 | 3.6.0 26 | .... 27 | 28 | com.google.code.simple-spring-memcached 29 | simple-spring-memcached 30 | ${simple.spring.memcached.version} 31 | 32 | 33 | com.google.code.simple-spring-memcached 34 | xmemcached-provider 35 | ${simple.spring.memcached.version} 36 | 37 | ``` 38 | 2. spring配置文件 39 | 40 | ```xml 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | ``` 62 | 3. JAVA注解 63 | 64 | ```java 65 | @Override 66 | @ReadThroughSingleCache(namespace = GlobalConstants.CACHE_KEY_ROLE) 67 | public Role load(@ParameterValueKeyProvider Integer id) { 68 | return super.get(id, OpenClose.OPEN, OpenClose.CLOSE); 69 | } 70 | ``` 71 | 72 | ```java 73 | //测试代码 ======= 显示Memcached所有的key - value 74 | public void listCacheObjs() throws Exception { 75 | final String ip = "10.0.11.135:11211"; 76 | 77 | MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses(ip)); 78 | MemcachedClient client = builder.build(); 79 | KeyIterator it = client.getKeyIterator(AddrUtil.getOneAddress(ip)); 80 | while (it.hasNext()) { 81 | String key = it.next(); 82 | LOG.info("====== Key/value : {0} / {1}", key, client.get(key)); 83 | } 84 | } 85 | ``` 86 | 87 | 使用就是这么简单,但功能也比较单一,适合简单的key-value场景。 88 | 89 | > 注意事项: 90 | > 1.`@ReadThroughSingleCache` 作为一个cache存储,即不管你返回值是List还是int,统统转成字符窜后存储。`@ReadThroughMultiCache` list数据是作为多个cache存储,且方法的参数必须包含list的参数。`@ReadThroughAssignCache` 自定义cache的KEY值。 91 | > 2. 如果方法的参数为一个Entity对象,则需要在主键的get方法上加上`@CacheKeyMethod`注解,表明此Entity生成key的方法为此主键的get方法。如果对象为联合主键,则自己建一个`public String cacheKey() { ... }`,在此方法上加上`@CacheKeyMethod`就可以了。如果没有`@CacheKeyMethod`注解,则使用此对象的`toString`方法生成KEY。标记`@CacheKeyMethod`注解的方法必须返回`String`。 92 | 93 | -------------------------------------------------------------------------------- /Microservice/分布式ID.md: -------------------------------------------------------------------------------- 1 | # 分布式ID 2 | 3 | ## Snowflake - 雪花算法 4 | 5 | * 优点: 6 | * 生成速度快 7 | * 实现简单,没有多余的依赖 8 | * 可以根据实际情况调整各个位段,方便灵活 9 | * 缺点: 10 | * 只能趋势递增 11 | * 依赖机器时间. 如果发生回拨可能会造成生成的ID重复 12 | * 前后端交互接口需要注意**精度丢失**问题。 13 | 14 | > JS只有`Number`这一种数值类型,用`64-bit IEEE 754`双精度浮点数存储,这意味着不仅仅小数会丢失精度,**大于9007199254740991(16位数字)的整数** /`2^53-1`/`Number.MAX_SAFE_INTEGER` 15 | 也会存在丢失精度的风险。而雪花算法的Long值都非常大,很容易出现精度丢失问题,需要后端把数值转换成字符串类型,可借助于`Jackson`的`WRITE_NUMBERS_AS_STRINGS: true`功能实现。 16 | 17 | ### 时间回拨 18 | 19 | * 产生原因: 20 | * 机器需要同步时间服务器 21 | * 解决方案: 22 | * 当回拨时间小于X,可以等待时间追上来以后再继续生成 23 | * 当回拨时间大于X 时可以通过更换workId来产生之前都没有产生过的Id来解决回拨问题 24 | 25 | ### 参考 26 | 27 | * [雪花算法:分布式唯一ID生成利器](https://segmentfault.com/a/1190000041445831) 28 | * Seata 29 | * [Seata基于改良版雪花算法的分布式UUID生成器分析](https://seata.io/zh-cn/blog/seata-analysis-UUID-generator.html) 30 | * [Seata - 关于新版雪花算法的答疑](https://seata.io/zh-cn/blog/seata-snowflake-explain.html) 31 | * [雪花算法把玩](http://yang.observer/2020/08/30/snowflake/) 32 | * 各场景下WorkerID如何生成 33 | * 系统时间回退怎么办 34 | * [多时钟 解决雪花算法的时间回拨问题](https://blog.hackerpie.com/posts/algorithms/snowflake/multiple-clocks-snowflake/) 35 | * [SnowFlake 雪花算法生成分布式 ID](http://learn.lianglianglee.com/%E6%96%87%E7%AB%A0/SnowFlake%20%E9%9B%AA%E8%8A%B1%E7%AE%97%E6%B3%95%E7%94%9F%E6%88%90%E5%88%86%E5%B8%83%E5%BC%8F%20ID.md) - 参考实现 36 | 37 | ## Butterfly 38 | 39 | 雪花算法的改良方案,**思路可作参考**。 40 | 41 | > [Butterfly 官网](https://www.yuque.com/simonalong/butterfly/tul824) 42 | 43 | 44 | ## UidGenerator 45 | 46 | UidGenerator 基于Snowflake算法的Java唯一ID生成器。UidGenerator以组件形式工作在应用项目中, 支持自定义workerId位数和初始化策略, 47 | 从而适用于docker等虚拟化环境下实例自动重启、漂移等场景。 在实现上, UidGenerator通过借用未来时间来解决sequence天然存在的并发限制; 48 | 采用RingBuffer来缓存已生成的UID, 并行化UID的生产和消费, 同时对CacheLine补齐,避免了由RingBuffer带来的硬件级「伪共享」问题. 最终单机QPS可达600万。 49 | 50 | * [UidGenerator 文档](https://github.com/baidu/uid-generator/blob/master/README.zh_cn.md) 51 | 52 | > 注:UidGenerator 依赖DB 生产 WorkerId 53 | 54 | 55 | ## Leaf 56 | 57 | Leaf是美团基础研发平台推出的一个分布式ID生成服务。 58 | 59 | Leaf 提供两种生成的ID的方式(号段模式和snowflake模式),你可以同时开启两种方式,也可以指定开启某种方式(默认两种方式为关闭状态)。 60 | 61 | * [Leaf——美团点评分布式ID生成系统](https://tech.meituan.com/2017/04/21/mt-leaf.html) 62 | * [Leaf:美团分布式ID生成服务开源](https://tech.meituan.com/2019/03/07/open-source-project-leaf.html) 63 | * [使用文档 - Github](https://github.com/Meituan-Dianping/Leaf/blob/master/README_CN.md) 64 | * [Spring-Boot-Start](https://github.com/Meituan-Dianping/Leaf/blob/feature/spring-boot-starter/README_CN.md) 65 | 66 | 67 | ## Tinyid 68 | 69 | Tinyid是用Java开发的一款分布式id生成系统,基于数据库号段算法实现,关于这个算法可以参考美团leaf或者tinyid原理介绍。Tinyid扩展了leaf-segment算法, 70 | 支持了多db(master),同时提供了java-client(sdk)使id生成本地化,获得了更好的性能与可用性。 71 | 72 | * [概要 - Github](https://github.com/didi/tinyid/wiki) 73 | * [Getting started](https://github.com/didi/tinyid/wiki/Getting-started) 74 | * [Tinyid client config](https://github.com/didi/tinyid/wiki/Tinyid-client-config) 75 | * [Tinyid server config](https://github.com/didi/tinyid/wiki/Tinyid-server-config) 76 | * [Tinyid原理介绍](https://github.com/didi/tinyid/wiki/Tinyid%E5%8E%9F%E7%90%86%E4%BB%8B%E7%BB%8D) 77 | 78 | ## CosId -【推荐】 79 | 80 | 通用、灵活、高性能分布式ID生成器 81 | * 支持多种类型的分布式ID算法:SnowflakeId、SegmentId、SegmentChainId。 并且支持多种号段分发器、机器号分发器。 82 | * 通过简单配置即可自定义切换多种算法实现,定制以满足场景需要。 83 | * 设计极致优化,SegmentChainId 性能可达到近似 AtomicLong 的 TPS 性能:12743W+/s。 84 | 85 | > [官方文档](https://cosid.ahoo.me/guide/) 86 | 87 | > [Github 文档](https://github.com/Ahoo-Wang/CosId) - 配置文档相对全面 88 | 89 | -------------------------------------------------------------------------------- /linux/关闭TransparentHugePages (THP).md: -------------------------------------------------------------------------------- 1 | ## Disable Transparent Huge Pages (THP) 2 | 3 | ##### 翻译自MongoDB的官方文档 4 | --- 5 | 6 | Transparent Huge Pages (THP)是Linux内存管理系统。当你的机器使用大量的larger memory pages时,THP能减少Translation Lookaside Buffer (TLB)查询性能的开销。 7 | 然而,当THP应用于数据库时,表现不佳。 8 | 9 | 10 | 1. 创建 init.d script 11 | 创建/etc/init.d/disable-transparent-hugepages文件,内容如下: 12 | 13 | ```bash 14 | #!/bin/sh 15 | ### BEGIN INIT INFO 16 | # Provides: disable-transparent-hugepages 17 | # Required-Start: $local_fs 18 | # Required-Stop: 19 | # X-Start-Before: mongod mongodb-mms-automation-agent 20 | # Default-Start: 2 3 4 5 21 | # Default-Stop: 0 1 6 22 | # Short-Description: Disable Linux transparent huge pages 23 | # Description: Disable Linux transparent huge pages, to improve 24 | # database performance. 25 | ### END INIT INFO 26 | 27 | case $1 in 28 | start) 29 | if [ -d /sys/kernel/mm/transparent_hugepage ]; then 30 | thp_path=/sys/kernel/mm/transparent_hugepage 31 | elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then 32 | thp_path=/sys/kernel/mm/redhat_transparent_hugepage 33 | else 34 | return 0 35 | fi 36 | 37 | echo 'never' > ${thp_path}/enabled 38 | echo 'never' > ${thp_path}/defrag 39 | 40 | unset thp_path 41 | ;; 42 | esac 43 | ``` 44 | 45 | 2. 赋予可执行权限 46 | ```bash 47 | sudo chmod 755 /etc/init.d/disable-transparent-hugepages 48 | ``` 49 | 50 | 3. 启动服务 51 | 52 | > service disable-transparent-hugepages start 53 | 54 | 4. 开机自启服务 55 | 56 | | Linux版本 | 命令 | 57 | | ------------- | ----------- | 58 | | Ubuntu and Debian | sudo update-rc.d disable-transparent-hugepages defaults| 59 | | SUSE | sudo insserv /etc/init.d/disable-transparent-hugepages | 60 | | Red Hat, CentOS, Amazon Linux, and derivatives | sudo chkconfig --add disable-transparent-hugepages | 61 | 62 | 5. 如果你使用了**tuned** 或者 **ktune**,你需要重新配置(**当系统为 Red Hat 或 CentOS 6+ 时**) 63 | 当你使用**tuned** 或者 **ktune**时,你需要修改或新建一个profile来设置THP为`never` 64 | 65 | * Red Hat/CentOS 6 66 | 1. 创建一个新profile 67 | 68 | > sudo cp -r /etc/tune-profiles/default /etc/tune-profiles/no-thp 69 | 70 | 2. 编辑ktune.sh 71 | 编辑/etc/tune-profiles/no-thp/ktune.sh。添加如下代码到ktune.sh文件的start()代码块中且在`return 0`语句之前: 72 | 73 | > set_transparent_hugepages never 74 | 75 | 3. 启用新建的profile 76 | 77 | >sudo tuned-adm profile no-thp 78 | 79 | * Red Hat/CentOS 7 80 | 1. 创建一个新profile 81 | 创建一个tuned profile目录: 82 | 83 | > sudo mkdir /etc/tuned/no-thp 84 | 85 | 2. 编辑tuned.conf 86 | 创建/etc/tuned/no-thp/tuned.conf文件。文件内包含: 87 | 88 | ```bash 89 | [main] 90 | include=virtual-guest 91 | 92 | [vm] 93 | transparent_hugepages=never 94 | ``` 95 | 96 | 3. 启用新建的profile 97 | 98 | >sudo tuned-adm profile no-thp 99 | 100 | 6. 测试 101 | 你可以通过如下命令来检查THP的是否关闭: 102 | 103 | ```bash 104 | cat /sys/kernel/mm/transparent_hugepage/enabled 105 | cat /sys/kernel/mm/transparent_hugepage/defrag 106 | ``` 107 | 108 | 在Red Hat Enterprise Linux、CentOS、或其他的Red Hat衍生品系统中,你可以替换成下面的命令: 109 | 110 | ```bash 111 | cat /sys/kernel/mm/redhat_transparent_hugepage/enabled 112 | cat /sys/kernel/mm/redhat_transparent_hugepage/defrag 113 | ``` 114 | 115 | 最终显示的结果应该为: 116 | 117 | > always madvise [never] -------------------------------------------------------------------------------- /DistributedStorage/Ceph.md: -------------------------------------------------------------------------------- 1 | # Ceph 2 | 3 | ## 参考 4 | 5 | * [Ceph文档 - 英文](https://docs.ceph.com/en/latest/) 6 | * [Ceph文档 - 中文](http://docs.ceph.org.cn/) 7 | 8 | * [Ceph分布式存储工作原理 及 部署介绍](https://www.cnblogs.com/kevingrace/p/8387999.html) 9 | * [ceph介绍](https://www.yinxiang.com/everhub/note/1a22d46e-6d37-4603-b2e3-7cb6c7af610c) 10 | * [CRUSH(Controlled Replication Under Scalable Hashing)算法的原理与实现](https://zhuanlan.zhihu.com/p/58888246) 11 | 12 | * [use cases / reference architectures](https://ceph.io/use-cases/) 13 | * [[2019] – SUSE Enterprise Storage on HPE ProLiant](https://ceph.io/use-cases/#suse-enterprise-storage-on-hpe-proliant) 14 | * [[2019] – SUSE Enterprise Storage on Lenovo ThinkSystem](https://ceph.io/use-cases/#suse-enterprise-storage-on-lenovo-thinksystem) 15 | * [[2019] – SUSE Enterprise Storage and Veeam Backup and Restore](https://ceph.io/use-cases/#suse-enterprise-storage-and-veeam-backup-and-restore) 16 | * [[2019] – SUSE Enterprise Storage on Dell EMC PowerEdge Server](https://ceph.io/use-cases/#suse-enterprise-storage-on-dell-emc-poweredge-server) 17 | * [[2018] – Red Hat Ceph Storage on Intel Processors and SSDs](https://ceph.io/use-cases/#red-hat-ceph-storage-on-intel-processors-and-ssds) 18 | * [[2017] – SUSE Enterprise Storage and Commvault Data Platform](https://ceph.io/use-cases/#suse-enterprise-storage-and-commvault-data-platform) 19 | * [[2017] – Red Hat Ceph Storage on QCT Servers: Object Storage Performance and Sizing Guide](https://ceph.io/use-cases/#red-hat-ceph-storage-on-qct-servers-object-storage-performance-and-sizing-guide) 20 | * [[2017] – Understanding a Multi-Site Ceph Gateway Installation](https://ceph.io/use-cases/#understanding-a-multi-site-ceph-gateway-installation) 21 | * [[2017] – Hyper Converged Red Hat OpenStack Platform 10 and Red Hat Ceph Storage 2](https://ceph.io/use-cases/#hyper-converged-red-hat-openstack-platform-10-and-red-hat-ceph-storage-2) 22 | * [[2017] – Dell EMC DSS 7000 with Red Hat Ceph Storage 2](https://ceph.io/use-cases/#dell-emc-dss-7000-with-red-hat-ceph-storage-2) 23 | * [[2016] – High-Performance Cluster Storage for IOPS Workloads](https://ceph.io/use-cases/#high-performance-cluster-storage-for-iops-workloads) 24 | * [[2016] – Ceph on NetApp E-Series](https://ceph.io/use-cases/#ceph-on-netapp-e-series) 25 | * [[2016] – MySQL Databases on Red Hat Ceph Storage](https://ceph.io/use-cases/#mysql-databases-on-red-hat-ceph-storage) 26 | * [[2016] – Red Hat Ceph Storage on Dell Poweredge R730XD](https://ceph.io/use-cases/#red-hat-ceph-storage-on-dell-poweredge-r730xd) 27 | * [[2016] – Red Hat Ceph Storage on Supermicro Storage Servers](https://ceph.io/use-cases/#red-hat-ceph-storage-on-supermicro-storage-servers) 28 | * [[2016] – Cisco UCS C3160 high Density Rack Server with Red Hat Ceph Storage](https://ceph.io/use-cases/#cisco-ucs-c3160-high-density-rack-server-with-red-hat-ceph-storage) 29 | * [[2016] – Accelerating Ceph for Database Workloads With an All PCIe SSD Cluster](https://ceph.io/use-cases/#accelerating-ceph-for-database-workloads-with-an-all-pcie-ssd-cluster) 30 | * [[2016] – Red Hat Ceph Storage on QCT Servers](https://ceph.io/use-cases/#red-hat-ceph-storage-on-qct-servers) 31 | * [[2016] – Cisco UCS Integrated Infrastructure with RHEL OSP and Red Hat Ceph Storage](https://ceph.io/use-cases/#cisco-ucs-integrated-infrastructure-with-rhel-osp-and-red-hat-ceph-storage) 32 | * [[2014] – Ceph@Home: The domestication of a wild cephalopod](https://ceph.io/use-cases/#cephhome-the-domestication-of-a-wild-cephalopod) -------------------------------------------------------------------------------- /Template&MarkupLanguage/JSON/Jackson.md: -------------------------------------------------------------------------------- 1 | ## Jackson 2 | 3 | * [Jackson JSON Tutorial](https://www.baeldung.com/jackson) 4 | * [Jackson 框架的高阶应用](https://www.ibm.com/developerworks/cn/java/jackson-advanced-application/index.html) 5 | * [Jackson ObjectMapper](http://tutorials.jenkov.com/java-json/jackson-objectmapper.html) 6 | * [Jackson JsonNode](http://tutorials.jenkov.com/java-json/jackson-jsonnode.html) 7 | * [Jackson JsonParser](http://tutorials.jenkov.com/java-json/jackson-jsonparser.html) 8 | * [Jackson JsonGenerator](http://tutorials.jenkov.com/java-json/jackson-jsongenerator.html) 9 | * [Jackson Annotations](http://tutorials.jenkov.com/java-json/jackson-annotations.html) 10 | 11 | ### 总结 12 | 13 | * 使用Jackson序列化对象时,如果对象的某个属性使用了JDK动态代理(属性的实际类型为代理类), 14 | 则使用Jackson反序列化时会抛异常。此时可使用以下方案解决(针对动态代理的属性类型使用JDK序列化): 15 | 16 | ```java 17 | import com.easycodebox.spring.cloud.oauth2.AccessTokenRequestMixin.AccessTokenRequestDeserializer; 18 | import com.easycodebox.spring.cloud.oauth2.AccessTokenRequestMixin.AccessTokenRequestSerializer; 19 | import com.fasterxml.jackson.annotation.JsonTypeInfo; 20 | import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; 21 | import com.fasterxml.jackson.core.JsonGenerator; 22 | import com.fasterxml.jackson.core.JsonParser; 23 | import com.fasterxml.jackson.databind.DeserializationContext; 24 | import com.fasterxml.jackson.databind.JsonDeserializer; 25 | import com.fasterxml.jackson.databind.JsonSerializer; 26 | import com.fasterxml.jackson.databind.SerializerProvider; 27 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 28 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 29 | import java.io.IOException; 30 | import java.util.Map; 31 | import org.springframework.security.oauth2.client.token.AccessTokenRequest; 32 | import org.springframework.security.oauth2.common.util.SerializationUtils; 33 | 34 | /** 35 | * 当启用{@link org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client}时, 36 | * 会初始化{@link org.springframework.security.oauth2.config.annotation.web.configuration.OAuth2ClientConfiguration#accessTokenRequest(Map, String)} Bean, 37 | * 而此{@code AccessTokenRequest} Bean为 request scope bean,此bean为代理bean,所以通过Jackson反序列化时会失败。 38 | * 39 | * @author WangXiaoJin 40 | * @date 2019-05-31 16:04 41 | */ 42 | @JsonTypeInfo(use = Id.NONE) 43 | @JsonSerialize(using = AccessTokenRequestSerializer.class) 44 | @JsonDeserialize(using = AccessTokenRequestDeserializer.class) 45 | public class AccessTokenRequestMixin { 46 | 47 | public static class AccessTokenRequestDeserializer extends JsonDeserializer { 48 | 49 | @Override 50 | public AccessTokenRequest deserialize(JsonParser p, DeserializationContext des) 51 | throws IOException { 52 | return SerializationUtils.deserialize(p.getBinaryValue()); 53 | } 54 | } 55 | 56 | public static class AccessTokenRequestSerializer extends JsonSerializer { 57 | 58 | @Override 59 | public void serialize(AccessTokenRequest value, JsonGenerator gen, SerializerProvider serializers) 60 | throws IOException { 61 | gen.writeBinary(SerializationUtils.serialize(value)); 62 | } 63 | } 64 | } 65 | ``` 66 | 67 | ```java 68 | ObjectMapper mapper = new ObjectMapper(); 69 | //启用自定义的Mixin 70 | mapper.addMixIn(AccessTokenRequest.class, AccessTokenRequestMixin.class); 71 | // 开启默认的DefaultTyping 72 | mapper.enableDefaultTyping(DefaultTyping.NON_FINAL, As.PROPERTY); 73 | ``` 74 | 75 | * 自定义第三方框架的 序列化/反序列化 规则:参考 `spring-security-core`的`org.springframework.security.jackson2.CoreJackson2Module`类 -------------------------------------------------------------------------------- /Java/OSGi - Jigsaw.md: -------------------------------------------------------------------------------- 1 | # OSGi - Jigsaw 2 | 3 | ## OSGi 4 | 5 | There are a number of commercial and open source OSGi framework implementations. The open source options include `Apache 6 | Felix`, `Eclipse Concierge`, `Eclipse Equinox`, `Knopflerfish`. 7 | 8 | ### 文档 9 | 10 | * [enRoute Tutorials](https://enroute.osgi.org/) - enRoute Tutorials and Examples provide a simple developer onramp for 11 | those unfamiliar with OSGi™. 12 | 13 | * [官网](https://www.osgi.org/developer/where-to-start/) 14 | 15 | * [OSGi模块化框架详解](http://www.uml.org.cn/zjjs/201905273.asp) 16 | 17 | ### 插件 18 | 19 | #### bnd-maven-plugin 20 | 21 | The bnd-maven-plugin is a key plugin when producing OSGi bundles. The bnd-maven-plugin is responsible for parsing the bytecode 22 | of the classes included in the JAR file being produced by a Maven module. Based on the discovered annotations and dependencies 23 | the bnd-maven-plugin will construct an OSGi Manifest file for the bundle, and any other required metadata 24 | (for example Declarative Services XML descriptors). 25 | 26 | #### bnd-export-maven-plugin 27 | 28 | The bnd-export-maven-plugin is used to export an OSGi application as a runnable JAR. The input to the bnd-export-maven-plugin 29 | is a bndrun file. This file declares a set of bundles and launch properties that should be used to start an OSGi framework 30 | containing the application. 31 | 32 | #### bnd-indexer-maven-plugin 33 | 34 | The bnd-indexer-maven-plugin is used to generate an OSGi repository index from the set of maven dependencies in your module’s pom. 35 | This repository index can be used for resolving or exporting the application. 36 | 37 | #### bnd-resolver-maven-plugin 38 | 39 | The bnd-resolver-maven-plugin is not normally part of the main build, but it can be used from the command line to resolve 40 | an application or integration testing bndrun. This resolve operation takes a set of run requirements and uses an OSGi repository 41 | index to find the complete set of bundles that need to b deployed to satisfy the run requirements. 42 | 43 | #### bnd-baseline-maven-plugin 44 | 45 | The bnd-baseline-maven-plugin is used to validate the semantic versioning of a bundle’s exported API by comparing it against 46 | the last released version. This plugin will fail the build if the API version has not been increased when a change has been made, 47 | or if the version increase is insufficient to communicate the semantics of the change. 48 | 49 | #### bnd-testing-maven-plugin 50 | 51 | The bnd-testing-maven-plugin is used to provide bundle-level testing. The tests are written using JUnit and packaged into 52 | a tester bundle (often produced in the same build project). The bnd-testing-maven-plugin then uses one or more bndrun files 53 | to launch an OSGi framework containing the tester bundle and the bundles under test. The test cases are then run by the 54 | bnd-testing-maven-plugin. 55 | 56 | 57 | 58 | ## Karaf 59 | 60 | 61 | ## Apache Felix 62 | 63 | 64 | ## Eclipse Equinox 65 | 66 | 67 | 68 | ## Jigsaw 69 | 70 | ### 文档 71 | 72 | * [Jigsaw - 官网](http://openjdk.java.net/projects/jigsaw/) 73 | * [java9 模块化 jigsaw](https://www.cnblogs.com/krcys/p/8657282.html) 74 | 75 | 76 | 77 | 78 | ## 杂项 79 | 80 | * [Java 9,OSGi和模块化的未来(1)](https://mindawei.github.io/2018/02/05/Java-9%EF%BC%8COSGi%E5%92%8C%E6%A8%A1%E5%9D%97%E5%8C%96%E7%9A%84%E6%9C%AA%E6%9D%A5%EF%BC%881%EF%BC%89/) 81 | * [Java 9,OSGi和模块化的未来(2)](https://mindawei.github.io/2018/02/06/Java-9%EF%BC%8COSGi%E5%92%8C%E6%A8%A1%E5%9D%97%E5%8C%96%E7%9A%84%E6%9C%AA%E6%9D%A5%EF%BC%882%EF%BC%89/) 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /Java/Spring/SpringBoot/Fat-Jar排除指定包.md: -------------------------------------------------------------------------------- 1 | # Fat-Jar排除指定包 2 | 3 | ## 1. Spring-Boot-Jar-Type 4 | 5 | `spring-boot-maven-plugin` 在打包时会获取 jar 包中 `MANIFEST.MF` 的 `Spring-Boot-Jar-Type`属性值,如果值为 6 | `dependencies-starter` 或 `annotation-processor`,则此jar不会被打进 fat-jar 中,但是此jar的依赖包不受任何影响。 7 | 8 | 可以借助此功能忽略SpringBoot项目中的`starter`及`annotation-processor`包,因为这两种类型的包在应用运行时根本就用不到。 9 | 10 | > 建议使用此方案 11 | 12 | 参考示例: 13 | ```xml 14 | 15 | 16 | 17 | org.apache.maven.plugins 18 | maven-jar-plugin 19 | 20 | 21 | 25 | false 26 | 27 | true 28 | true 29 | 30 | 31 | 36 | dependencies-starter 37 | 38 | 39 | 40 | 41 | 42 | 43 | ``` 44 | 45 | 参考链接: 46 | * [spring-boot-maven-plugin 插件源码](https://github.com/spring-projects/spring-boot/blob/c59d474ec4e586a437c50afd6b19ae6973d4db64/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/JarTypeFilter.java#L49) 47 | 48 | ## 2. spring-boot-maven-plugin 插件 exclude 功能 49 | 50 | ### 方法一 51 | 52 | 排除指定的`groupId`、`artifactId`,如有需要可以配置`classifier`。 53 | ```xml 54 | 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-maven-plugin 59 | 60 | 61 | 62 | com.example 63 | module1 64 | 65 | 66 | 67 | 68 | 69 | 70 | ``` 71 | 72 | ### 方法二 73 | 74 | 排除指定`groupId`下的所有artifact。 75 | ```xml 76 | 77 | 78 | 79 | org.springframework.boot 80 | spring-boot-maven-plugin 81 | 82 | com.example 83 | 84 | 85 | 86 | 87 | ``` 88 | 89 | > 注意事项: 90 | > 1. spring-boot-maven-plugin 插件 exclude 功能只会忽略配置自身jar,不会忽略其依赖jar。 91 | > 2. 在当前可项目的`pom.xml`中依赖的jar使用`true`或`provided`修饰时,打出的 fat-jar 还是会 92 | 包含上述jar的。因为对于spring-boot项目来说,其自生就是一个容器,不存在外部容器的说法。 93 | > 3. 间接依赖的jar配置了`true`或`provided`则忽略,规则和maven保持一直。 94 | 95 | 96 | 参考链接: 97 | * [Dependency Exclusion](https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle/#packaging.examples.exclude-dependency) 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /Java/Spring/SpringCloud/SpringCloud.md: -------------------------------------------------------------------------------- 1 | # Spring Cloud 2 | 3 | ## Config 4 | 5 | * [Spring Cloud Config Refresh Strategies](https://soshace.com/spring-cloud-config-refresh-strategies/) 6 | 7 | 8 | ## Feign 9 | 10 | * [SpringBoot2.1.x后Feign出现Bean被重复注册,导致项目不能启动](https://www.jianshu.com/p/b5581826cf67) 11 | 12 | 13 | ## Spring Cloud Consul 14 | Nginx配置: 15 | ``` 16 | upstream consul { 17 | ip_hash; 18 | server 192.168.201.1:8500 max_fails=10; 19 | server 192.168.201.2:8500 max_fails=10; 20 | server 192.168.201.3:8500 max_fails=10; 21 | } 22 | 23 | server { 24 | listen 80; 25 | server_name consul.xxx.com; 26 | # 第二个参数用于设置响应头Keep-Alive 27 | keepalive_timeout 75s 72s; 28 | proxy_ignore_client_abort off; 29 | proxy_next_upstream error timeout; 30 | 31 | location / { 32 | proxy_pass http://consul; 33 | proxy_set_header Host $host; 34 | proxy_set_header X-Real-IP $remote_addr; 35 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 36 | } 37 | } 38 | ``` 39 | 40 | 问题汇总: 41 | * `org.apache.http.NoHttpResponseException: The target server failed to respond` - [记HttpClient的NoHttpResponse问题](https://czjxy881.github.io/java,nginx/%E8%AE%B0HttpClient%E7%9A%84NoHttpResponse%E9%97%AE%E9%A2%98/) 42 | 43 | 44 | ## Spring Cloud Gateway 45 | 46 | #### Reactor Netty Access Logs 47 | 48 | * [Reactor Netty Access Logs](https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#reactor-netty-access-logs) 49 | 50 | #### Log Levels 51 | 52 | The following loggers may contain valuable troubleshooting information at the `DEBUG` and `TRACE` levels: 53 | * `org.springframework.cloud.gateway` 54 | * `org.springframework.http.server.reactive` 55 | * `org.springframework.web.reactive` 56 | * `org.springframework.boot.autoconfigure.web` 57 | * `reactor.netty` 58 | * `redisratelimiter` 59 | 60 | #### Wiretap 61 | 62 | The Reactor Netty `HttpClient` and `HttpServer` can have wiretap enabled. When combined with setting the `reactor.netty` 63 | log level to `DEBUG` or `TRACE`, it enables the logging of information, such as headers and bodies sent and received across the wire. 64 | To enable wiretap, set `spring.cloud.gateway.httpserver.wiretap=true` or `spring.cloud.gateway.httpclient.wiretap=true` for the `HttpServer` and `HttpClient`, respectively. 65 | 66 | 67 | 68 | ### 官方文档 69 | 70 | * [Spring Cloud `CircuitBreaker` GatewayFilter Factory](https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#spring-cloud-circuitbreaker-filter-factory) 71 | * [The `RequestRateLimiter` GatewayFilter Factory](https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#the-requestratelimiter-gatewayfilter-factory) 72 | * [The `SaveSession` GatewayFilter Factory](https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#the-savesession-gatewayfilter-factory) 73 | 74 | ## 问题 75 | 76 | ### `bootstrap` VS `spring.config.import` 77 | 78 | `Spring Boot 2.4`/`spring cloud 3.x` 默认使用禁用了`bootstrap`机制加载配置,改用`spring.config.import`, 79 | 导致本地的`profiles`配置优先级高于配置中心的`profiles`配置。 80 | 81 | 暂时解决方案: 82 | 1. `spring.config.import=consul:`作为环境变量或启动参数 83 | 2. 提供一个高优先级(`Ordered.HIGHEST_PRECEDENCE`)的`EnvironmentPostProcessor`,把`spring.config.import=consul:`添加进`MapPropertySource` 84 | 3. 依赖`spring-cloud-starter-bootstrap`,启用`bootstrap`加载机制 85 | 86 | 参考链接: 87 | * [The priority of defaulContext is now higher than the application context with spring.config.import](https://github.com/spring-cloud/spring-cloud-consul/issues/702) 88 | * [ConfigData imports cannot override profile specific imports](https://github.com/spring-projects/spring-boot/issues/25766) 89 | * [Ordering of remote vs local configuration files when using profiles is different between bootstrap and spring.config.import](https://github.com/spring-cloud/spring-cloud-config/issues/1795) 90 | 91 | 92 | -------------------------------------------------------------------------------- /Security/汇总.md: -------------------------------------------------------------------------------- 1 | # 汇总 2 | 3 | ## 开源组件 4 | 5 | ### Sa-Token 6 | 7 | Sa-Token 是一个轻量级 Java 权限认证框架,主要解决:登录认证、权限认证、单点登录、OAuth2.0、分布式Session会话、微服务网关鉴权 等一系列权限相关问题。 8 | 9 | * 登录认证 —— 单端登录、多端登录、同端互斥登录、七天内免登录 10 | * 权限认证 —— 权限认证、角色认证、会话二级认证 11 | * Session会话 —— 全端共享Session、单端独享Session、自定义Session 12 | * 踢人下线 —— 根据账号id踢人下线、根据Token值踢人下线 13 | * 账号封禁 —— 指定天数封禁、永久封禁、设定解封时间 14 | * 持久层扩展 —— 可集成Redis、Memcached等专业缓存中间件,重启数据不丢失 15 | * 分布式会话 —— 提供jwt集成、共享数据中心两种分布式会话方案 16 | * 微服务网关鉴权 —— 适配Gateway、ShenYu、Zuul等常见网关的路由拦截认证 17 | * 单点登录 —— 内置三种单点登录模式:无论是否跨域、是否共享Redis,都可以搞定 18 | * OAuth2.0认证 —— 基于RFC-6749标准编写,OAuth2.0标准流程的授权认证,支持openid模式 19 | * 二级认证 —— 在已登录的基础上再次认证,保证安全性 20 | * Basic认证 —— 一行代码接入 Http Basic 认证 21 | * 独立Redis —— 将权限缓存与业务缓存分离 22 | * 临时Token验证 —— 解决短时间的Token授权问题 23 | * 模拟他人账号 —— 实时操作任意用户状态数据 24 | * 临时身份切换 —— 将会话身份临时切换为其它账号 25 | * 前后台分离 —— APP、小程序等不支持Cookie的终端 26 | * 同端互斥登录 —— 像QQ一样手机电脑同时在线,但是两个手机上互斥登录 27 | * 多账号认证体系 —— 比如一个商城项目的user表和admin表分开鉴权 28 | * 花式token生成 —— 内置六种Token风格,还可:自定义Token生成策略、自定义Token前缀 29 | * 注解式鉴权 —— 优雅的将鉴权与业务代码分离 30 | * 路由拦截式鉴权 —— 根据路由拦截鉴权,可适配restful模式 31 | * 自动续签 —— 提供两种Token过期策略,灵活搭配使用,还可自动续签 32 | * 会话治理 —— 提供方便灵活的会话查询接口 33 | * 记住我模式 —— 适配[记住我]模式,重启浏览器免验证 34 | * 密码加密 —— 提供密码加密模块,可快速MD5、SHA1、SHA256、AES、RSA加密 35 | * 全局侦听器 —— 在用户登陆、注销、被踢下线等关键性操作时进行一些AOP操作 36 | * 开箱即用 —— 提供SpringMVC、WebFlux等常见web框架starter集成包,真正的开箱即用 37 | * 更多功能正在集成中... —— 如有您有好想法或者建议,欢迎加群交流 38 | 39 | > 注:可作为参考方案 [官网链接](https://sa-token.dev33.cn/) 40 | 41 | 42 | ## 参考文档 43 | 44 | * [Please Stop Using LocalStorage - 讲解LocalStorage的缺点及在什么情况下可以使用](https://dev.to/rdegges/please-stop-using-local-storage-1i04) 45 | * [OWASP Cheat Sheet Series -【重要】](https://cheatsheetseries.owasp.org/) - 列出了几乎所有与安全相关的信息 46 | * Abuse Case 47 | * Authorization Testing Automation 48 | * Access Control 49 | * Authentication 50 | * Attack Surface Analysis 51 | * AJAX Security 52 | * Bean Validation 53 | * Cryptographic Storage 54 | * C-Based Toolchain Hardening 55 | * Content Security Policy 56 | * Choosing and Using Security Questions 57 | * Cross-Site Request Forgery Prevention 58 | * Cross Site Scripting Prevention 59 | * Clickjacking Defense 60 | * C-Based Toolchain Hardening 61 | * Credential Stuffing Prevention 62 | * DotNet Security 63 | * Deserialization 64 | * Denial of Service 65 | * Docker Security 66 | * DOM based XSS Prevention 67 | * Error Handling 68 | * Forgot Password 69 | * HTML5 Security 70 | * HTTP Strict Transport Security 71 | * Insecure Direct Object Reference Prevention 72 | * Input Validation 73 | * Injection Prevention Cheat Sheet in Java 74 | * Injection Prevention Cheat Sheet 75 | * JSON Web Token Cheat Sheet for Java 76 | * JAAS Cheat Sheet 77 | * Key Management 78 | * Logging Cheat Sheet 79 | * LDAP Injection Prevention 80 | * Mass Assignment 81 | * Microservices based Security Arch Doc 82 | * OS Command Injection Defense 83 | * PHP Configuration 84 | * Pinning 85 | * Protect FileUpload Against Malicious File 86 | * Password Storage 87 | * Query Parameterization 88 | * REST Security 89 | * Ruby on Rails 90 | * REST Assessment 91 | * Server Side Request Forgery Prevention 92 | * Securing Cascading Style Sheets Cheat Sheet 93 | * Session Management 94 | * SAML Security 95 | * SQL Injection Prevention 96 | * Third Party Javascript Management 97 | * Transport Layer Protection 98 | * Threat Modeling 99 | * TLS Cipher String 100 | * Transaction Authorization 101 | * User Privacy Protection 102 | * Unvalidated Redirects and Forwards 103 | * Vulnerability Disclosure 104 | * Vulnerable Dependency Management 105 | * Virtual Patching 106 | * Web Service Security 107 | * XML Security 108 | * XML External Entity Prevention 109 | -------------------------------------------------------------------------------- /CodeStyle/CodeStyle-IDE.md: -------------------------------------------------------------------------------- 1 | ## CodeStyle-IDE 2 | 3 | #### Eclipse应用Google Code Style 4 | 5 | * 下载地址:https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml 6 | * 安装之前需要修改几处配置项 7 | * `` - 缩进习惯了4个空格 8 | * `` - 连续缩进设置为1 9 | * `` 10 | * `` - 代码最大长度为120 11 | * `` - 注释最大长度为120 12 | * `` - 保留的空行数 13 | * `` - 枚举对象太多时换行 14 | * 安装文档参考[Checkstyle.md](Checkstyle.md) 15 | 16 | #### Eclipse设置JS、CSS、HTML、XML 17 | 18 | * 通用 19 | 20 | * `General | Editors | Text Editors | Displayed tab width : 2` 21 | * `General | Editors | Text Editors | 勾选 Insert spaces for tabs` 22 | 23 | * JS 24 | 25 | 配置路径:`JavaScript | Code Style | Formatter | 选中对应profile点击Edit` 26 | 27 | * 缩进使用空格替代且为2个空格 28 | * `Indentation | Tab policy | Spaces only` 29 | * `Indentation | Indentation size | 2` 30 | * `Indentation | Tab size | 2` 31 | 32 | * CSS 33 | * 缩进使用空格替代 34 | 35 | `Web | CSS Files | Editor -> 选中Indent using spaces 且 Indentation size设置为2` 36 | 37 | * HTML 38 | * 缩进使用空格替代 39 | 40 | `Web | HTML Files | Editor -> 选中Indent using spaces 且 Indentation size设置为2` 41 | 42 | * XML 43 | * 缩进使用空格替代 44 | 45 | `XML | XML Files | Editor -> 选中Indent using spaces 且 Indentation size设置为2` 46 | 47 | * JSON 48 | * 缩进使用空格替代 49 | 50 | `JSON | JSON Files | Editor -> 选中Indent using spaces 且 Indentation size设置为2` 51 | 52 | #### IDEA应用Google Code Style 53 | 54 | * 下载地址:https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml 55 | * 安装之前需要修改几处配置项 56 | * 只修改Java语言``: 57 | * `