在 Mac 上使用 GNU Commands
最近突然拿到一台 MacBook Pro,摸了幾天一直很不習慣。 macOS 的核心是基於 Unix 所開發的,terminal 中預設搭載的 command 跟 Linux 差非常的大 這讓習慣以 Linux 開發程式的人很不適應。 ...
最近突然拿到一台 MacBook Pro,摸了幾天一直很不習慣。 macOS 的核心是基於 Unix 所開發的,terminal 中預設搭載的 command 跟 Linux 差非常的大 這讓習慣以 Linux 開發程式的人很不適應。 ...
github.com/uber-go/zap, zap 是目前我比較常用的 logger package 在寫 log file 時,通常需要定期的封存檔案,避免單一檔案過大而導致之後難以整理 zap 本身沒有 rotation 功能,要自己寫,或是用 lumberjack 這個 package zap 官方的 FAQ 中 zap/FAQ.md ...
記錄一些比較常用/實用(可能)的快捷鍵 控制 Ctrl+C: 中斷正在執行的程式 Ctrl+D: 結束 shell (同 exit) Ctrl+Z: 暫停正在執行的程式,放入背景 (使用 fg 可以叫回來) Ctrl+X Ctrl+E: 使用 vim 編輯 script 並一次執行 移動 Ctrl+A: 到此行最前面 (同 Home 鍵) Ctrl+E: 到此行最後面 (同 End 鍵) Alt+B: 前進一個字元 Alt+F: 後退一個字元 Ctrl+B: 前進一格 Ctrl+F: 後退一格 刪除 Ctrl+H: 移除前一個字元 (同 Backspace 鍵) Ctrl+D: 移除後一個字元 (同 Delete 鍵) Ctrl+U: 移除游標之前的所有文字 Ctrl+K: 移除游標之後的所有文字 歷史指令 Ctrl+P: 上一個指令 Ctrl+N: 下一個指令 Ctrl+R: 搜尋指令 Ctrl+R: 上一個 Ctrl+Shift+R: 下一個 Ctrl+G: 取消搜尋 畫面 Ctrl+L: 清空畫面 (同 clear) Ctrl+S: 凍結畫面輸出 Ctrl+Q: 回復畫面輸出 Reference Bash Shell 快速鍵 | Tsung’s Blog Shortcuts to move faster in Bash command line - teohm.dev The Best Keyboard Shortcuts for Bash
每天都要看螢幕超過八小時的情況下,漸漸的想對自己的好一點,找一些讓自己眼睛比較舒服的字型。 一個每天都要盯著 terminal 的工程師,更是要選個看得清楚又容易辨視的字型來寫 code ...
邏輯運算子 php 的邏輯運算子除了 && 跟 || 之外,還有 and 跟 or 他們之間的差異在有不同的優先順序 Precedence 而這個優先順序上的差異,會讓程式在一些情況下,產生跟你想像的不一樣的成果 ...
前言 回歸使用 vim 當作主要開發工具後,為了省下調效 vimrc 的時間,決定先用別人整理好的設定,於是乎找到了 spf13-vim,便開始的了快樂的 vim 生活。 spf13-vim 用了數個月之後,熟悉了不少的設定方式,也調整不少符合自己習慣的設定。 ...
最近信箱會出現來自 Github 的信件 Github 現在會檢查你的專案中是否有用到有漏洞的套件版本,如果都沒有處理的話,還會一天來一封… 這只是個測試用專案,好像應該來處理一下,不然那信件有點煩人。 ...
增加 source list debian testing (buster, 10) 要選擇 bionic 版本, 避免套件相依問題 1 echo "deb https://download.virtualbox.org/virtualbox/debian bionic contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list 增加 apt key 1 2 wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - 安裝 Virtualbox 1 2 sudo apt update sudo apt install virtualbox-5.2 ps. Virtualbox 6.0 在 2018/12/18 發佈了 ...
SSD 優化的幾個要點 啟用 SSD 的 Trim 功能 減少非必要的寫入動作 掛載暫存資料夾到 Ram 上 啟用排程 Trim 1 2 $ sudo systemctl enable fstrim.timer Created symlink /etc/systemd/system/timers.target.wants/fstrim.timer → /lib/systemd/system/fstrim.timer. ps. 不建議使用 /etc/fstab 的 discard 選項 增加 Mount Options 修改前備份 fstab ...
每台機器都會有一些自己唯一的 id 在開發程式中,可能會有需要用來分辨機器 machine-id 1 2 3 $ cat /etc/machine-id $ cat /var/lib/dbus/machine-id product_uuid 1 $ sudo cat /sys/class/dmi/id/product_uuid MAC address 1 $ ip link Hard Disk UUID 1 2 3 $ blkid $ ls -l /dev/disk/by-uuid random UUID 1 2 3 $ cat /proc/sys/kernel/random/uuid $ uuidgen Reference https://www.thegeekdiary.com/centos-rhel-7-how-to-change-the-machine-id/ http://0pointer.de/blog/projects/ids.html https://liquidat.wordpress.com/2013/03/13/uuids-and-linux-everything-you-ever-need-to-know/ ...
入手 ThinkPad X1c 來當工作機 在使用了幾天不習慣的 windows 10 確定機器沒有什麼問題之後, 就把 OS 換成 Debian 了 安裝 Debian 之前 更新 BIOS 到目前最新的版本 1.34 調整以下的設定: Security -> Secure Boot - Set to “Disabled” Config -> Power -> Sleep State - Set to “Linux” Config -> Thunderbolt BIOS Assist Mode - Set to “Enabled” 安裝 Debian Linux Distribute: Debian testing ...
記錄一下目前會用的 Extensions Gnome Shell Extensions 網址: https://extensions.gnome.org/ 增加操作性 Top Panel Workspace Scroll https://extensions.gnome.org/extension/701/top-panel-workspace-scroll/ 外觀調整 User Themes https://extensions.gnome.org/extension/19/user-themes/ Hide Activities Button https://extensions.gnome.org/extension/744/hide-activities-button/ Panel OSD https://extensions.gnome.org/extension/708/panel-osd/ Remove Dropdown Arrows https://extensions.gnome.org/extension/800/remove-dropdown-arrows/ 實用功能 Caffeine https://extensions.gnome.org/extension/517/caffeine/ Lock Keys https://extensions.gnome.org/extension/36/lock-keys/ Extensions https://extensions.gnome.org/extension/1036/extensions/ Suspend Button https://extensions.gnome.org/extension/826/suspend-button/ Night Light Slider https://extensions.gnome.org/extension/1276/night-light-slider/ Clipboard Indicator https://extensions.gnome.org/extension/779/clipboard-indicator/ OpenWeather https://extensions.gnome.org/extension/750/openweather/
Go 原生的 Error Type 先認識 go 的 error interface 1 2 3 type error interface { Error() string } 只要 struct 實作 Error() 方法,就會是 error type,例如 os package 裡面的 PathError https://golang.org/pkg/os/#PathError 1 2 3 4 5 6 7 8 // PathError records an error and the operation and file path that caused it. type PathError struct { Op string Path string Err error } func (e *PathError) Error() string { return e.Op + " " + e.Path + ": " + e.Err.Error() } 建立自己程式裡的 Error struct 依照使用情境 error strcut ...
語言/框架: 前端: react/redux/Semantic UI React 設計元件,不再是過去設計模版的方式 後端: php/lumen, golang/echo php 快速開發 go 效能優秀,善於處理並發工作 編輯器 vim: 工程師最好的伙伴 vscode: 第三方套件對 javascript 有很完整的支援 開發環境 vagrant: 用配置檔來管理虛擬機器 docker: 輕量化,快速啟動服務 測試工具 postman: 方便測試 RESTful API 工作管理 gitlab: 有 private repo,可以考慮自行架設的 git service trello: 把工作項目放到看板上,更容易看清工作的全樣 文件 hackmd: 共筆用 draw.io: 畫流程圖很好用 evernote: 個人筆記,有跨平台,可以在手機上做筆記 imgur: 上傳圖檔用 Summary 整理完有一種在寫履歷的感覺,還有一些在尋找跟試用的工具就沒列上來了 ...
用 curl 找一隻鸚鵡來跳舞 1 $ curl parrot.live 來源 curl 版: https://github.com/hugomd/parrot.live terminal 版: https://github.com/jmhobbs/terminal-parrot
什麼是 gRPC Google 推出的 RPC framework 採用 Google 制定的 protocol buffers 當作資料傳輸格式 有 proto 工具可以把你寫好的 proto file 直接生成程式碼 比 RESTful API 更快、更有效率 更多請參考官網: grpc / grpc.io 安裝 開始寫 gRPC 服務之前,要先安裝一些 protocol buffer 的工具 ...
Evernote 官方沒有出 Linux Application,只有在網站上介紹 NixNote,在 Linux 上,我都是直接用 web client。 web client 的基本功能已經很好用了,只是想要整理筆記的時候覺得有點不夠力 ...
安裝好基本款的 debian 是沒有 sudo 指令可以使用的,需要自行安裝設定 安裝 sudo 切換到 root 安裝 1 2 # su - # apt install sudo 設定 sudoer 1 # usermod -aG sudo nyo 設定好之後,登入並用 sudo 隨意打個指令試試 ...
被稱作 Linux 神器的工具 入門之後我也愛上它了,讓 terminal 變得非常的靈活 安裝 mac 1 $ brew install tmux ubuntu / debian apt 上裝的可能會太舊,直接裝 github 上最新 release 的 參考別人寫好的腳本: https://gist.github.com/P7h/91e14096374075f5316e 1 2 3 4 5 6 7 8 9 10 11 12 13 VERSION=2.6 sudo apt -y remove tmux sudo apt -y install wget tar libevent-dev libncurses-dev wget https://github.com/tmux/tmux/releases/download/${VERSION}/tmux-${VERSION}.tar.gz tar xf tmux-${VERSION}.tar.gz rm -f tmux-${VERSION}.tar.gz cd tmux-${VERSION} ./configure make sudo make install cd - sudo rm -rf /usr/local/src/tmux-* sudo mv tmux-${VERSION} /usr/local/src tmux.conf 放上幾個我覺得實用的設定 ...
使用目前最強大的 vim 套件包 spf13-vim 安裝 vim 需要支援 lua 版本的 vim mac 1 2 $ brew install macvim --with-cscope --with-lua --override-system-vim $ brew install ctags debian 1 $ sudo apt install vim vim-gnome vim-doc ctags windows 我不知道 安裝 spf13-vim 有一鍵無腦安裝的指令 ...