九月 30, 2009

Think about backup again

最近发生的两件事情让我再次思考如何备份自己的数据,一个是同事的IBM T42相继报废,另外就是访问国外网站越来越困难了。目前我的备份方式很原始,手工备份,外加几个使用rsync的脚本,自动化程度较低。公司里的数据肯定不能备份到外网,自己也有电子书、片子和音乐什么的,不方便放出来,所以需要一个可以自己搭建的备份方案。

我的私人网络数据备份做得不错,基本都有备份,除了Google Docs里的文档。

九月 21, 2009

Git remote pushurl

从git 1.6.4起,有了一个新的控制选项——remote.$name.pushurl,官方解释如下:

"git push $name" honors remote.$name.pushurl if present before using remote.$name.url. In other words, the URL used for fetching and pushing can be different.

也就是说,你可以有一个url用来取,一个url用来提交,下面是一个配置的例子

[remote "gitweb"]
        pushurl = ssh://me@example.com/gitrepo/mypj.git
        url = git://example.com/mypj.git
        fetch = +refs/heads/*:refs/remotes/gitweb/*

九月 14, 2009

Photo helps remember

曾经读过一个人讲述自己使用evernote的方式,他在停好车之后拍一张照片,然后上传到evernote上,以免忘记自己停车的位置。当时觉得有点小题大做,这种临时的事情就不用上传了吧。

最近突然想不起自己的房租转账收据放到哪里去了,顿时一头汗啊。决定以后对于重要的物品或者长时间不用的物品,把存放位置拍下来,存到evernote,分门别类。

九月 11, 2009

Wrap git log output

缺省情况下,git log的输出并不会把长字符串换行,如果有人写提交信息的时候没有换行,那么超出终端宽度的部分就无法看到,解决方法是把core.pager设置为

less -+$LESS -FRX

详细解释参见git config手册中关于core.pager的部分。

这也是我在identi.ca上发的第一个消息

九月 07, 2009

Turn on c++-mode for h files

C/C++都使用h作为头文件后缀名,使得无法简单地在Emacs里面指定major-mode。使用magic-mode-alist可以减轻一点烦恼。以v8项目为例:

(add-to-list 'magic-mode-alist
             '("// .* the v8 project" . c++-mode))

Emacs在打开文件时如果匹配到相应的正则表达式,就会使用c++-mode

九月 02, 2009

Send org status change to identica

microblog的一个功能算告诉世界What are you doing?以下一段代码把正在计时的任务和刚刚完成的任务记录在identi.ca或者任何自己建立的laconi.ca上。

(defun wl-org-clock-in-update ()
  (let ((current-heading (org-get-heading t))
        (tags (org-get-tags-at)))
    (when (member "@office" tags)
      (with-current-buffer identica-buffer
        (identica-update-status-if-not-blank "statuses" "update"
                                             current-heading)))))

(add-hook 'org-clock-in-hook 'wl-org-clock-in-update)

(defun wl-org-todo-state-change-update ()
  (let ((current-heading (org-get-heading t))
        (tags (org-get-tags-at)))
    (when (and (member "@office" tags)
               (string-match "^\(DONE\|CANCELED\|GOT\) " current-heading))
      (with-current-buffer identica-buffer
        (identica-update-status-if-not-blank "statuses" "update"
                                             (concat "#" current-heading))))))

(add-hook 'org-after-todo-state-change-hook 'wl-org-todo-state-change-update)

我在公司的机器上装了laconica,所以只在上面记录跟工作相关的内容,其中(member "@office" tags)保证只发送含有@office标签的任务。