Cao Yi

藏在著名软件系统中的两个彩蛋

Index

1. Fancy Message from sudo

这个彩蛋应该在RedHat系列的Linux中都有的,但我只有CentOS上的经验。据说在openSUSE中也有这段有趣的话。

当你第一次使用sudo时,系统会显示三句劝喻:

  1. Respect the privacy of others. 尊重他人隐私。
  2. Think before you type. 三思而后行。
  3. With great power comes great responsibility. 权力越大,责任越大。
$ sudo su - tomcat

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for caoyi:
Last login: Wed Feb  3 20:01:34 EST 2021 on pts/0

官方的中文版是

我们信任您已经从系统管理员那里了解了日常注意事项。
总结起来无外乎这三点:

    #1) 尊重别人的隐私。
    #2) 输入前要先考虑(后果和风险)。
    #3) 权力越大,责任越大。

2. Zen of Python

打开Python的控制台,输入import this可以看到所谓的Python之禅(The Zen of Python)

  1. Beautiful is better than ugly. 优美优于丑陋
  2. Explicit is better than implicit. 明瞭优于隐晦
  3. Simple is better than complex. 简单优于复杂
  4. Complex is better than complicated. 复杂优于凌乱
  5. Flat is better than nested. 扁平优于嵌套
  6. Sparse is better than dense. 稀疏优于稠密
  7. Readability counts. 可读性很重要
  8. Special cases aren’t special enough to break the rules.
  9. Although practicality beats purity. 即使实用比纯粹更优, 特例亦不可违背原则。
  10. Errors should never pass silently.
  11. Unless explicitly silenced. 错误绝不能悄悄忽略,除非它明确需要如此。
  12. In the face of ambiguity, refuse the temptation to guess. 面对不确定性,拒绝妄加猜测。
  13. There should be one– and preferably only one –obvious way to do it. 任何问题应有一种,且最好只有一种,显而易见的解决方法。
  14. Although that way may not be obvious at first unless you’re Dutch. 尽管这方法一开始并非如此直观,除非你是荷兰人。
  15. Now is better than never. 做优于不做
  16. Although never is often better than right now. 然而不假思索还不如不做。
  17. If the implementation is hard to explain, it’s a bad idea. 很难解释的,必然是坏方法。
  18. If the implementation is easy to explain, it may be a good idea. 很好解释的,可能是好方法。
  19. Namespaces are one honking great idea – let’s do more of those! 命名空间是个绝妙的主意,我们应好好利用它。
C:\Users\iridi>py
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!