0%

ssh to a remote server and run programs inside a terminal is not a big deal for major operating systems. However if the remote program requires graphics display, it will be a little bit tricky. macOS does have a powerful terminal that can automatically create an X window for the remote application. Windows could do that too, with some sort of hacking. Thanks to the great bash on windows, the effort to run remote X applications is now minimized. The detailed steps are shown below.

Read more »

拖了一个多月的时间,终于告别了《白色相簿2》的征程。完成终章雪菜线之后,整个剧情在 coda (最终章) 走向了总爆发。先前有传闻称,绝大多数玩家在初入 coda 时都会走入冬马NE(又称浮气线)的结局。我也按照 galgame 的传统,一周目不看攻略,完全凭个人喜好做出选择。我原本估计会进入冬马的某个结局,可最后一个选项让我大吃一惊:



我就这样莫名其妙迎来了雪菜TE的结局。可从先前的选择上看,好感度明明是显著偏向冬马和纱的。难道游戏设计出现了 bug? 等我又打完了冬马TE和冬马NE这两个结局,再将做出的选择一一比对,才深刻领悟了 coda 设计的精妙之处。

Read more »

Blue Screen of Death (BSoD) is a famous but annoying symbol of windows operating system. It indicates that there are some fatal errors such that the system can't work safely. General applications don't have the ability to trigger the blue screen, so there should be something wrong with either hardware or drivers, if windows itself is not corrupted. In whatever case, you need to take actions because the blue screen will appear from time to time if the root cause is not found and properly handled.

So how to investigate the root cause of a blue screen failure?

Read more »

《人类简史:从动物到上帝》是一本不同寻常的历史书。这本书中,我最欣赏的一点是,作者彻底放弃了一般历史学者的说教态度和马后炮的研究方法,承认历史的进程实际上受到诸多不确定性因素的影响,不存在什么“历史的必然”。我们常说要“以史为鉴”,就是要把握历史发展的一般规律,并以此来指导现在和未来的决策。不过,人类相信历史存在规律,并从历史事件中总结出一二三条,并不意味着历史有必然的一面,也不代表我们能看到事件发生的真正原因(想想学术界争论不休的各种观点),更不能说时过境迁,了解这些过去的故事对当下的情境能有怎样的帮助。就像今天没有人能断定希拉里或是川普一定可以当选美国总统,但等竞选结果公布之后,就会出现各种理论解释这一结果的成因。此外,在他们上任之前,我们也无从知晓美利坚是会变好还是变坏。研究历史规律,对这些最为实际的问题,往往是没有什么功用的。放弃了这种历史的功利心态,作者站在了超越人类的立场上,以极为宏大的视角描绘了人类数万年发展的基本脉络。这一点,足以让本书与众不同。

整个人类数万年的历史,想要在一本书里表露清楚,不得不选择性地忽略很多大事件,只去探讨能反映历史精髓的事情。在谋篇布局上,作者以三次重大飞跃为分界,以“认知革命”、“农业革命/人类的融合统一”和“科学革命”统领相关的篇章,乍看之下是相当合理的。但是,如果深入到每章节的内部,并仔细研读其中的文字,不难发现作者的行文存在诸多问题。

Read more »

新的改变

这是本博客改用 hexo 引擎和更换主题样式之后的第三次重大更新。现在整个站点 bitmingw.com 以及其引用的所有资源已经强制使用了 HTTPS 加密传输。即使用户最初使用不安全的 HTTP 协议,也会被 301 重定向为 HTTPS 协议。



文章的后续部分会详细讲解本站点 HTTPS 通讯的设计与实现,供各位博主参考。

Read more »

Dynamic programming (DP) is a group of very useful algorithms to solve searching problems. In many cases, it is easy to realize that a particular problem can be solved in DP, but you may spend a lot of time on finding the iterative equations. Distinct Subsequences is one such problem.

Here is the description from leetcode.

Given a string S and a string T, count the number of distinct subsequences of T in S.

A subsequence of a string is a new string which is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ACE" is a subsequence of "ABCDE" while "AEC" is not).

Here is an example:
S = "rabbbit", T = "rabbit"

Return 3.

Read more »

嗯,踏入二次元并不是我预先规划好的事情。我平时喜欢搜集各种音乐来听,其中也包括各类动漫的 OP (Open Song) 和 ED (Ending Song). 不经意间,youtube 推荐的一部 MV 深深吸引了我。这部 MV 的视频取材于《樱花庄的宠物女孩》,我就这样与这部动漫不期而遇了。

《樱花庄》并不算知名的神番,但如今细想起来,拿它来入宅真是合适不过。十多年前,我在电视里看过神作 EVA (《新世纪福音战士》), 但那时的我头脑中丝毫没有 ACG 的概念。上大学以来陆续看过少数几部动漫,印象比较深刻的也只有《秒速五厘米》了。很可惜《秒五》剧情太短,哭过就完了,没能让我一遍又一遍地回忆、反思,于是我又错失了一次入宅的机会。《樱花庄》并没有采用《秒五》的煽情策略,而是牢牢围绕一条主线展开:一群天才与凡人在樱花庄这个屋檐下生活。作为轻小说改编的作品,深入刻画人性并不是它的本意。那种有矛盾有尴尬,但又处处充满了爱与友善的气氛,才是动漫着重描写的。

Read more »

不同的人用微信找我聊天的方式是不太一样的。其中一些人喜欢先发一句 “在嘛?” 之类的问候语,等到我回复之后才给出后文。另一些人则是直接把想说的话甩过来。这其中的差别很有意思。为了简化,本文不讨论 “宝贝儿” 、 “你在干嘛?” 、 “想你” 这种开场白。

Read more »

The Concept

Partial function is a function partially complete. As a transformer, it is a way to create new functions from existing functions, meanwhile adding your own things. It can be named whatever you want, but I call it partial to keep consistency with the concept.

Here is a typical implementation of partial function.

1
2
3
4
5
6
7
8
def partial(method, name, **specified):
@functools.wraps(method)
def wrapper(self, *args, **kwargs):
final = dict(specified)
final.update(kwargs)
return getattr(self, method.__name__)(*args, **final)
wrapper.__name__ = name
return wrapper

It seems to be pretty complex. This article will help you understand this function.

Read more »

从今天起,本博客将放弃原主题 yilia, 转而使用新主题 NexT.

从 2014 年博客在 GitHub Pages 上线至今,除了框架从 Jekyll 变成了 hexo 之外,并没有经历过大规模的改版。这体现了我对 yilia 主题一贯的偏爱。2014 年的 yilia 更像是一个私人的藏品,在代码仓库里还夹杂了日语五十音这种私货。我有幸成为了这个主题的第二个开发者,规范了代码仓库的内容,还修复了部分 bug. 随着该项目的 star 数从几十增长到一千,越来越多的人加入到开发者的行列中,使它在两年的时间里不断完善。

然而 yilia 设计上的部分缺陷最终使我放弃了这个主题。

首先,这个主题最大的卖点在于其繁复的页面设计,移动端甚至使用了侧滑来展示导航内容。这种设计过于追求美感,却丧失了纯净的阅读体验。腾讯将侧滑菜单视为广告予以屏蔽的做法虽不恰当,但也足以说明这已经不是腾讯心目中博客文章该有的样子了。

其次,yilia 虽不断升级其外观设计,却并未充分挖掘 hexo 的潜力。归档页面没有重新设计,只是重复展现主页的内容,相当于放弃了这个功能。分类和标签都长成了标签的样子,而且大小完全一致,数目增多之后难以分辨。先前有其他开发者提出过相关问题,当前活跃的 pull request 多达三十余条,但作者本人并未积极处理这些问题。

最后,甚至连 yilia 最引以为豪的美感也出现了不可解决的缺陷。hexo 有一个 bug, 会导致编译后的 HTML 文件中的引号从 Markdown 中的直引号变成弯引号。由于 yilia 使用了微软雅黑作为显示字体,这个字体中的弯引号被视为中文引号,其字符宽度非常夸张,严重影响了英文的显示。因为这个 bug 不太可能得到修复,所以 yilia 主题就无法解决这个颜值上的致命伤。

经过再三评估和测试,我决定使用 NexT 这款人气更高也更为成熟的主题。该主题的页面极为简洁,符合沉浸式的阅读体验。时间轴和标签云的设计精湛,极大方便了读者的查阅。同时 NexT 提供了强大的插件支持,例如第三方全文检索,使得静态网页的能力完全不输 wordpress, 这也是它的一大亮点。

博客外观的改版结束了,但博客内容的更新会一直继续。

I believe most of you won't like to see the following question on your exam paper.

If you choose an answer to this question at random,
what is the probability that you will be correct?
A) 25%
B) 50%
C) 0%
D) 25%

This is actually a very hard question. To fully understand the question we need to make some assumptions and see what we can infer from them. Let's start from an "obvious" one.

Assumption 1: this question has a unique correct answer.

Read more »

有个朋友问了我三个关于编程的问题。因为无法用一两句话回答,所以我决定发到博客上,希望对大家有所启发。

这三个问题是:

  1. 你是不是把大家看美剧的时间都拿来编程了?
  2. 你是怎么对编程产生如此大兴趣的?
  3. 你如何培养对编程的兴趣?
Read more »

我相信现在同时喜欢读博客并且喜欢数学的人已经不多了。如果你恰好在这个圈子里面,你或许听说过 matrix67 这个人。他的博客 The Aha Moments 用简单易懂的语言讲述了许多有趣的数学问题。你或许不知,matrix67 还开发了一个叫 ideagen 的神秘板块,专门用来启发思维。这个 idea generator 的工作机制十分简单,每当你刷新页面的时候,它就会返回一个新的短语。只要稍加测试即可发现,这个东西返回的大部分结果都很无厘头,一小部分结果如果脑洞够大,还是有些意义的。这是我在五次测试中拿到的短语:

1
2
3
4
5
合意的老处女
香醇的牧师
惨痛的来路
美妙的卫生部
叫座的医学

这些短语有明显的共性,都是一个名词跟在一个形容词后面。无厘头的结果,加上固定的模式,不难使人想到这些短语不是直接采集自语料库,而是由语料库中的形容词和名词随机拼接而成的。为了验证这个猜想,我设计了如下的实验。

Read more »

毫无疑问,这是有史以来最为紧凑和充实的一个学期。整个学期以三月十日为界,可以分成两段。第一段在玩命地找工作,第二段在玩命地写作业和做项目,把第一段欠下的债还回来。

Read more »

Today when I want to copy a project from my Linux machine to Windows, I get a very unusual error.

1
2
cp: cannot create regular file ‘Share/bookrepo/target/guestbook-java-1.0-SNAPSHOT/js/aux.js’: Operation not permitted
cp: cannot create regular file ‘Share/bookrepo/src/main/webapp/js/aux.js’: Operation not permitted

It says that we can't copy a file named aux.js to the destination. However the file has exactly the same permission as others, so why it is handled separately? After googling for a while I get the astonishing answer: AUX, with all possible extensions, are invalid file names in Windows! WAT??

According to the MSDN documentation, the following names are reserved and could not be used to name a file.

  • CON
  • PRN
  • AUX
  • NUL
  • COM[1-9]
  • LPT[1-9]

Since file names are case insensitive in Windows, aux.js accidentally fails into the range, and thus cause the error. I would say it is a terrible design because no one knows that before he/she encounters the problem!

Here is an article talking about the history behind those invalid files names. It is hard to believe that the idea can be traced back to 1973 CM/P OS, even before the DOS. All the new things build on it, including DOS, Windows NT, and .NET, are suffering the same problem just for COMPATIBILITY!

Programmers are warned by the following statement: never modify a container itself while using an iterator that goes through it. It makes sense because it is usually hard to track what is going on. Even worse, different programming languages have different implementation on iterators, so the same logic may not work everywhere.

In this article I will demonstrate how Python iterator works by exploiting it, namely modify the container while accessing elements.

Read more »

近日深感有个命题是合理的:追求精致生活的人普遍没有深邃的思想。翻译成更浅显的文字,就是说你看到的生活过得精致幸福之人,很可能是思想上的 low 逼。

Read more »

有些故事,从开头看不到结局,只是可以猜测中间会有怎样的剧情。正是这结果的不确定性,让整个过程变得如此令人着迷、痴狂。

来亚村整整四个月了,这四个月的经历可谓非同寻常。我本想每日连载,留下每一天的欣喜、感动、焦虑和自责。可因为种种原因,我丢掉了写日记的习惯,任由时光的身影一点点模糊,直到消失不见。不过学期回顾的传统是不能丢掉的,于是就有了这一篇。

Read more »

There is a very interesting question: what is the value of $i^i$, where $i$ is the unit imaginary number?

The answer is more interesting: $i^i = 0.2078795763507619...$. It is a REAL NUMBER!

How could we derive it?

First you need to know Euler's formula. Which states

$$
e^{ix} = cos(x) + i*sin(x)
$$

To construct the $i$ is really simple, just set $x = \pi/2$, we have

$$
e^{i*\pi/2} = i
$$

Now comes to the magic part. Raise both sides to power of $i$. The right side is $i^i$. The left side is now

$$
e^{i*i*\pi/2} = e^{-\pi/2} = 0.2078795763507619...
$$

However, this is not the end of the story. Notice $i$ has infinity amount of forms:

$$
e^{i*(2\pi n+\pi/2)} = i, n \in \mathbf{Z}
$$

As a result, $i^i$ has infinity different values:

$$
e^{-2\pi n-\pi/2}, n \in \mathbf{Z}
$$

So $i^i$ is not a number. It represents a set of numbers. And, I can't believe the crazy world any more!

References

Email 是一个伟大的发明。但多数人不知道,网络上的 email, 与其说是邮件,倒不如说是明信片:任何一个参与投递的节点,都可以阅览其中的内容。他们不仅可以搜集信息,还能伪造你的身份,做不法的勾当。想要安全地投递邮件,就要把明信片装进信封里,贴上自己的防伪标签。这样邮件的内容就无法被第三方获知,第三方也不能以你的身份发邮件了。

工具

为了完成加密这件事,咱们需要一整套软件的支持。在 windows 系统上,推荐的工具链是 gpg + thunderbird + enigmail.

  • GPG 是 "GNU Privacy Guard" 的缩写,用于数据和通讯的加密。我们使用 gpg4win 软件包实现 GPG 的功能。
  • Thunderbird 是一款老牌邮件客户端。它的插件 enigmail 帮助我们轻松实现邮件的加密、验证和解密过程。
Read more »