ai-learn note

  • supervised learning
    • regression problem.
      • Given the “right answer” for each example in the data.
    • classification probleam.
  • unsupervised learning

Octave

glossaries

  1. hypothesis
  2. theta
  3. parameter
  4. prediction
  5. algorithm
  6. linear
  7. regression
  8. gradient
  9. descent
  10. derivative
  11. contour plots,contour figures
  12. convergence,converge,diverge
  13. intuition
  14. overshoot
  15. accuracy
  16. denote
  17. discrete value
  18. matrices
  19. transpose
  20. algebra
  21. polynomial

mini-program-login-userinfo

wx.getUserInfo

这个接口字面意思很简单,就是取得用户的信息,目前最新版本的接口,已经不会弹出对话框,要用户来授权。所以一般此接口单独使用,毫无效果,示例如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//app.js
App({
onLaunch: function () {
console.log('App before call wx.getSetting')
wx.getUserInfo({
success: res => {
console.log('success', res)
},
fail: res => {
console.log('fail', res)
},
complete: res => {
console.log('complete', res)
}
})
}
})

结果如下

1
2
3
App before call wx.getSetting
fail {errMsg: "getUserInfo:fail auth deny"}
complete {errMsg: "getUserInfo:fail auth deny"}

Base64Image

小图标制作小技巧

思路

很多图标网上搜不到,或是搜到又不是自己想要的,自己要动手制作,又需要一些图片处理软件,不是很方便,不如换个思路。利用js的canvas画图,画完之后再转为base64,即可在css中直接使用了。很是方便。

实现

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
1> 打开w3school的在线编辑 http://www.w3school.com.cn/tiy/t.asp?f=html5_canvas
2> copy下面代码
<!DOCTYPE HTML>
<html>
<body>

<canvas id="myCanvas" style="border:solid 1px black"></canvas>
<div id="result"></div>
<script type="text/javascript">

var canvas=document.getElementById('myCanvas');
var ctx=canvas.getContext('2d');
ctx.strokeStyle='#fed06a';
ctx.arc(12,12,10,0,2*Math.PI);
ctx.stroke();
ctx.fillStyle="#fed06a";
ctx.fill();
ctx.strokeStyle='white';
ctx.moveTo(7,11);
ctx.lineWidth=2;
ctx.lineTo(12,15);
ctx.lineTo(17,8);
ctx.stroke();

ctx.fillStyle='#fed06a';
ctx.beginPath();
ctx.arc(32,12,9,0,2*Math.PI);
ctx.arc(32,12,7,0,2*Math.PI);
ctx.fill("evenodd");

var result=document.getElementById('result');
result.innerHTML = canvas.toDataURL();
</script>


</body>
</html>

vue-demo

安装

1
2
3
4
1> 安装nodejs  `brew install node` `npm view vue-cli`
2> 安装vue-cli `nmp install -g vue-cli`
3> 安装webpack `nmp install -g webpack`
4> 创建webpack为模板的项目 `vue init webpack vue-demo`

常见问题

1、无法通过ip地址访问

1
修改config/index.js , host: '0.0.0.0'

2、invalid host header

1
1> 修改webpack.dev.config.js , devServer.disableHostCheck: true

3、跨域问题的处理

1
2
3
1> 问题描述: 通常开发阶段,前端页面使用node静态服务器,端口号是 8080。后端接口一般是本地的tomcat,端口号可能是 8081 。登录注册通常会写写cookie,后端response的cookie写在 8081 下,于是 8080 下拿不到 8081 的cookie,登录无效。
2> 解决办法,开启代理服务器。 config/index.js 文件中的proxyTable 。`axios`发起的请求仍然为 8080 ,通过反向代理,把 8080 的请求代理到 8081 上即可。
3> 莫名其妙的样式问题。可能是模块之间样式冲突。

FastLeaderElection

启动:

private void starter(QuorumPeer self, QuorumCnxManager manager) {
this.self = self;
proposedLeader = -1;
proposedZxid = -1;

    sendqueue = new LinkedBlockingQueue<ToSend>();
    recvqueue = new LinkedBlockingQueue<Notification>();
    this.messenger = new Messenger(manager);
}

org.apache.zookeeper.server.quorum.FastLeaderElection.ToSend

NIOServerCnxnFactory

简介

Zookeeper 默认的ServerCnxnFactory的实现。顾名思义,采用非阻塞通信方式。特点是采用了多个线程来分别处理各类型事件。

1、1个accept thread.

1.1 类结构

AcceptThread->AbstractSelectThread->ZooKeeperThread

1.2 解释
  • a) 每个AbstractSelectThread的对象都维持这一个 selectorthis.selector = Selector.open()
  • b) acceptThread对象把ServerSocketChannel的OP_ACCEPT事件注册到本对象的 selector 上。
  • c) 当一个新的链接 被 accept之后,就把此链接的处理交给某个selectThread,通过调用SelectorThread.addAcceptedConnection(SocketChannel),采用Round-robin策略,其实就是iterator.next()。这个时候一个socket接入完成,剩下的是selector thread的事了。

2、1-n个 selector threads.

2.1 类结构

SelectorThread->AbstractSelectThread->ZooKeeperThread

2.2 解释
  • a) 当一个acceptThread把SocketChanel传给selectorThread时,调用的addAcceptedConnection,这个方法是把socketChannel加到acceptedQueue里,每个acceptThread有一个LinkedBlockingQueue类型的队列。(而且我看的版本LinkedBlockingQueue没设置大小。)
  • b) selectThread的run方法里。
    1. select
    2. 把readable和writable的selectionKey封装成IOWorkRequest对象,放到workerPool(work threads)里。放到workerPool之前,把selectionKey的interest ops清除,及NIOServerCnxn disableSelectable。
    3. 把acceptedQueue的socket的OP_READ注册到selector上。
    4. 处理updateQueue 。workThread在处理完IO后,把SelectionKey加到updateQueue里。在这里恢复SelectionKey的interestOps。

3、0-m个 work threads.

3.1 结构

org.apache.zookeeper.server.WorkerService,其中实例变量:ArrayList workers = new ArrayList();

3.2 解释
  • a) 处理IO
  • b) cnxn.enableSelectable
  • c) 把key加到updateQueue中。

4、connection expiration thread

类结构ConnectionExpirerThread->ZooKeeperThread

activemq-in-action-index

  • Part 1 An introducation to messaging and ActiveMQ
    • 1 Introducation to ActiveMQ
      • 1.1 ActiveMQ features
      • 1.2 Using ActiveMQ: why and when?
      • 1.3 Getting started with ActiveMQ
      • 1.4 Running your first example with ActiveMQ
      • 1.5 Summary
    • 2、Understanding message-oriented middleware and JMS
      • 2.1 Introduction to enterprise messaging.
      • 2.2 What’s message-oriented middleware.
      • 2.3 What’s the Java Message Service?
      • 2.4 The JMS specification
        • JMS clients Non-JMS clients The JMS provider The JMS message JMS message internals Message selectors JMS domains Adminisitered objects
      • 2.5 Using the JMS API to create JMS applications
      • 2.6 Summary
    • 3、The ActiveMQ in Action examples.
  • Part 2 Configuring standard ActiveMQ components
    • 4、 Connecting to ActiveMQ
    • 5、 ActiveMQ message storage
    • 6、 Securing ActiveMQ
  • Part 3 Using ActiveMQ to build messaging applications
    • 7、 Creating Java applications with ActiveMQ
    • 8、 Integrating ActiveMQ with application servers
    • 9、 ActiveMQ messaging for other language
  • Part 4 Advanced features in ActiveMQ
    • 10、 Deploying ActiveMQ in the enterprise
    • 11、 ActiveMQ broker features in action
    • 12、 Advanced client options
    • 13、 Turning ActiveMQ for performance
    • 14、 Administering and monitoring ActiveMQ