2026-08-17

深夜驚醒,

不知道是哪一句歌
先穿過夢的縫隙。

紅磨坊仍在唱,
燈火那麼紅,
愛情那麼盛大,
像所有年輕時相信的事——
只要足夠用力,
就能抵抗離別。

於是我想起高中那年,
和那年同行的女孩並肩坐在黑暗裡,
銀幕亮著,
她的側臉也亮著。
那時候不知道,
有些電影散場以後,
人也會慢慢散場。

可是多年後的今晚,
真正讓心湖起風的,
竟不是她。

是另一個女孩。

那個沒有追到的人,
那條沒有走成的路,
那一句也許應該說出口
卻留在喉嚨裡的話。

奇怪的是,
歲月把她們放在不同的地方,
記憶卻在凌晨
把她們疊成同一片光。

我忽然分不清
自己懷念的是誰。

是那年同行的人嗎?
是未完成的喜歡嗎?
還是那個坐在青春裡,
以為人生很長,
每一條岔路
以後都還有機會回頭的自己?

原來人到後來
最難忘的未必是誰。

而是那些沒有活成的人生。

如果那天勇敢一點,
如果多說一句,
如果牽住另一隻手,
如果在某個路口
沒有轉身——

如今的我,
會在哪一個深夜醒來?
又會為誰
聽見同一首歌?

可是人生沒有如果。
只有歌聲穿過二十年的黑暗,
忽然抵達床邊,
提醒我:

那些女孩已經遠了,
那些夏天也遠了,
連當年那個
覺得來日方長的少年,
都已經走了很遠。

人生好短暫。

短得一場電影還沒有忘記,
青春卻已經成了往事;
短得一句歌詞才剛響起,
半生便在胸口
輕輕翻了一頁。

於是今晚我終於明白——

我懷念的也許不是某一個人,
而是那個
還有無數人生可以選的自己。

而那些沒走過的路,
那些沒牽到的手,
那些沒有發生的故事,

並沒有真正消失。

它們只是沉在心底,
等一首很多年前的歌
在凌晨響起,

然後一起回來,
坐在我的床沿,

陪我看一眼
已經如此短暫,
又如此漫長的
一生。

2024-01-09

Configuring HAProxy as a proxy for Cargo

Configuring HAProxy as a proxy for Cargo (the Rust package manager) in a corporate network environment involves several steps. Here's a general guide on how to do it:

  1. Install HAProxy: If you haven't already, you'll need to install HAProxy on a server that has network access to both your corporate network and the internet. The installation process will vary depending on your operating system.

  2. Configure HAProxy for HTTP/HTTPS Forwarding:

    • Open the HAProxy configuration file (usually located at /etc/haproxy/haproxy.cfg).
    • Set up frontend and backend configurations for HTTP and HTTPS traffic. For Cargo, you'll primarily be concerned with HTTPS traffic to crates.io, the default source for Cargo packages.
    • In the frontend section, define the port that HAProxy will listen on for incoming HTTP/HTTPS requests.
    • In the backend section, specify the server(s) to which the requests should be forwarded. For Cargo, this will be the domain of crates.io and any other relevant domains.
    • Ensure HAProxy is configured to handle SSL traffic properly if you're dealing with HTTPS.
  3. Configure Cargo to Use the Proxy:

    • On the client machines that will be using Cargo, you need to configure Cargo to use the HAProxy server as a proxy.
    • This can typically be done by setting environment variables like http_proxy and https_proxy. These should be set to the address of the HAProxy server, including the port number you configured in the HAProxy settings.
    • For example, if your HAProxy server's IP address is 192.168.1.100 and it's listening on port 8080, you would set http_proxy and https_proxy to http://192.168.1.100:8080.
  4. Test the Configuration:

    • After configuring both HAProxy and Cargo, test your setup by running Cargo commands like cargo build or cargo fetch and verify that the traffic is going through HAProxy.
    • Check the logs of HAProxy to ensure that it's correctly processing and forwarding the requests.
  5. Configure Logging and Monitoring (Optional but Recommended):

    • For a corporate environment, it’s important to have proper logging and monitoring in place.
    • Configure HAProxy's logging to record the relevant data, and set up monitoring to alert you to any issues with the proxy server.
  6. Security and Access Control:

    • In a corporate environment, you might want to restrict who can use the proxy. This can be done through network-level access controls or configurations within HAProxy.
    • Ensure your HAProxy server is secured and up-to-date with security patches.

Remember, this is a general guide, and the specific details can vary based on your network environment, the versions of HAProxy and Cargo you're using, and other factors. It's always a good idea to refer to the latest documentation for HAProxy and Cargo for the most accurate and detailed instructions. 

2016-05-19

如何關掉 Adobe Reader DC 惱人的右側功能窗格 (Tool pane)

Adobe Reader DC 右邊的工具窗格 (Tool Pane) 預設是會打開的 而且不管在 Windows 還是 OS X 上都沒有辦法永久性的關閉 但是,道高一尺魔高一丈,總是能找到破解的方法~ 

首先,關掉你的 Adobe Reader DC

接著,編輯 layout 設定檔:

Windows 路徑: "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroApp\ENU\Viewer.aapp".
OS X 路徑: "/Applications/Adobe Acrobat Reader DC.app/Contents/Resources/AcroAapp/ENU/Viewer.aapp"
用繁體中文版的人,上面路徑的 ENU 請改成 CHT

然後,注解掉 Viewer.aapp 檔案裡面的 Layout element 如下紅字所示:

<Application xmlns="http://ns.adobe.com/acrobat/app/2014" title="Viewer"
  id="Viewer" majorVersion="1" requiresDoc="true" minorVersion="0"/>
  <!--Layouts>
    <Layout name="Default">
      <RHP>
        <Component name="AppShortcutListView" type="Custom"/> 
      </RHP>
    </Layout>
  </Layouts-->
</Application>

存檔離開,再重開 Adobe Reader DC 之後,右側窗格就不見啦 !!!
來源參考: https://forums.adobe.com/message/7547488#7547488

2016-05-08

讓 tmux 還原重開機後的 tmux 和 vim 狀態: tmux-resurrect plugin

人生總是難免會遇到要重開機的時候,
tmux 在重開機之後原本的 session 是會消失的,
身為一個追求極致開發環境的人,
當然不允許自己手動解決這個問題(重新設置 tmux window/pane)
但究竟該怎麼做,才能夠自動恢復重開機之前的 tmux 和 vim session 呢?

首先,我們來瞄一下 tmux plugin manager (tpm) 這個好東西:
顧名思義,tpm 是一個 tmux 的 plugin 管理工具,
可以透過 ~/.tmux.conf 設定檔來配置 tmux 的 plugin,
是一種跟 vim vundle 概念頗為相似的工具。

tmux-resurrect 是一個 tpm 的外掛
主要的功能是讓 tmux 的 session/pane 可以被儲存及載入。
也就是,在重開機之前一旦做了儲存的動作,
重開機後,tmux 可以完全回覆到先前的狀態!

除此之外,tmux-resurrect 還支援 vim session 回復的功能,
這功能可以讓 tmux-resurrect 在重新載入 tmux 時,一併載入當時的 vim session!
這功能實在是很威呀~
當系統不得不 reboot 的時候,這功能可以大幅減低 context switch 的 overhead 呀~

底下記錄了 tpm和 tpm plugin 的安裝與設定步驟,
為了區別兩者安裝方式的不同,
我把步驟分成兩個階段,第一階段是裝 tpm,第二階段才是裝 tpm plugin:

1. 安裝 tpm
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
2. 在 ~/.tmux.conf 的最底下加上
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
run '~/.tmux/plugins/tpm/tpm'
3. 安裝 tmux (一定要先記得進入 tmux)
tmux
tmux source ~/.tmux.conf  
上述步驟完成之後,再重開一次 tmux,tpm 就裝好了!

接著是安裝 tmux-resurrect 還有 vim 狀態自動回覆的 tmux plugin 設定:

1. 在 ~/.tmux.conf 加上底下紅字兩行
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @resurrect-strategy-vim 'session'

run '~/.tmux/plugins/tpm/tpm'
2. 安裝剛剛加上的 plugin
Prefix + I          # 是大寫 I
3. 看到提示後,按 ESC 離開安裝畫面

一切就搞定了:
  • 儲存目前的 tmux 和 vim 狀態: Prefix + Ctrl-s
  • 還原目前的 tmux 和 vim 狀態: Prefix + Ctrl-r
* tmux 預設的 Prefix 是 Ctrl-b

這實在是一個很威的功能呀!

這年頭系統程式的開發環境真的是要什麼有什麼了,
容易管理又好安裝,還真是幸福呀~
  • shell: oh-my-zsh
  • vim: vundle
  • tmux: tpm

==
後記
雖然我本人很喜歡 tmux + vim + cscope 來開發系統程式
但是,經歷過用 Sublime Text 寫比較高階的語言之後
我總覺得 Sublime 除了 trace C/C++ 的外掛很鳥之外(ctags/cscope 外掛一整個悲劇)
整體使用的開發效能,不會輸給黏在鍵盤用盡各種 vim/tmux 熱鍵的組合,
也許是 Sublime 有自己的熱鍵,加上比 gvim 順的 GUI,
也許是 vim 的 tab 切換太囉唆 (1gt, 2gt, gT, gt),indent 對齊遜了點,folding 太醜陋..
不過 vim 的 split (ctrl-w v, ctrl-w s) 和 ctrl + ] 又具備超高效率...
天底下似乎還沒有完美的 editor...  (atom太吃ram又慢,emacs沒有 hjkl...)

2016-05-07

在 Ubuntu 上執行 32-bit 的 app

在 Ubuntu 上,把想安裝的 package 名字後面接上 :i386
理想是可以在 Ubuntu 上安裝該 package 的 i386 版本
但是,如果只單純這麼做,
若系統已經存在 x86_64 的同名 package,
是會把原本 for x86_64 的 package 給移除的
因此,要避免這樣的問題,首先要新增 i386 這個 architecture

sudo dpkg --add-architecture i386

接著

sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

Reference

2016-05-03

千萬別壯志未酬身先死

人能走多遠,跟體力真的有很大的關係!
前陣子腰痛,診療後是膝蓋受傷引起的發炎,
加上搬到公司的新大樓,健身房還沒蓋好,
約有 2 個月的時間給自己藉口沒去好好運動,
短短這段時間,已經明顯感覺到體能下滑的很嚴重,
好不容易下班後能開始集中精神思考 OSDI 的問題,

沒想到才經過一下子就十分疲累了!

有點體會到「壯志未酬身先死」的概念是什麼,
但這並不是什麼好體驗呀~
看來得好好重新把發條上緊,
當自己是頂尖運動家來訓練身體了~





2016-04-24

升級到 tmux 2.1 以及搭配 vim + mouse 要注意的地方

在解釋程式碼或是 demo 的時候,
用滑鼠來導覽畫面總是可以帶來一些便利,
以往非常好用的 tmux + vim 在 tmux 升級到 2.1 之後,
需要做一些調整,以下簡單記錄我前陣子所調整的部分。

tmux 在 2.1 之前,我們通常會打開底下四個選項
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on

tmux 升級到 2.1 之後,上面四個選項被濃縮成底下一個選項
set-option -g -q mouse on
但是,目前的版本,mouse scrolling 和 page up/down 都無法正常運作
可以加入底下的設定來支援這兩個部分:
bind-key -T root PPage if-shell -F "#{alternate_on}" "send-keys PPage" "copy-mode -e; send-keys PPage"
bind-key -t vi-copy PPage page-up
bind-key -t vi-copy NPage page-down
bind-key -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
bind-key -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M"
bind-key -t vi-copy WheelUpPane halfpage-up
bind-key -t vi-copy WheelDownPane halfpage-down
另一方面,在 tmux 2.1 搭配 vim 時,即便已設定了 :set mouse=a,
vsplit 的邊框在預設情況下是不能拖拉的,因此,要另外設定:
set ttymouse=xterm2
並且在 drag 之前先按住 [Cmd] 鍵,splitter 才可以順利被 mouse 所拉動。

其他相關設定歡迎參考我的 .tmux.conf
這個設定檔包含在我的跨平台 shell 開發環境設定裡面。

--
Reference
http://superuser.com/questions/549930/cant-resize-vim-splits-inside-tmux
https://github.com/NHDaly/tmux-scroll-copy-mode

深夜驚醒, 不知道是哪一句歌 先穿過夢的縫隙。 紅磨坊仍在唱, 燈火那麼紅, 愛情那麼盛大, 像所有年輕時相信的事—— 只要足夠用力, 就能抵抗離別。 於是我想起高中那年, 和那年同行的女孩並肩坐在黑暗裡, 銀幕亮著, 她的側臉也亮著。 那時候不知道, 有些電影散場以後, 人也會...