Friday, October 26, 2018

Gradle简介

Gradle与Maven比较:
1. Gradle利用cache使得build过程更快
2. Gradle利用分块build(incremental),也就是指对修改的文件重新build,如修改了test,只build该test

https://gradle.org/maven-vs-gradle/
https://www.jianshu.com/p/00d5469e25e7

Thursday, October 18, 2018

Java的Null pointer exception

Boolean a;
boolean b = false || a;
会出现NPE因为a可能为null。

switch(a){
    case true:
        return "";
}
会出现NPE因为a可能为null。

Friday, September 21, 2018

Java中的ThreadLocal和弱引用

ThreadLocal就是线程的私有变量和对象

static ThreadLocal<Metric> metric = new ThreadLocal<>();
这里用static因为相当于线程的私有全局变量,避免数据的重复copy(不同实例)。但可能导致内存泄漏(因为static不会被回收)。如果有线程池,线程会被复用就减低内存泄漏的可能。
https://www.zhihu.com/question/35250439

Strong ref是Map m = new HashMap();
Soft Ref内存不足才会回收,适用于缓存
Week Reference是回收器自动回收弱引用对象(HashMap中)
Phantom Ref是在析构finalize中不会复活下回收弱引用


https://droidyue.com/blog/2016/03/13/learning-threadlocal-in-java/
https://droidyue.com/blog/2014/10/12/understanding-weakreference-in-java/

我的书目:

Effective Java中文版(第2版)


Java并发编程实战


深入理解Java虚拟机:JVM高级特性与最佳实践(第2版)



重构:改善既有代码的设计 

系统思维:复杂商业系统的设计之道(原书第3版)

Sunday, September 9, 2018

JS代码缺陷自动分析工具 - eslint

eslint
gulp: js build tool
node.js
webpack: web browser library
unit test: Mocha

http://www.ruanyifeng.com/blog/2015/12/a-mocha-tutorial-of-examples.html

Thursday, August 16, 2018

whistle简介

如何安装
http://wproxy.org/whistle/install.html

https设置
http://wproxy.org/whistle/webui/https.html

windows commands

netstat -ano | findstr :8899
taskkill /PID typeyourPIDhere /F

https://stackoverflow.com/questions/39632667/how-to-kill-a-currently-using-port-on-localhost-in-windows

Thursday, June 28, 2018

AWS CloudFront

CDN service

比如Alexa use case,可以用于给一个skill播放音乐,用CloudFront根据user location来读取相应地区的audio。CloudFront自动配对到S3.