# [Week 5] 春假、閒聊
###### tags: `MCL` `Weekly Meeting`
### 工讀相關
* 下週一正常上班哦
<img src="https://hackmd.mcl.math.ncu.edu.tw/uploads/upload_e3c758bcc7b590f9bccf3489a0d40387.png" width=400>
> [name=thenothingseal@instagram]
### 其他
* [[AIdea, 工研院] 科技部愛文芒果等級分類競賽](https://aidea-web.tw/topic/72f6ea6a-9300-445a-bedc-9e9f27d91b1c)
* 企劃書全部收齊了,這陣子開始排報告時間
## 閒聊
### 芒果辨識與擷取中所使用的技術:MaskRCNN

> [name=Waleed Abdulla, Splash of Color: Instance Segmentation with Mask R-CNN and TensorFlow]
* [[Medium] Splash of Color: Instance Segmentation with Mask R-CNN and TensorFlow](https://engineering.matterport.com/splash-of-color-instance-segmentation-with-mask-r-cnn-and-tensorflow-7c761e238b46)
* [[GitHub] matterport/Mask_RCNN](https://github.com/matterport/Mask_RCNN)
### YouTube IFrame API
* [同源政策 (Same-origin policy)](https://developer.mozilla.org/zh-TW/docs/Web/Security/Same-origin_policy) 會限制跨站執行任意 JavaScript 腳本
* [YouTube IFrame API](https://developers.google.com/youtube/iframe_api_reference) 使用 [postMessage](https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/529625/) 實現跨站 DOM 操作
* [[Google] 官方文件](https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/529625)
* [[webduino, 中文教學] Youtube 互動](https://tutorials.webduino.io/zh-tw/docs/socket/useful/youtube.html)
### TypeScript

> TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
* 具型態註解功能
* 將原先 JavaScript 弱型別的特性變成強型別
* 可編譯成 ES5 (瀏覽器支援之 JS 版本)
- [[Medium] TypeScript 入門 {學習筆記}](https://medium.com/tkd-giant/typescript%E5%85%A5%E9%96%80-%E5%AD%B8%E7%BF%92%E7%AD%86%E8%A8%98-d659bb592810)
### Python 3 的型態註解
* [[Python] typing — Support for type hints](https://docs.python.org/3/library/typing.html)
```python
def greet(your_name: str) -> str:
return 'Hi {}'.format(your_name)
```
### 在 Python 中實現 function overloading:`singledispatch`
* [[Python] functool -- Higher-order functions and operations on callable objects](https://docs.python.org/3/library/functools.html)
* [functool.singledispatch](https://docs.python.org/3/library/functools.html#functools.singledispatch)
* [functool.singledispatchmethod](https://docs.python.org/3/library/functools.html#functools.singledispatchmethod)
在 Python 3.4 以上支援 `singledispatch`,可實現函數層級的 function overloading,但不包括在 Class 當中的函數 (Method)
```python
import functools
@functools.singledispatch
def greater_than_me(value):
raise NotImplementedError
@greater_than_me.register
def _(value: int) -> int:
return value + 1
@greater_than_me.register
def _(value: float) -> float:
return value + .1
print(greater_than_me(1)) # 2
print(greater_than_me(1.1)) # 1.2
print(greater_than_me('1')) # will raise NotImplementError
```
而在 **Python 3.8** 以後方支援在 Class 當中的函數 `singledispatchmethod`
```python
import functools
class GreaterThanMe:
def __init__(self, times: int) -> 'GreaterThanMe':
self.times = times
@functools.singledispatchmethod
def much_greater_than_me(self, value):
raise NotImplementedError
@much_greater_than_me.register
def _(self, value: int) -> int:
return value + self.times * 1
@much_greater_than_me.register
def _(self, value: float) -> float:
return value + self.times * .1
g = GreaterThanMe(3)
print(g.much_greater_than_me(1)) # 4
print(g.much_greater_than_me(1.1)) # 1.4
print(g.much_greater_than_me('1')) # will raise NotImplementError
```
### Python 語法糖:`@`
#### 第一種用法:裝飾器
* [[iT邦鐵人賽] DAY09 - 搞懂 Python 的裝飾器](https://ithelp.ithome.com.tw/articles/10200763)
* [[Python] PEP 318 -- Decorators for Functions and Methods](https://www.python.org/dev/peps/pep-0318/)
#### 第二種用法:Python 3 NumPy 矩陣乘法
* https://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.html
```python
import numpy as np
a = np.eye(3) # identity matrix of degree 3
a[0, 0] = 2 # change a[0, 0] from 1 to 2
b = np.array([1, 1, 1])
print(a @ b) # [2, 1, 1]
```