2024/02/21

用壞一支智慧手錶

當初趕流行, 看上了Fitbit charge 5這隻手錶, 想要知道我的睡眠品質如何, 結果只有第一個晚上量得出數字, 充電也常常充不進去, 心裡就覺得這隻錶真是嬌貴, 要配合它的脾氣才會正常工作. 後來也只有在跑步時才會帶著它,看看整趟下來跑了多遠, 回頭來看, 一週至多只帶它一次, 不過不管怎樣吧, 至少我是努力讓它不至於變成電子垃圾.

結果最近充完電後, 直接出現一個紅色X的畫面;看來手錶放棄自己了 XD. 經過這段經歷, 我至少短期內不會再買智慧手錶了.

2023/11/12

So you want to be a lone wolf?

Yes

古人說四十不惑,五十知天命, 雖然我還沒到五十歲, 但也漸漸開始查覺自己的天命是什麼了, 這個天命就是 lone wolf. 小時候有孤單老人上新聞時, 同學就會開玩笑說我長大以後會變成孤單老人, 當時還會不服氣, 現在我不會用孤單老人形容自己, 不過會大方承認我就是lone wolf, 一匹孤狼, 靠自己的能力養活自己, 專注在設定的目標, 不在意他人的眼光和評價, 穿著素色的衣服表達內斂的特質, 安靜坐下, 觀察週遭的環境, 必要時才說一兩句話.

和反社會人格不同, lone wolf 只靠自己及少數人就能活下去, 但反社會人格的人需要靠許多人的支持才活得下去, 儘管在外顯出來, 這兩類人都不好相處, 但還是有跟本上的差別.

Lone Wolf的重點是Lone, 我喜歡一個人跑步,一個人健身, 一個人跑步, 一個人靜靜把工作做完. Wolf 是 spiritual animal, 指的是形像上的比喻, 不是指為達目的不擇手段的狼性.

Lone Wolf理解自己, 肯定自己, 獨立, 自食其力, 不斷擴大自己的認知邊界, 偏好quality而不是quantity, 欣賞別人的優點, 尊重自己及別人的時間, 真正理解快樂來於自己內心深處而不是外在的肯定.

雖然常常會被人誤解, 但那又如何, lone wolf才不管這些呢!

2023/10/01

漂亮的天空

過了盛夏, 天黑時間漸漸提前, 回家時正巧是黃昏時刻, 在等紅燈時突然發現天空好漂亮, 趕緊拿出手機拍下來. 這個路口的紅燈等待時間特長, 大概也只有這種機緣才會覺得等紅燈沒有什麼, 科科.

2023/05/21

新家裝潢

裝潢在兩年前就做好了, 當初在做的時候有些目標, 把家裡弄得和飯店一樣舒適, 還要好照顧, 還要省錢. 兩年下來, 我認為目標有達到(開心~~), 裝潢過程中和設計師來回討論過n回, 感謝他對部分想法的包容, 儘可能完成客戶的需求.

價錢部分, 差不多一坪對應到的裝潢是4萬元, 加上家俱家電以後, 整體花了錢還在預期內. 如果未來還有機會的話, 還是會去買沒有裝潢過的素屋, 自己打造自己的家.

2023/03/02

令人心情複雜的孩子

最近看到老大在醫院的收據上寫著 ADHD 四個字, 心中情緒很複雜, 帶孩子是件有負擔的事, 再加上 ADHD, 這個負擔更大. 老大還算是好的, 至少還能和外界保持一定程度的溝通. 第二個孩子就不同了, 他似乎活在自己的世界裡, 一門心思就是騎著自己的車車或者是安靜玩自己的玩具, 幾乎不太說話, 問他問題直接用嗯!表示拒絕. 我小時候也應該是這樣子(難怪很多人說我自閉), 雖然我對孩子的行為能感同身受, 但時常對未來並沒有太多樂觀的期待, 很可能這十年的時間, 就是要投入到教導這兩個孩子身上, 其他的事情就不要想太多了.

每當夜深人靜時, 有些不安的想法會自動湧上來, 像是

  • 他們以後在學校能學到東西, 能和別人好好相處嗎?
  • 他們能找到好工作嗎?
  • 萬一我們都不在了, 他們要怎麼過活?

在網路上看到相同境遇的家長分享想法, 基本上大家的擔心都差不多, 至少知道我不是孤例, 就足以讓我感到有些安慰. 雖然兩個孩子可能都是天才, 但這段時間真得不好過啊.

2020/03/19

使用std::accumulate的注意事項

The third parameter of std::accumulate is not only used as the base of summation but also the type used through out the API.

2020/02/17

Make gentoo-based docker image

As a gentoo user, I want to build gentoo-based docker image to can deploy to other Linux distributions. Such a docker image is usually faster when compared to another one generated otherwise. This post documents my experience. In general, there are several steps as shown below.

  1. Prepare systemd-based stage3 image (mine is stage3-amd64-systemd-20190323.tar.bz2)
  2. make a chrooted environment, as we do in standard gentoo installation.
  3. Install the package into an initially empty directory.
  4. Make docker image from that installation directory.

Step 3 is the key. To do so, we need to use ROOT environment variable during emerge. Suppose that we want to make an image running nginx service. The command is as follows.

ROOT=/mnt/nginx-docker emerge bash shadow glibc nginx

(Tips: we can futher chroot to /mnt/nginx-docker to check if we can launch the service.)

The reason why emerging bash/shadow/glibc is that we use dynamic shared libraries when building nginx. Although I didn't try, I suspect that use ```emerge -e nginx``` would be OK in this case.

After emerge finishes, exit the chroot environment and run the following command:

cd /mnt/gentoo/mnt/nginx-docker tar --numeric-owner -cj --to-stdout . | docker import - gentoo-nginx:base

What follows is standard docker image making.

Although it is fun to do so, I would not recommend other people to make gentoo-based docker images because there are many dark corners out there. If I really need a gentoo-based docker image, I would pull the gentoo base image from docker hub, emerge packages, and make my docker image.

2020/02/13

讀書感想-紅樓夢

花了幾個月的時間看完紅樓夢,剛開始時是帶著兩個疑問在看的,一個是想知道為什麼它會是個經典,另一個是為什麼後來賈府會沒落。看到最後,心中的疑問就都解開了。

整體而言,紅樓夢寫得很有禪意,不同心境的人對相同的文本會有不同的解讀,我想主要是它同時出現對立的元素,說它是在講家庭愛情故事嘛,偏偏裡頭有官場的事,說它寫實嘛,偏偏裡面有怪力亂神的情節,說它描寫賈寶玉追求靈性嘛,偏偏又有一個被社會化的甄寶玉,說它是色情小說,偏偏裡面有忠君報國的正經論述。加上許多情節又不詳寫,有些文字又寫得隱誨,為整本書留下了大量想像空間和討論空間,所以上百年來熱度不減。

週遭很少人在討論紅樓夢,我想除了人物眾多,不容易和沒看過的人溝通以外,看過的人也不會說裡面有風月寶鑑這些東西,更別提它的用途了。

到了這個年紀,關注的內容不再是寶釵黛的三角關係,我更多看的是枱面下每個人的細節和互動;細數下來,賈府做過的破事還真不少,就只談死人的話,賈赦要為石呆子的死負責,王夫人要為金釧和睛雯的死負責,王熙鳳要為尤二姐的死負責,從情節來看,他們都是知道社會規範底線的人,但就是要把人給弄死,而且沒有悔意,這是人治社會的特性,人治社會會把人們心中惡的一面放大,縱使是以慈祥形現出現的薜姨媽,在得知兒子想執行一個男男的運動而被暴打一頓後,直覺反應也是透過賈府的權勢把凶手抓回來;若是把這些弄死人的場景原封不動搬到今天台灣來,他們沒有實現的可能,這是法治社會的好處,我們要好好珍惜。

有關賈府被抄的重要人物是賈雨村,在賈家被參時,賈雨村表現得比趙家人更像趙家人,為同宗的賈家補上一刀,只是在人治社會裡,少了血緣姻親的人如賈雨村之流,永遠當不上趙家人,最終他還是回到了原本的位置。

整本紅樓夢到底在講什麼呢? 我想,它講的是一個循環的故事,經過一個興衰的循環之後,每個人回到了原本屬於他的地方。

2018/05/05

刻意練習

最近又看了一本好書,書名是「刻意練習」,講述學習方法的學術研究成果,書裡講的學習方法叫刻意練習法,它並非指學會一項技能或一個知識而已,而是如何學到頂尖高手的境界。刻意學習法有四個特點,前兩個是要有具體目標以及要專注,這和一般的學習法的要求相近;後兩個特點就不一樣了,一個是意見回饋,在部分情況下,這代表要找到可以給出具體回饋的專家,以及要付出錢請這樣的專家來指導;最後一個特點則是在舒適區及恐慌區之間大量練習,這則是花大量時間和人的慣性及惰性作博鬥。

書裡有些觀點和傳統觀念不同,像是技能不能轉移,能記住一長串的數字並不代表能記住一長串的字母;一般傳統的看法是類似的能力可以轉移,像是國文成績好往往代表英文成績好。除此之外還有另一個有意思的隱喻,學習既然是在舒適區之外進行,那就是在有點痛苦的狀態下進行,故學習並不是個會讓人感到快樂的事。

對像我這把年紀的人而言,看完整本書之後最感到欣慰的是學習不分年齡和領域,只要用對學習方法並實踐,就可以練成高手,「老狗變不出新把戲」這句俗語是拿來吵架用的,並不是指人在變老之後就再也學不會新技能的社會學結論。

這本書最讓人佩服的是論述完整,除了有刻意練習法的主體論述外,它也對讀者可能有的提問作出直接或接間的回答,這些提問像是

  • 為什麼有些人從事同一領域多年,卻成長有限?
  • 若技能是靠刻意練習練出來的,那如何解釋像貝多芬、愛因斯坦等天才的存在?
  • 世上有「天賦」這件事嗎?
  • 若技能不能轉移,為什麼國文分數高的人往往英文分數也比較高?
  • 智商在學習過程裡拌演的角色是什麼?
  • 為什麼有些人能夠快樂學習並成為高手?

有關這些提問的回答有些僅止於臆測,尚有待新的研究𨤳清,不過就一本大眾讀物而言,能把自己的主張輪圓並完整講述出來,令人佩服。

2017/09/16

Setup L2TP/IPSec VPN server on Gentoo Linux

It is not trivial to setup VPN server on Gentoo. After several trial and errors, the VPN is up and running. I think it is better to leave a documentation of what I did.

The final outcomes I want to achieve are

  1. A gentoo linux with a public IP that runs VPN server. Its IP is 172.104.75.62
  2. Other clients, esp my android phone, can connect to the VPN server via L2TP/IPSec protocol.

There are two great articles that help me make it.

Unlike the Gentoo wiki, I do not use certificate files like *.ca or *.crt. I use psk.txt to do the auth job. It would keep the setup task simple.

Install necessary packages

    # emerge ipsec-tools xl2tpd pptpd

Setup ipsec-tools (racoon)

There are 3 configuration files for racoon. The first is /etc/racoon/psk.txt. It controls what information clients should provide, as shown below.

# Peer IP/FQDN  Secret
* be903514

Note that I specify the IP field as *, which means all clients use the same Secret.

The second configuration file is racoon.conf:

path pre_shared_key "/etc/racoon/psk.txt";

remote anonymous {
        exchange_mode main;
        my_identifier fqdn "172.104.75.62";
        passive on;
        generate_policy on;
        nat_traversal on;
        proposal_check obey;
        proposal {
                encryption_algorithm 3des;
                hash_algorithm sha1;
                authentication_method pre_shared_key;
                dh_group 2;
        }
}
sainfo anonymous {
        encryption_algorithm aes, 3des;
        authentication_algorithm hmac_sha1, hmac_md5;
        compression_algorithm deflate;
}

Finally, the 3rd configuration file for racoon is /etc/ipsec-tools.conf

flush;
spdflush;
spdadd 172.104.75.62[l2tp] 0.0.0.0/0 udp -P out ipsec
        esp/transport//require;
spdadd 0.0.0.0/0 172.104.75.62[l2tp] udp -P in ipsec
        esp/transport//require;

After setting up the three files, it's time to call racoon up:

# /etc/init.d/racoon start

Setup xl2tpd

x2ltpd has only one configuration file /etc/xl2tpd/xl2tpd.conf

[global]
port = 1701
access control = no
[lns default]
ip range = 192.168.0.1-192.168.0.20
local ip = 192.168.1.2
require authentication = yes
name = LinuxVPN
pppoptfile = /etc/ppp/options.xl2tpd

Note that pppoptfile variable refs to a file outside the /etc/xl2tpd directory. We need to create it later.

I also setup iptable rules as suggested in the Gentoo Wiki:

iptables -t filter -A INPUT -p udp -m policy --dir in --pol ipsec -m udp --dport l2tp -j ACCEPT
iptables -t filter -A INPUT -p udp -m udp --dport l2tp -j REJECT --reject-with icmp-port-unreachable
iptables -t filter -A OUTPUT -p udp -m policy --dir out --pol ipsec -m udp --sport l2tp -j ACCEPT
iptables -t filter -A OUTPUT -p udp -m udp --sport l2tp -j REJECT --reject-with icmp-port-unreachable 

Setup pptd

The first step is to edit /etc/ppp/chap-secrets. The following is my config:

# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
pptpuser  * I_am_client   *

Next create a file /etc/ppp/options.xl2tpd that matches the setting of /etc/xl2tpd/xl2tpd.conf

noccp
auth
crtscts
mtu 1410
mru 1410
nodefaultroute
lock
proxyarp
silent

OK. Now the xl2tpd and pptpd are ready to run.

# /etc/init.d/xl2tpd start
# /etc/init.d/pptpd start

Reap fruits

Now, check the android if it can connect to the VPN server. Tap Settings - More - VPN - Add VPN profile. The following window shows up, and I fill up only the Name, Type, Server IP, and pre-shared key. The IPSec pre-shared key is be903514 in my case (see /etc/racoon/psk.txt).

Save and profile and Tap it again to connect. I will open a dialog. Now, fill in the values that correspond to /etc/ppp/chap-secrets. In my case, Username is pptpuser and the password is I_am_client.

If all goes well, a "Connected" message would show in the android.