工具

  • Linux,  工具,  技术

    Mac command line cheat sheet

    Behavior Command Comment go to the beginning of the line ctrl+a go to the end of the line ctrl+e Save a output of a command to a env variable principle_arn=$(aws –profile perAdmin sts get-caller-identity –query Arn –output text) use a env variable ${principle_arn} replace character sed -e “s|PRINCIPAL_ARN|${principle_arn}|g” \assume-role-policy-template.json > assume-role-policy.json The delimiter of choice is a forward slash (/), which is the most commonly used delimiter. However, sed can use any character as a delimiter. In fact, it will automatically use the character following the s as a delimiter-e means you can use the followed scripts multiple times.https://unix.stackexchange.com/questions/33157/what-is-the-purpose-of-e-in-sed-command

  • 工具,  技术

    Kibana Query cheatsheet

    Example Query Result DSL message:”a test” 1 match phase message: a test 1, 2 match message.keyword: “a test” none match phase message.keyword: “this is a test” 2 match phase KQL got converted to DSL before sending to the server: We can check the related DSL by clicking “inspect” button in UI. Reference: https://xeraa.net/blog/2021_kibana-map-kql-url-elasticsearch-query/

  • 工具,  技术

    Sublime Column Mode

    It’s very easy and the easiest way is just hold the middle mouse button and move the mouse. If you want to select specific lines. While you have selected the lines, loose the middle mouse button and hold “CMD” button and re-select new lines. If you want to subtract from selection, hold “CMD” and “Shift” instead. Alternative is hold “ctrl” and “shift” button and keep clicking “up” or “down” to select. Reference: https://www.sublimetext.com/docs/2/column_selection.html

  • 工具,  技术

    注册欧陆词典

    欧路词典真的挺好用的,Mac版本需要150多块钱。 教程如下: 文字版 1.安装任意版本的欧路词典,打开一次并退出。 2.打开Finder前往”~/Library/Preferences”找到com.eusoft.eudic.plist文件。 3.使用PlistEdit Pro打开,修改MAIN_TimesLeft中的数值为820711(试用天数)。 4.将文件锁定、改为只读。 Notes: If you don’t have PlistEdit Pro, you can use https://github.com/ic005k/Xplist/releases/tag/1.2.47 Actually even the PlistEdit Pro shows expired it seems still saved the file anyways.

  • Java,  工具,  技术

    如何在本地环境同时用多个jdk版本

    如果工作在不同的项目,可能需要不同的jdk版本。如果用mvn的话默认只是用系统设置的版本。这时候如果想在命令行编译就会比较麻烦。最简单的做法是把系统的java版本设置成最常用的,然后设置别名分别对应不同的版本。 下面是例子: 这样就可以了。 另一个方法通常IDE的mvn都可以用单独的配置,比如说用Intellij,我们可以在不同的Intellij的project设置不同的版本:

  • 工具,  技术

    How to create a new repo in github?

    If you write codes only for your job and don’t really try to have your personal little projects you may never create a brand new project in repo even you have been written codes for years. So how to create a new repo in gitbut sounds easy but a lot of experienced developers may never do that. Int he other hand, whether he/she can create a repo without any trouble or google search is a arguable way to determine whether he/she is a passionate developers or not (no argument needed here, personal option).. Ok. let’s start. Normally when you build a new repo you may use third part bootstrap tool…

  • 工具,  技术

    Resillience4j – 远程方法调用的工具箱

    在MicroService的世界,很多的远程调用。只要有远程调用就会有网络不稳定问题,某些api会fail掉,有时候api会很长时间没有反馈,导致client的线程大量占用。 其实在非microservice的场景,数据库连接也有同样的问题。数据库操作有时候会遇到lock的问题,需要重试基本上是肯定的。 Resillience4j这个library专门针对这些常用的场景提供了非常容易使用的library。几个典型的功能如下: Retry 根据返回的结果,或者异常决定是不是要retry,如何retry。这个场景太常见了。比如说对于locking issue可以这么做。如果是data integrity的错误,就不需要retry。 Circuit Breaker 根据一个threshold,如果说一定时间内错误率到达一定程度,预计不断请求返回错误,还不如直接忽略,继续执行。特别是有时候错误会消耗额外的等待时间。 Rate Limiter 限制call的rate。比如说限制一秒钟一次call Time Limiter 限制执行的等待时间。 BulkHead 限制并发执行的数量。 Cache 一定时间内的重复call的cache,提高性能。 Fallback 提供可选的方案。比如说Object Query不行可以转ZOQL

  • 工具,  技术

    对象的序列化

    对象的序列化和传输在过去这些年也发生了很多的变化。 Java序列化 很早以前用这个,因为这种序列化方式只能局限于一个单一语言,已经不再用了。 Json 用Jackson的ObjectMapper把一个对象序列化成Jason,然后再反序列化. Avro Kafka的默认方式。需要提前预定义好model,序列化,反序列化的时候都需要用那个model。model更新的时候我记得并不像想象的那么简单。比如说加一个字段。我们必须asdl定义NoAE的所有的消息都有自己对应的Class,Serializer和Deseriallizer,都是基于Avro的。比如 NotificationInstanceDeserializer NotificationInstanceSerializer AvroSerializer.java (This copied from GenericBinarySerializer.java in CDC-model) 而DACO的Serializer和Deserializer都是用一个 JsonSerializer.其实就是Jakson的ObjectMapper的实现。不过传输的都是二进制(但是其实就是json专程bytes而已,Kafka的所有消息都是bytes)。DataModel必须是JsonNode的实现(其实不需要,objectMapper.writeValueAsBytes这个方法就是接受Object)。没有语言独立的表达。。绑定Jackson. 这个就是偷懒的做法。不需要定义avil文件,只需要写一个继承JsonNode的bean就好。主要是公司没有一个统一的标准,大家都选择自己最convinience的方法去做。以后如果要改格式就还挺麻烦。 JsonSerializer.java KafkaJsonDeserializer.java. 所以Kafka consumer都是拿的JsonNode,需要再转为子类。比如NotificationMessage.java Protocal Buffer gRPC的默认方式。和Avro类似。尺寸都比较小。