我的微博自选集 (2011)

2011年那一年,我正带领一个小团队在点击科技开发 Lava微博。那也是我玩微博很疯狂的一年。那一年结束的时候,我有了一个想法,要把一年零散写下的微博里,把值得留存的部分集中起来,发表到当时支持长微博的 Lava微博。这个保存工作至少花了我数个小时,但它是值得的。看,这里保存着十年前的我。

2011年3月


"明哲保身", "事不关己,高高挂起", "各人自扫门前雪,谁管他人瓦上霜" 这些思想害了中国5000年, 到今天仍然有很大的市场. 请大家记住, 只求自保, 一定保不住自己. 普及公民教育, 唤醒公民意识, 刻不容缓. 3月1日13:23 来自新浪微博

据说: 很多人梦想和目标不能实现的原因有两个:晚上下不了网, 早晨起不了床。 3月2日13:59 来自新浪微博

葛剑雄教授:知识分子多少有点知识,这是他们的幸运,也是他们的不幸。有了知识,就想有运用的机会,就不会满足于有饭吃,有衣穿,有妻子儿女,这就是所谓实现自身价值。在皇权垄断一切的社会里,要实现自身价值,舍做官就别无他途。可是做了官就只能服从法律和上司,就绝对避不开现实政治。疾恶如仇会有党人那样的下场,洁身自好或许能做到,却因此而一事无成,同流合污又有违初衷,而不齿于士林,急流勇退倒也干脆,但原来的理想也随之成为泡影。 3月4日19:42 来自S60客户端

顾准语录:要像小孩捡石子一样为自己收集知识财富。一个人在任何时候都要为自己寻找一个目标,即使明知道这个目标是自欺欺人的,也要向着这个目标奋斗,否则你的生活就没有中心。 3月5日11:02 来自S60客户端

…more

A simple nfs server on centos

At the server end

choose a server as the nfs-server, do things below in root role

dnf -y install nfs-utils
mkdir /mnt/nfs-share
chown -R nobody /mnt/nfs-share/

vim /etc/exports
add a line
/mnt/nfs-share 192.168.178.0/255.255.255.0(rw,sync,all_squash)
save and exit

systemctl enable nfs-server
systemctl start nfs-server

At the client end

dnf -y install nfs-utils
mkdir /mnt/nfs-local
chown -R nobody /mnt/nfs-local/

vim /etc/hosts
add a line, replace 192.168.xxx.yyy to the IP addr of your NFS server
nfs-server 192.168.xxx.yyy 

vim /etc/fstab
add a line
nfs-server:/mnt/nfs-share  /mnt/nfs-local   nfs defaults   0 0
save and exit
 
mount -a # to confirm what you have done is right

other utils:

You could use showmount -e 192.168.xxx.yyy to get a share list from the nfs server.

Don't simple unset them afterward when using `shopt` change a setting

Sometimes we need to run shopt -s dotglob nullglob before moving files including dotfiles. So there's another question, do we need to set it back afterward? The most correct answer is

It's usually not clear if either dotglob or nullglob were already set before running shopt -s to set them. Thus, blindly un-setting them may not be the proper reset to do. Setting them in a subshell would leave the current shell's settings unchanged:

( shopt -s dotglob nullglob; mv /public/* /public_html/ )

Reference: Jeff Schaller's answer under this question

神奇且无害的REBASE

2014年底翻译了这篇文章,当时发表在GotGit 群组,搬过来留存一下

作者:Jeff Kreeftmeijer 发表于 2010-10-11 原文链接

大约一个月前, 以Git为主题我写了不少文章,始于@nvie 出色的git开发流程教你写出更好的提交注释,终结于强大的reflog和惊人强大的bisect 。你猜怎么着?我竟然忘记了介绍神奇的rebase

人们通常认为rebase是一种压合提交工具,但这并非它的看家本领。顾名思义,它的本职工作是变基(改变我们所做变更的基础)。

哦,忘掉那篇吓唬人的文章,只要清楚自己在做什么,根本不会产生什么恶果。

假设你正工作在一个名叫feature/login的新功能分支上,某个家伙实现了某样东西,并把他的代码push到了develop分支上。你需要那个东西,该怎么做?

可以把develop分支合并到你正在工作的分支,这会产生一些....乱七八糟的合并提交,不好。

也可以把我们需要的那个提交cherry-pick过来。不过经验表明虽然不是什么大问题,从一堆提交里找出需要拣选的提交,终究是个麻烦事。

Git的rebase指令允许我们先回退自己的改动(类似“倒带”),拉回另一个分支的所有变动之后(变基),在新的基础(HEAD)上“重放”我们的变更:

$ git rebase develop

First, rewinding head to replay your work on top of it...
Fast-forwarded feature/login to develop.

仿佛在拉回那些变更之前,我们什么也没做(我们所有的改动仿佛发生那些变更之后)。这非常好,是不是?我们还能在pull的同时变基(使用--rebase选项),这样的话我们甚至都不需要离开自己的工作分支。

##更小块的冲突

rebase让我们拥有干净的提交历史,即便在rebase的过程中发生冲突,它也是我们解决冲突的坚强后盾:

$ git rebase develop

First, rewinding head to replay your work on top of it...
Applying: feature/login
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging config/environment.rb
CONFLICT (content): Merge conflict in config/environment.rb
Failed to merge in the changes.
Patch failed at 0001 feature/login

When you have resolved this problem run "git rebase continue".
If you would prefer to skip this patch, instead run "git rebase
skip".
To restore the original branch and stop rebasing run "git rebase --abort".

由于rebase顺序重放每一个提交,冲突会以更小的块(更多的次数)出现,这有助于我们迅速理解冲突原因,更快地解决冲突。在解决冲突之后,只需git add冲突文件,然后输入下面的命令继续rebase过程:

$ git rebase --continue

##rebase 还是 merge

当我们工作于一个功能分支,发现需要 develop 分支上的所有变更时,我建议使用rebase。当我们的功能分支已经开发完成,应该使用 merge 把功能分支合并回 develop分支。这样我们能够记录下我们在何时把分支合并到 develop 主干,就是利用那个...我们前面说过的“乱七八糟”的提交。在这个时候,它真的不是乱七八糟的提交,确实不是。

在合并功能分支之前,我希望你使用rebase。这样我们方能保证自己的分支在合到并主干时仍然拥有干净的提交历史。

你用过rebase吗?你在何时使用 rebase 不用 merge?还是只用 rebase?你还害怕rebase吗?欢迎撰写评论留下你的想法,让我知道。

PS: 这篇文章虽然写于2010年,但写的清晰明快。我今天(2014年)把它翻译过来,希望能帮助到更多的人。rebase是一个很好的工具,只要你愿意了解它。

Tuple type in C#

It's a rather interesting feature. I first use it the same way as the python tuple type. I immediately found I was wrong. It doesn't support using an index to visit certain element

Stupid enough. I think. Soon I found the correct way, you know, the Item1, Item2 way.

It's so Stupid! Then I found the best way: the named element way.

Task<(List<string> orderIdList, List<string> orderNoList)> GetExpiringOrderIdListAndOrderNoList(DateTime checkTime);

Ok. It's not very stupid.