[TIL] 為了自己的習慣,弄了一個簡單的服務 Github issue bookmark

本篇提到的開源專案: https://github.com/kkdai/bookmark-makerserver https://github.com/kkdai/bookmarks 起因 平時習慣拿 twitter 作為 bookmark 的概念,看到喜歡的鏈結或是網站就直接 tweet 出來. 但是都沒有記錄下來. 之前有想過透過程式設計週記的方式來記錄下來,但是又覺得太過流水帳而且沒有辦法有系統的分類. 想著想著就想到透過 Github Issue 來做這件事情,有以下的好處: 可以透過 Label 來分類 可以使用 Github 的搜尋功能來尋找想找的部分 可以補充很多的 comment 在同一個 issue 上面做為閱讀後的心得記錄.更方便未來搜尋. 架構 一如往常,我依舊使用許多免錢的架構.並且將整個流程都開源給大家分享,大家應該可以在五分鐘內建立自己的整體流程. 你可能要自己做的事情如下: 取得 Github Auth Token (去這裡) 取得 IFTTT Maker 帳號與權限 修改一下 IFTT Maker 資料. 詳細流程都在 https://github.com/kkdai/bookmark-makerserver 支援的語法範例 這裡提供一些 tweet 的範例,還有他會變成何種 github issue gernest/mention: Twitter like mentions and #hashtags parser for Go(Golang) # easy way to get hashtag in #golang https://github.com/gernest/mention Title: gernest/mention: Twitter like mentions and #hashtags parser for Go(Golang) Content: easy way to get hashtag in Labels: hashtags,golang Link: https://github.com/gernest/mention 希望能提供給一些需要的人,有任何問題歡迎發 issue 討論 .. 未來發展 幾個階段… 第一個階段應該會先支援 Facebook 貼文,並且根據我臉書文章格式來貼 Github issue 等收集好大量的 Github issue 後,應該會寫另外一個工具來定期(每個禮拜) 根據 Github issue 來產出 Monthly_README.md 甚至可以把這個機制弄成電子報… 恩… 應該說是部落格好一點.
繼續閱讀

[Coursera] Illinois: Cloud Computing Concept Part 1 : Week 5

課程鏈結: 這裡 學習鏈結: Week 1-2 Week 3 Week4 Week5 Mini Project (Gossip Protocol) 課程內容: 這裡先簡單的介紹整系列的課程內容,希望能讓大家了解這個課程想做什麼. 這整堂課主要是圍繞著 Cloud Computing 經常會使用到的技術與相關的概念. 整堂課其實只有一個程式語言作業: 使用 C++ 寫 Gossip Protocol 雖然課程裡面程式語言的作業不多,但是整體上的內容還算不少. 除了有談到一些雲端技術的基本概念: Map Reduce Multicasting and Gossip Protocol P2P Protocol and System K/V DB, NOSQL, and Cassandra (畢竟都談了 Gossip) Consensus Algorithm - Paxos, FLP Proof 其實課程內容很有料,也可以學到很多的東西. 前提: Snapshots Global Snapshot Global Snapshot = Global State =Individual state + communication channel 時間不同步的時候所造成 Global Snapshot 會失敗的原因 時間不正確 無法抓到溝通的狀態 任何造成 Global Snapshot 變動的原因: Process send/receive message Process move one step 以一個範例來解釋演算法 基本定義: There are no failures and all messages arrive intact and only once The communication channels are unidirectional and FIFO ordered There is a communication path between any two processes in the system Any process may initiate the snapshot algorithm The snapshot algorithm does not interfere with the normal execution of the processes Each process in the system records its local state and the state of its...
繼續閱讀

[TIL] Advanced Scheduling in Kubernetes

前提 在 Kubernetes 或是 DCOS 這種集群管理系統上要分配工作相當的方便,但是有些時候我們需要指定某些特定的任務在指定的機器上面才能夠執行. 在 DCOS 上面可以使用 Constraints Kubernetes 裡面要達到指定 POD 到特定的機器上面,一般來說而言有以下幾種方式: nodeSelector (1.0) Kubernetes 1.6 之前官方推薦的方式,不過 1.6 之後請使用 Affinity Affinity (After Kubernetes 1.6) Taints and Tolerations (After Kubernetes 1.6) nodeSelector 簡單的方式就是透過對於 node 設定不同的 label 來讓 nodeSelector 可以找到適當的機器. 比如說你有一台機器有特殊的硬體,比如說 GPU kubectl label nodes windows-node1 hardware=gpu 以本次的範例來說,我們部署了不少的機器.其中有一台專門負責部署 Web App kubectl label nodes windows-node1 usage=app 設定好之後,也可以去查詢你目前節點所有的 labels kubectl get nodes --show-labels 提供一個官方的簡單範例,讓我們了解如何使用 nodeSelector apiVersion: v1 kind: Pod metadata: name: nginx labels: env: test spec: containers: - name: nginx image: nginx imagePullPolicy: IfNotPresent nodeSelector: usage: app 試著跑起來看看…. (架設檔案名稱為 testpod.yaml) kubectl create -f testpod.yaml 查看結果…. kubectl get pods -o wide 以下的部分只允許在 Kubernetes 1.6 以後才能正確執行. Affinity (After Kubernetes 1.6) Affinity 透過類似的方式可以指定 POD 所執行的位置,但是語法不是很類似. 以下先展示一個跟上面範例相同語法的範例 (testpod_affinity.yaml) apiVersion: v1 kind: Pod metadata: name: nginx labels: env: test spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: usage operator: In values: - app containers: - name: nginx image: nginx imagePullPolicy: IfNotPresent 那大家會問說, Affinity 究竟功能有哪些比起 nodeSelector 還強大.讓之後官方會建議使用這個?...
繼續閱讀

[TIL][文章推薦] 設計高效能的 Hash Table

原文 Felix Chern: 設計高效能的Hash Table(一) 心得 還記得當初在寫 Consistent Hashing 的時候,一直不願意拿人家寫好的 Hash Function 來改,硬要自己寫一個. 結果發現寫出來的 Hashing 一直出問題.才知道原來 Hash Function 是實作 Consistent Hashing 的一個重點. 這一篇文章有了一些基本對於 Hash Function 的介紹,也把幾個好用的 Hash Function 一一的列出來. 其中包括了最近被移到了 Google 的 “highwayhash” 或是之前有介紹過在 Uber/ringpop 下作為 Consistent Hashing 的 farmhash 這篇文章相當推薦,原因如下: 作者 (Felix Chern) 目前似乎在 Google 工作,部落格文章都相當有深度. 有 Hash Function 列出的清單並且有簡單的介紹. 參考: ringpop 是 Uber 的去中心化 App : 這篇文章有下集,在這裡 關於實作與相關測試: 其實 Damian Gryski 實作了不少 Hash Function 的 Go 套件 HighWay Hash 其 Benchmark 如下: ~/s/g/s/g/d/go-highway   master  go test -bench=. 六 4/29 01:31:56 2017 BenchmarkHighway8-8 50000000 26.3 ns/op 304.36 MB/s BenchmarkHighway16-8 50000000 26.7 ns/op 599.24 MB/s BenchmarkHighway40-8 50000000 29.7 ns/op 1345.35 MB/s BenchmarkHighway64-8 50000000 33.3 ns/op 1924.53 MB/s BenchmarkHighway1K-8 10000000 137 ns/op 7452.07 MB/s BenchmarkHighway8K-8 2000000 873 ns/op 9378.40 MB/s Farm Hash 其 Benchmark 如下: !  ~/s/g/s/g/d/go-farm   master  go test -bench=. 257ms  六 4/29 01:30:43 2017 BenchmarkHash32-8 20000000 100 ns/op BenchmarkHash64-8 20000000 58.2...
繼續閱讀

[TIL] Chatbot Day Quick Note

Talks 聊天機器人與對談式商務的未來發展 - Clement Tang Chatbot situation and chatbot types. Chatbot的智慧與靈魂 - 陳縕儂 – 台大資工系助理教授 前半段: 討論 AI Bot 的分別與差異,目前的 Chatbot 主要都專注在 Conversation . 後半段: 一天搞懂對話機器人 Chatbot 應該要聰明的來處理前後文 (Dialog) Human-like dialog system 運用對話機器人提供線上客服服務 -Herman Wu -微軟技術傳教士 QnA Maker: Upload Q&A document into ML, system will convert file into knowledge base extraction. It could learn and publish as API service. Bot-Framework Provide bot simulator (sounds great) CNTK (MS Deep Learning toolset) Azure Container Serice Only cloud to support three kind of container management system. 突破 Facebook messenger platform API 限制 張家豪 - Ucfunnel 工程 Her/Him Her/Her 匿名聊天 貼圖也可以傳 一般 Chatbot 無法傳貼圖 變通方式轉貼截圖 Solution: facebook-chat-api can convert AP_ID FB_ID facebook-chat-api can get stick_id 話題產生器 產生交友行為 (交換 FB ID) 一般來說只能拿到 AP_ID 無法拿到 FB_ID Solution: facebook-chat-api to convert it. 如何在 24 小時後回話 在 FB 超過一天 Chatbot 會失敗 Solution: Use facebook-chat-api ping if user block If not, we could renew conversion window (TBC) facebook-chat-api link...
繼續閱讀

程式設計週記[2017/04/21]: Golang 可以做的事情越來越底層了

這是什麼? 程式週記主要內容如下: Gihub project 介紹: 主要會貼一些github,但是會盡量寫上一些有用的評語(或是我容易想到的關鍵詞)幫助以後查詢 網路文章心得: 會寫些心得,強迫自己閱讀. “程式週記”並且定期週期性更新. 大部分內容在我的twitter都會有,這邊只是將一些簡單的心得與感想註解一下. 本週摘要 到了四月了,當初不小心把兩個分享都排在四月,於是又要準備兩個投影片.重要的是, Chatbot Day 的部分還有不少的 code 要準備. Go schollz/linkcrawler: Cross-platform persistent and distributed web crawler 是一個跨平台具有分散式與一致性的網頁爬蟲工具.具有可以一次將多個目標全部分散給各個 client 來抓取的功能.充分使用到 Golang 許多的特性,可以好好來看看 justForFunc justForFunc 是由 Google 傳教士 - Francesc Campoy 所主持的 Youtube 頻道,裡面的內容都是講解 Golang 相關的部分,歡迎大家來訂閱. 此外: Google Cloud Platform Podcast 也是 Francesc 的另外一個的項目,主要就是 Google Cloud Platform 的 Podcast .這也是我經常收聽的. Francesc 跟 Mark 的對談很有趣 Introducing NATS to Go Developers – Shiju Varghese – Medium NATS 是一個使用 #golang 建置的分散式 Message Queue 系統 (另外還有一個大家熟知的是 NSQ) NATS 原本是由 Ruby 開發而成,經由 Apcera 改寫成 Golang 之後持續維護的, 這篇文章有著基本的介紹,並且講解如何使用.. Mobile Apps by Pure Go with Reverse Binding 這篇討論一個很有趣的方向,在討論如何從 gomobile 裡面的 golang 語言中如何在呼叫 platform 的 code (ex: Android Java) 做法也很傳統,就是多包一層 cgo -> jni -> java . 真是老方法就是好用…. 不過不知道有沒有雷…. DigitalOcean Hsinchu 這活動不錯… 跟 #Golang 有關,不過地點在新竹… 有 HackMD + appleboy + kubernetes How We Built Testable HTTP API Server GoConJP 的投影片,講解如何建置一個可以測試的 HTTP API Server. 很多觀念基礎都有點到,搭配 Golang 語言特性 (built-in testing) 實在很方便. Introducing NATS to...
繼續閱讀