utterances: 使用 github issue 做部落格的留言系統

說到留言系統,過去最常看到的大概是 Disqus 但是實際使用過會發現 Disqus 的檔案太肥大,會拉長網站的載入速度,所以在我把部落格移到 github 上面的時候,就完全不想要整合留言系統 ...

20 March 2021 · 1 min · nyo

Interface in Go

Interface Go 的 interface (介面) 是一堆方法簽章集合而成的 type (型態), 只要一個 type 實作出 interface 定義的所有方法,就是實作 interface interface 是 Go 用來定義物件行為的方式,其概念是: 如果某個物件可以做「這件事」,那麼它就可以用來當成是「這種東西」。 ...

16 March 2021 · 2 min · nyo

2020 打字練習記錄

2020 十月開始到十二月斷斷續續練習了幾十天的英打,有時練習一兩分鐘,有時練了超過 30 分鐘, 從 30 wpm 練習到可以破 60 wpm,最高記錄有摸到 71 wpm 一開始是看了一篇分享提升打字速度的影片,就突然想開始練習 ...

27 February 2021 · 1 min · nyo

IPv6 簡介

IPv6 是為了解決 IPv4 位址用盡問題而誕生的 長度從 IPv4 的 32 位元增加到 128 位元 常用表示方法 使用冒號組合 8 組 4 個十六進位數字 1 2 ex. 2001:0db8:86a3:08d3:1319:8a2e:0370:7344 簡短 IPv6 的規則 每一組數字前導的零可以省略 ...

26 February 2021 · 1 min · nyo

Vim File Explorer - Defx

原本的 vim file explorer 是用 NERDTree,最近發現 vim 大師 Shougo 有推出 Defx,所以就來試試新工具 Defx 沒有預設的快捷鍵,需要自己做大量設定。一開始我把快捷鍵設定成跟 NERDTree 很相似,但是怎麼試都不太順手,就不再使用過去的習慣了。 ...

21 February 2021 · 2 min · nyo

Makefile: Phony Targets

Makefile Rule Makefile Rule 格式如下 1 2 target: prerequisites recipe target: 要產生的檔案名稱 prerequisites: 產生 target 所需要的檔案 recipe: 要執行的動作 這裡準備一個寫 golang 會用到的 Makefile 如下面: 1 2 build: go build -o main main.go 執行 make build,Make 會先檢查有沒有 build 這個檔案,當檔案不存在的時候就執行 go build ... 指令 ...

24 January 2021 · 1 min · nyo

有效率的會議準則

開會很花時間,不順利的會議令人心很累。 有效率的會議提升時間的價值,更使人愉快工作。 工作時一定會有各種會議,「時間」跟「注意力」在不知不覺中就會被吃掉了。 ...

08 December 2020 · 2 min · nyo

找到 github 上面專案的最新版本

使用 github api 就可以查到最新的版本 需要的 command: curl jq 1 2 3 4 5 6 latest_release() { repo_name=$1 curl --silent \ https://api.github.com/repos/$repo_name/releases/latest | \ jq -r '.tag_name' } 執行結果,以 tmux 當範例 1 2 $ latest_release tmux/tmux 3.1c Reference Shell - Get latest release from GitHub

01 December 2020 · 1 min · nyo

Git Pull Warning and Foxtrot Merge

最近把 git 升級到 2.27 版 1 2 $ git version git version 2.27.0 執行 git pull 指令時,會跳出一篇警告 1 2 3 4 5 6 7 8 9 10 11 12 13 $ git pull warning: Pulling without specifying how to reconcile divergent branches is discouraged. You can squelch this message by running one of the following commands sometime before your next pull: git config pull.rebase false # merge (the default strategy) git config pull.rebase true # rebase git config pull.ff only # fast-forward only You can replace "git config" with "git config --global" to set a default preference for all repositories. You can also pass --rebase, --no-rebase, or --ff-only on the command line to override the configured default per invocation. 大致上是要你決定在 pull 遇到分支衝突的處理方式。 ...

01 December 2020 · 2 min · nyo

清除沒有用的 Docker Image

寫這篇文章時的 docker 版本 1 2 $ docker -v Docker version 19.03.13, build 4484c46d9d 查看、刪除 Image 查看 images $ docker images 刪除 images $ docker rmi <image_id> 正在使用的 image 不能刪除 1 2 $ docker rmi 63130206b0fa Error response from daemon: conflict: unable to delete 63130206b0fa (must be forced) - image is being used by stopped container 730c4cddd1ad 清除沒有用的 Image 清除沒有被 tag 的 image 1 2 3 $ docker image prune WARNING! This will remove all dangling images. Are you sure you want to continue? [y/N] y 清除沒有被 tag 也沒有被引用的 image 1 $ docker image prune -a 條件過濾,清除 24 小時以前建立的 image 1 $ docker image prune -a --filter "until=24h" Reference https://docs.docker.com/config/pruning https://docs.docker.com/engine/reference/commandline/image_prune

17 November 2020 · 1 min · nyo

四個「簡單設計」規則 (Xp Simplicity Rules)

一直想找看看有沒有更加簡單好懂,更為基本的原則,當做程式設計時核心理念。 看過 SOLID,讀過 Clean Code,在實戰中不斷的練習。研究設計模式 (Design Pattern),但是複雜解決方案不一定能夠派上用場。 ...

25 October 2020 · 2 min · nyo

CI vs Hooks 自動化工具比較

前陣子在一場討論中,聊到一些能夠觸發測試的自動化工具 (Gitlab CI, Phabricator Arcanist, Git hooks) 討論的過程中,發現有些人會認為只要能夠自動執行測試,效果上都是一樣的。但實際上,每個工具想要解決的問題並不一樣。 ...

18 October 2020 · 2 min · nyo

試用 GORM

ORM (Object Relational Mapping) ORM 是一種把 資料庫 對應到 程式物件 的技術,可以讓開發者更快速的開發處理資料庫的程式 使用上常見優點: 快速開發 較高的安全性 也是有相對的缺點: 犧牲效能 額外的學習成本 難以處理複雜查詢 這次看在優點上,小試了一下 Go 裡面的 ORM 工具 ...

05 August 2020 · 1 min · nyo

我們需要 Readme

問題情境 拿到一份程式碼,但是不知道可以做什麼,不知道怎麼運行它 一個宣稱幫你解決很多麻煩的工具,但是沒有說明清楚怎麼使用 想要參與專案的開發,但是不知道如何設置開發環境 當你遇到這些問題時,你會怎麼解決問題? ...

21 July 2020 · 1 min · nyo

新的 Github Profile 區塊

最近在 github 上發現一個功能,不確定是什麼時候開始有的 就是只要建立一個跟自己帳號同名的 repository 裡面 README.md 的內容就會顯示在 profile 上面 建立新的倉庫 輸入自己的帳號,github 會跟你說你發現了一秘密 ...

12 July 2020 · 1 min · nyo

Go Modules With Private Git Repository

go 1.14 開始,go modules 可以在正式環境上使用了 你可能會建立自己私人的工具庫,這時要搭配 go modules 就需要做一些設定 基本的設定 假設現在要建立一個私有 module 倉庫,放在 gitlab.com/nyorc/module 1 2 mkdir module cd module 啟用 go module ...

11 July 2020 · 1 min · nyo

Functional Programming With Go

Functional Programming 中文:函數式程式設計,是程式設計方法 (programming paradigm) 的其中一種 所謂的 Functional Programming 是以數學函數的概念來設計程式,並避免有狀態 (state) 與避免可變資料 (mutable data) 以下是一些 Functional Programming 的特點 ...

26 June 2020 · 2 min · nyo

Manifesto Software Craftsmanship (軟體工藝宣言)

Manifesto Software Craftsmanship As aspiring Software Craftsmen we are raising the bar of professional software development by practicing it and helping others learn the craft. Through this work we have come to value: Not only working software, but also well-crafted software Not only responding to change, but also steadily adding value Not only individuals and interactions, but also a community of professionals Not only customer collaboration, but also productive partnerships ...

03 June 2020 · 1 min · nyo

Cohesion and Coupling

想要評估一份程式碼是不是好的設計,不會是比較資深的工程師說了就算數 其中一個方法就是從內聚跟耦合的程度來評估 Cohesion (內聚) 一個模組內的不同功能的相關程度 ...

01 June 2020 · 1 min · nyo

軟體開發原則: DRY, KISS, YAGNI

最近在 code review 時,看到不少讓人頭暈的程式碼 在討論如何寫出更好的程式碼之外,應該要回顧幾個軟體開發原則,避免自己走歪路 DRY wiki: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself 原文: Don't repeat yourself,如同字面上的意思,不要重複你的程式碼。 ...

11 May 2020 · 2 min · nyo