Just a reminder when installing 3rdparty software on MacOS.

Starting with MacOS Sierra 10.12, run:

Starting with MacOS Catalina 10.15, run:

Recently played with the Spring/SpringBoot/SpringCloud stack with a toy project: https://github.com/gonwan/spring-cloud-demo. Just paste README.md here, and any pull request is welcome:


The demo project is initialized from https://github.com/carnellj/spmia-chapter10. Additions are:

  • Code cleanup, bug fix, and better comments.
  • Java 9+ support.
  • Spring Boot 2.0 migration.
  • Switch from Postgres to MySQL, and from Kafka to RabbitMQ.
  • Easier local debugging by switching off service discovery and remote config file lookup.
  • Kubernetes support.
  • Swagger Integration.
  • Spring Boot Admin Integration.

The project includes:

  • [eureka-server]: Service for service discovery. Registered services are shown on its web frontend, running at 8761 port.
  • [config-server]: Service for config file management. Config files can be accessed via: http://${config-server}:8888/${appname}/${profile}. Where ${appname} is spring.application.name and ${profile} is something like dev, prd or default.
  • [zipkin-server]: Service to aggregate distributed tracing data, working with spring-cloud-sleuth. It runs at 9411 port. All cross service requests, message bus delivery are traced by default.
  • [zuul-server]: Gateway service to route requests, running at 5555 port.
  • [authentication-service]: OAuth2 enabled authentication service running at 8901. Redis is used for token cache. JWT support is also included. Spring Cloud Security 2.0 saves a lot when building this kind of services.
  • [organization-service]: Application service holding organization information, running at 8085. It also acts as an OAuth2 client to authentication-service for authorization.
  • [license-service]: Application service holding license information, running at 8080. It also acts as an OAuth2 client to authentication-service for authorization.
  • [config]: Config files hosted to be accessed by config-server.
  • [docker]: Docker compose support.
  • [kubernetes]: Kubernetes support.

NOTE: The new OAuth2 support in Spring is actively being developed. All functions are merging into core Spring Security 5. As a result, current implementation is suppose to change. See:

Tested Dependencies

  • Java 8+
  • Docker 1.13+
  • Kubernetes 1.11+

Building Docker Images

In case of running out of disk space, clean up unused images and volumes with:

Running Docker Compose

Or with separate services:

Running Kubernetes

NOTE: Kubernetes does not support environment variable substitution by default.

Use Cases

Suppose you are using the kubernetes deployment.

Get OAuth2 token

curl is used here, and 31004 is the cluster-wide port of the Zuul gateway server:

Get organization info

Use the token returned from previous request.

Get license info associated with organization info

Use the token returned from previous request.

Distributed Tracing via Zipkin

Every response contains a correlation ID to help diagnose possible failures among service call. Run with curl -v to get it:

Search it in Zipkin to get all trace info, including latencies if you are interested in.

The license service caches organization info in Redis, prefixed with organizations:. So you may want to clear them to get a complete tracing of cross service invoke.

Working with OAuth2

All OAuth2 tokens are cached in Redis, prefixed with oauth2:. There is also JWT token support. Comment/Uncomment @Configuration in AuthorizationServerConfiguration and JwtAuthorizationServerConfiguration classes to switch it on/off.

Swagger Integration

The organization service and license service have Swagger integration. Access via /swagger-ui.html.

Spring Boot Admin Integration

Spring Boot Admin is integrated into the eureka server. Access via: http://${eureka-server}:8761/admin.

As a note here:

Go to Menu –> Store –> Check for Available Downloads, to refresh your iBooks login manually. Also make sure the iCloud option for iBooks is enabled in settings.

Updated July 4, 2022: On MacOS 12, Go to Settings –> Apple ID —> iCloud Drive, disable and re-enable the iBooks sync. If this does not work, logout and re-login the Apple ID.

    I’m now working for ASUS Computer Inc. as a senior software engineer. My wage is about 5k – 8k per month. No house nor car is available.
    In spare time, I read books. Learning is important. I also watch animes to relax myself. I like singing. My favorite singer is Fish Leong. Every week, I play badminton or do other sports. But I’m not very good at sports, just for fun. “Living with passion” is my motto.
    Lastly, I do not have a plan for marriage in recent two years.

    gonwan’s girlfriend

    ·162-172 a must.
    ·Intelligent, diligent, and with a pleasant personality.
    ·Being so outgoing that I can trust and always share my thoughts with you.
    ·No specific zodiac required.
    ·Good singing skills preferred.
    ·Good drawing skills a plus.

    ·Just whatever a girlfriend should do.

    I will offer a better life to you, if you get the position.
    Please send your resume to “gonwan (at) gmail (dot) com”. Be sure to mark the title with “applying for position”. Then you will be informed when and where to take an interview session.
    Contact me if you are the one.

2008/08 – 2009/07 读过的技术类书籍.
基本按照时间序, 至少读完50% 以上, 其中页数以amazon.com 为准.

Cross-Platform Development in C++

Authors: Syd Logan
Pages: 576
Difficulty: ★★★
Recommended Degree: ★★★
Comprehensive Degree: 95%
本书的作者是Netscape 的资深工程师, 也就是现在正在弄firefox 这个东西. 本书实质性的内容不多, 但是对于跨平台的开发目前看来还是唯一一本. 书里一开始说, 对于一个跨平台的项目, 便一开始就要各个平台并行开发, 不能丢掉任何一个. 也就是态度决定一切. 接着介绍了一般跨平台开发的编码规范, 哪些语言特性是编译器相关的, 哪些特性是平台相关的, 需要避免使用. 然后便是代码的组织结构, 以及如何自己实现跨平台的接口. 在然后是跨平台的一些开发工具. 最后介绍了wxWidgets 这个开源的跨平台项目, 以及作者自己写的一个跨平台类库.

C++ GUI Programming with Qt4, 2E

Authors: Jasmin Blanchette, Mark Summerfield
Pages: 752
Difficulty: ★★★☆
Recommended Degree: ★★★★
Comprehensive Degree: 90%
Qt, 这是一个跨平台的GUI 类库, 当然现在已经不仅仅限于GUI 了. 当初看这本书的原因, 自然是因为前一本看的意犹未尽. 而Qt 的代码, 因为有商业版本的支持, 比wxWidgets 质量高很多(Qt 自4.4 版本以后感觉代码质量有所下降). 可以把Qt 的GUI 库想像成Java 中的swing 库, 因为它们的控件都是用GDI 画出来的. 而可以把wxWidgets 的GUI 库想像成Java 中的awt 库, 它们的控件是调用Windows 的API 来绘制的. 所以你可以把它们分别成为light-weight 和heavy-weight.
言归正传, 这本书可以说是一本半官方的文档. 除了前几章介绍了Qt 的整体框架之外, 之后开始便都在讲如何使用类库. Qt 的好处, 除了跨平台以外, 还有客户端代码的简洁, 以及很好的工具支持. 当然, 要知道类库怎么用并不难, 难的是要知道类库到底是如何设计的. 看这本书的时候, 丸子经常写一个很简单的程序, 然后用Visual Studio 单步调式Qt 的源代码. 之后, 在公司项目中对于Qt 设计思想的使用, 让我对Qt 有了更深的理解.

An Introduction to Design Patterns in C++ with Qt4

Authors: Alan Ezust, Paul Ezust
Pages: 656
Difficulty: ★★
Recommended Degree: ★
Comprehensive Degree: 100%
乍看之下, 本书的名字很牛啊, 又是Qt, 又是C++, 又是design pattern. 但其实却是入门等级的, 丸子也被书名给骗了. 本书的流程大概就是用Qt 的语法, 教你写程序, 顺便提提design pattern. 真无语.

Effective C++, 2E

Authors: Scott Meyers
Pages: 256
Difficulty: ★★★
Recommended Degree: ★★★
Comprehensive Degree: 95%
本书也可以说经典了, 但是丸子却没看过. 书中提了50 条C++ 的编程规范, 让你的code 能更加effective. 当时看的时候, 发现自己几乎都知道, 而且中间有很多的废话, 一般人根本不会那么写代码的. 所以感觉收获并不是很大. 还是推荐另外3 本书比较有难度的书: <<exceptional c++>>, <<more exceptional c++>>, <<c++ object model>>, 保证让你看的醉生梦死.

Design Patterns: Elements of Reusable Object-Oriented Software

Authors: Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides
Pages: 416
Difficulty: ★★★★
Recommended Degree: ★★★★★
Comprehensive Degree: 75%
又一本经典, 四人帮的书.
本书被丸子誉为程序员的九阳神功, 有了它等之后练太极, 练乾坤大挪移就能事半功倍.
本书自然是介绍23 种设计模式. 就语言描述来说, 真的是有些难懂, 但确实是目前来说最定义最完整的. 目前公司training 的一本叫做<<head first: design pattern>> 的书, amazon 上评价也不错, 确实更容易理解, 但是这本书说的显然还是太简单了, 而且举的例子事实上很多会混淆读者的理解.

Applying UML and Patterns

Authors: Craig Larman
Pages: 736
Difficulty: ★★★★
Recommended Degree: ★★★★
Comprehensive Degree: 80%
本书其实题目起的不好, 它实际上整个都在讲软件工程的过程控制, 中间突出UML 和Pattern (不只是design pattern, 还有architectural pattern) 的核心作用. 反正看不懂就看吧. 本书在7 月份的分组考试中起到了非常重要的作用.
另, 本书让我想到上课时我们可爱滴牛老师=v=.

Essential COM

Authors: Don Box
Pages: 464
Difficulty: ★★★★☆
Recommended Degree: ★★★
Comprehensive Degree: 60%
本真是目前来说看的最累的一本. 真不知道M$ 那帮人是怎么设计出那么复杂的COM(Component Object Model) 框架的. 本书破天荒的有两篇前言, 一篇还是COM 的设计者, 说没有人能比Box 先生解释COM 解释的更好了. 事实上, 他解释的我也不怎么能看懂, 而且还严重拖延了我的看书计划. 如果没有严重的自虐倾向, 建议看下面这本书. 本书偏理论, 下面那本偏应用.
最后说一下, 为什么要用COM. M$ 的最初设计是为了跨平台, 解决C++ 的二进制兼容型. 当然, 很嘲的是, 横跨的是Windows 平台.

Inside COM

Authors: Dale Rogerson
Pages: 376
Difficulty: ★★★☆
Recommended Degree: ★★★★
Comprehensive Degree: 80%
本书跟上一本都是COM 的必看书之一. 我在看了上一本前3 章之后, 来看这本, 一晚上扫了100 多页, 真是心情愉快啊. 很多的例子代码能帮助你更好的理解.

Pro C# 2008 and the .NET 3.5 Platform, 4E

Authors: Andrew Troelsen
Pages: 1370
Difficulty: ★★★
Recommended Degree: ★★★
Comprehensive Degree: 90%
公司training 的书, 居然有1000 多页. amazon 上评价不错, 但私以为比较垃圾. 本书把你当作C# 的初学者来对待. 作者还很喜欢用这样的词来开头”simply put, …..”, 当我们都是sx. 所以我也就随便看看, 主要看的是C# 3.0, 3.5 的新特性, 比如WPF, WCF, WF, LINQ 等. 而这些新特性本书却写的非常的不详细, 果然是给初学者的书.
WPF 确实是比较比较好的设计. 这一点不想多说, 光看有很多开源的模仿WPF 的框架就知道这个设计思路有多好.
WCF, WF.. 私以为这两个完全没有必要. WCF 虽然说代码的确比较简单, 但那个配置文件没有Visual Studio 的辅助, 基本是配不来的. WF 感觉就是个半成品, 对于Visual Studio 的依赖性更大.
LINQ 的设计思路是把SQL 集成到.NET 的语言级别, 想法很好. 但是平白增加了语言的复杂性. 光为了支持LINQ 特性, .NET 3.5 就增加了好几个关键字, 以及好几个语言特性. 而这些新加的特性除了LINQ 之外, 很少会在其它库中用到.
丸子评价可能带有片面性, 请自行判断.

Programming Windows, 5E

Authors: Charles Petzold
Pages: 1100
Difficulty: ★★★☆
Recommended Degree: ★★★★☆
Comprehensive Degree: 90%
大师的书啊.. Charles Petzold, 响当当的名字.
本书侧重于介绍Windows GUI 的编程. 一个最最简单的Windows 窗口, 完全调用Windows API 的话大概要70-80 行代码. 而*nix/gtk 大概是20 行以内, Qt 和Java 应该能在10 行以内. Windows API 的代码效率实在有待商榷.
言归正传, 本书从Windows 的窗口消息机制讲起, 消息循环, 消息分发, 屏幕重绘, 控件的使用, Owner-draw, Hook. 然后本书的另外一个大头讲了GDI 的相关内容, 非常的深入. GDI 的使用是一件让人很头痛的事情, 功能本身不怎么强大, 但非常容易写出memory leak, 或者GDI handle leak 的代码. 于是M$ 之后发布了GDI+, 这个GDI 的扩展版本确实比GDI 强大了不少, 而且是OO 的. 但是缺点是, 绘图那个慢啊.. 而且debug 困难.
另外推荐一本<<Programmiong Application for Microsoft Windows>>. 这本测试的是Windows API 的非GUI 部分.

Microsoft Windows Internals, 4E

Authors: Mark E. Russinovich, David A. Solomon
Pages: 976
Difficulty: ★★★★☆
Recommended Degree: ★★★★☆
Comprehensive Degree: 80%
本书也是一本牛书, Windows 内核最权威的书, 前Windows 部门的项目经理甚至为它作序. 就书本身来说, 语言方面真的没人能写出那么拗口的句子了, 从句套从句, 有时候一打段文字它居然就只有一句句子. 但没办法, 书就那么一本.
如果说上面那本偏重的是user mode 的话, 那么本书偏中的就是kernel mode. M$ 的东西, 它就是不开源. 一个可能很容易的概念, 一旦把它作为黑盒来分析的话, 理解起来就会非常的累人, 不像Linux, 所有的代码你都可以看. 书中推荐使用Windbg 来调试内核.
本书跟一般的OS 书一样, 介绍了Windows 的进程, 线程, 内存管理, 缓存, 存储管理, 安全性等一系列的相关的实现及最初的设计思路. 让我发现M$ 确实是很有创造力的一家公司, 很多东西都是在Windows 这个OS 上最先出现的哦, 而且它的设计思路完全不走寻常路=v=.
对于本书的理解非常重要. 我一般写程序调用Windows API 的时候, MSDN 上很多时候会说, 某个函数一定要跟另外一个搭配使用, 某个函数一定要传入什么什么参数, 某个函数一定要在什么什么模式下使用. 看完本书之后, 很多东西都能解答了, 也就用不着硬记了.
另外要说的一点是, M$ Windows 的API 兼容型的确很好, 上个世纪编译的程序一样能在最新的Windows 7 下运行. 但代价就是, Windows 代码的冗余. 看看Linux 内核的开发, 不用的代码, 基本都是标记为deprecated 之后保留几个版本, 然后就直接删掉的. Mac OSX 做的更绝, OSX 之前的代码完全不能用, 而10.5 版本在原来Carbon API的基础上完全重写了一套Cocoa 的API. 当然要我选, 我一定选的是高效的代码. 但M$ 却不是, 这也是M$ 聪明的地方吧.