标签 ‘生活’ 的存档
在 Google Buzz 中隐藏某个来源的消息
Google Buzz 允许用户添加多个来源, 如自定义 RSS 馈送, flickr, 和 Twitter 等。 不少用户同步了自己的 Twitter 序列, 但这造成了大量重复的条目, 以及一些非 Twitter 用户的反感。 隐藏一个特定来源而不 unfollow 一位联系人, 一直是一个被期待的功能。 现在这个功能终於被实现了。

要隐藏一个特定来源, 在 Google Buzz 中单击 (直接单击) 一个联系人的名字, 以转到他/她的 Buzz 消息页面。 现在在每个来源後方都有一个 Mute/Unmute 按钮, 用於对一个来源静音或解除静音。
用 Makefile 记录编译次数
如果您喜欢不用 IDE 写代码, Makefile 可能是您无法避免的东西。然而用朴素的 make 自动记录编译次数, 实现起来可能需要一些技巧。
我所见到的大多数解决方案都依赖於专门的脚本, 这种方法既不优雅也不便於移植。这裡我将给出我的方法, 这个方法只依赖 echo 和 grep (当然, 还有 GNU make), 这些工具几乎在所有平台上都可以使用。
利用 make 计数的主要障碍在於它缺乏数值运算。尽管人们通常用数码表示数字, 但数字也可以利用反覆出现的同一个符号来编码——比如, 两个苹果携带了信息 ‘2’。
因此, 我们可以让 make 做它能做的最简单的事情——每次向一个文件中添加一个固定的符号——然後用 grep 来统计这个符号出现的次数, 也就是编译次数。
下面是一个完整的 Makefile, 供您尝试。它利用文件 .BuildCounter 来存储编译次数, 並向文件 BuildCount.inc 写入一行 BuildNumber = N;, 其中 N 为编译次数。
__COUNTER_FILE__ = .BuildCounter __COUNTER_INC_FILE__ = BuildCount.inc ifeq ($(wildcard $(__COUNTER_FILE__)),) $(shell echo > $(__COUNTER_FILE__)) endif $(shell echo $$ >> $(__COUNTER_FILE__)) $(shell echo BuildNumber = $(shell grep -c -F $$ $(__COUNTER_FILE__))\; > $(__COUNTER_INC_FILE__)) default: @more $(__COUNTER_INC_FILE__)
单击此处下载该文件。
Counting Build Number with Makefile
If you prefer writing code without an IDE, Makefile is something you probably can’t avoid. With plain make, however, automatic build number counting can be tricky to implement.
Most of the existing solutions (to my knowledge) rely on ad hoc scripts that are neither elegant nor portable. Here I’ll give my solution that relies solely on echo and grep (and, of course, GNU make), virtually available on all platforms.
The major obstacle to counting numbers with make is the absence of numerical operations. While a number is usually represented with a numeral, it can also be encoded with repeated usage of a constant symbol—for example, two apples carry the information ‘2-ness’.
Therefore, the idea is to make make do the simplest it can do—adding a symbol to a counter file each time—and use grep to count the number of appearance of that symbol, i.e. the build number.
Below is a complete Makefile for you to try out. It uses the file .BuildCounter to store the build number, and writes the string BuildNumber = N; to the file BuildCount.inc, where N is the build count.
__COUNTER_FILE__ = .BuildCounter __COUNTER_INC_FILE__ = BuildCount.inc ifeq ($(wildcard $(__COUNTER_FILE__)),) $(shell echo > $(__COUNTER_FILE__)) endif $(shell echo $$ >> $(__COUNTER_FILE__)) $(shell echo BuildNumber = $(shell grep -c -F $$ $(__COUNTER_FILE__))\; > $(__COUNTER_INC_FILE__)) default: @more $(__COUNTER_INC_FILE__)
Click here to download this file.


在 Twitter 上跟踪 Subacme





