二月 26, 2009

Website backup task

我会在每个月最后一天备份网站,如果最后一天是周五或者周末,那么就在这一周的周四备份。由于记性不大好,所以需要有个提醒。之前一直用RTM,可惜我这个规则有点复杂,没法在RTM里面描述,导致经常要修改任务日期,有点麻烦。有时候稍不留神就错过了。

今天终于无法忍受,改用Org Mode了。方法就是使用一个超眩的任务日期,如下:

** DONE 备份网站
   SCHEDULED: <%%(wl-diary-website-backup-day)>

wl-diary-website-backup-day的实现如下:

(defun wl-diary-website-backup-day (&optional mark)
  (let* ((day (calendar-extract-day date))
         (month (calendar-extract-month date))
         (year (calendar-extract-year date))
         (lastday (calendar-last-day-of-month month year))
         (lastdayname (calendar-day-of-week (list month lastday year))))
    (and (or (and (= day lastday)
                  (memq lastdayname '(1 2 3 4)))
             (and (< (- lastday day) 7)
                  (memq lastdayname '(0 5 6))
                  (= (calendar-day-of-week date) 4)))
         (cons mark ""))))

二月 23, 2009

replace-regexp

在GNU Emacs里面,如果replace-regexp的替换字符串部分出现\,,并且后面接一个Emacs Lisp表达式,那么这个表达式的计算结果将作为替换字符串的一部分。比如将oddmuse格式的标题(=== 标题 ===)转换为Org Mode的标题(** 标题),可以使用

M-x replace-regexp RET \(=+?\) \(.+?\) =+ RET \,(make-string (1- (length \1)) ?*) \2 RET

注意其中长度减1。

二月 20, 2009

Who Uses Linux?

学习Who Uses Linux?,贴一下截止今天本站2月份的访问统计(基于Advanced Web Statistics 6.8 (build 1.910)),其中的Unknown OS参见最后一个表格,即无法找到OS部分的User Agent。

Operating Systems (Top 10)
Operating SystemsHitsPercent
Windows1135147.5 %
Unknown1019442.7 %
Linux21639 %
Macintosh1260.5 %
Unknown Unix system120 %
BSD60 %
Symbian OS10 %
Browsers (Top 10)
BrowsersGrabberHitsPercent
MS Internet ExplorerNo757031.7 %
MozillaNo693329 %
FirefoxNo478120 %
Unknown?259210.8 %
Subversion clientNo5692.3 %
OperaNo4892 %
SafariNo4782 %
NetscapeNo3881.6 %
KonquerorNo200 %
GreatNews (RSS Reader)No170 %
Others 160 %
Unknown OS (useragent field)
User agent (52)Last visit
Mozilla/3.0_(compatible;_Indy_Library)20 Feb 2009 - 02:11
Snarfer/1.0.2_(http://www.snarfware.com/)20 Feb 2009 - 01:44
freenews20 Feb 2009 - 01:09
QQFeedFetcher;_(_http://service.mail.qq.com/cgi-bin/help?id=40;_1_subscribers;_feed-id=87727)20 Feb 2009 - 01:02
RSS/1.0_(gzip)20 Feb 2009 - 00:49
Sphere_Scout&v4.0_-_scout_at_sphere_dot_com20 Feb 2009 - 00:27
dragonfly(ebingbong#playstarmusic.com)19 Feb 2009 - 23:57
AideRSS/1.0_(aiderss.com);_1_subscribers19 Feb 2009 - 23:42
QQFeedFetcher;_(_http://service.mail.qq.com/cgi-bin/help?id=40;_1_subscribers;_feed-id=2873998)19 Feb 2009 - 23:36
Fastladder_FeedFetcher/0.01_(http://fastladder.com/;_1_subscriber)19 Feb 2009 - 23:34
Mozilla/5.0_(compatible;__Page2RSS/0.5;__http://page2rss.com/)19 Feb 2009 - 21:28
Mozilla/5.0_(en-US)19 Feb 2009 - 21:02
Virtual_Reach_Newsclip_Collector19 Feb 2009 - 19:12
Mozilla/5.0_(compatible;_ScoutJet;__http://www.scoutjet.com/)19 Feb 2009 - 18:39
Mozilla/5.0_(compatible;_Charlotte/1.1;_http://www.searchme.com/support/)19 Feb 2009 - 10:15
Activeweave/BlogRovR/2009-02-15_10:23:00.0;_version_0.4.357;_2_subscribers.19 Feb 2009 - 09:50
SVN/1.5.4_(r33841)_neon/0.28.319 Feb 2009 - 05:59
Yanga_WorldSearch_Bot_v1.1/beta_(http://www.yanga.co.uk/)19 Feb 2009 - 04:40
Mozilla/5.0_(compatible;_TopBlogsInfo/1.0;__topblogsinfo@gmail.com)18 Feb 2009 - 17:51
GreatNews/1.017 Feb 2009 - 19:15
BlackBerry8320/4.5.0.42_Profile/MIDP-2.0_Configuration/CLDC-1.1_VendorID/14217 Feb 2009 - 18:47
Mozilla/5.0_(compatible;_Charlotte/1.0t;_http://www.searchme.com/support/)17 Feb 2009 - 17:42
Mugshot/Firehose_(http://developer.mugshot.org/wiki/FirehosePolling)16 Feb 2009 - 16:58
Mozilla/4.0_(compatible;)16 Feb 2009 - 07:30
LWP::Simple/5.81216 Feb 2009 - 07:29
Mozilla16 Feb 2009 - 06:57
MLBot_(www.metadatalabs.com/mlbot)15 Feb 2009 - 17:49
Mozilla/5.0_(compatible)15 Feb 2009 - 01:22
Activeweave/BlogRovR/2009-02-10_16:32:00.0;_version_0.4.355;_2_subscribers.14 Feb 2009 - 19:38
Mozilla/5.0_Firefox/3.0.513 Feb 2009 - 23:00
Mozilla/5.0_(compatible;_woriobot_support_[at]_worio_[dot]_com__http://worio.com)13 Feb 2009 - 11:40
Mozilla/5.0_(compatible;__Page2RSS/0.4;__http://page2rss.com/)13 Feb 2009 - 11:40
Mozilla/3.0_(compatible)13 Feb 2009 - 04:11
Internet_Explorer12 Feb 2009 - 22:49
AideRSS/1.0_(aiderss.com)12 Feb 2009 - 06:44
Mozilla/5.0_(compatible;_proximic;__http://www.proximic.com)11 Feb 2009 - 09:41
Wget/1.11.411 Feb 2009 - 00:39
Rome_Client_(http://tinyurl.com/64t5n)_Ver:_0.910 Feb 2009 - 21:57
SkyGrid/1.0_(_http://skygrid.com/partners)10 Feb 2009 - 21:39
Activeweave/BlogRovR/2009-02-09_11:12:00.0;_version_0.4.352;_2_subscribers.10 Feb 2009 - 16:47
BPImageWalker/2.0_(www.bdbrandprotect.com)10 Feb 2009 - 01:50
Mozilla/4.010 Feb 2009 - 00:17
FeedHub_MetaDataFetcher/1.0_(http://www.feedhub.com)08 Feb 2009 - 18:26
Activeweave/BlogRovR/2008-09-22_17:17:00.0;_version_0.4.350;_2_subscribers.07 Feb 2009 - 06:57
Mozilla/5.0_(compatible;_Twingly_Recon;_twingly.com)07 Feb 2009 - 02:36
Mozilla/5.0_(compatible;_Konqueror/4.2)_KHTML/4.2.0_(like_Gecko)05 Feb 2009 - 09:30
Mozilla/4.0_(compatible;_)05 Feb 2009 - 02:00
OPWV-SDK_UP.Browser/7.0.2.3.119_(GUI)_MMP/2.0_Push/PO04 Feb 2009 - 10:51
SVN/1.4.6_(r28521)_neon/0.28.303 Feb 2009 - 20:50
SVN/1.4.6_(r28521)_neon/0.27.203 Feb 2009 - 01:58
_DB_DB2_ODBC__support@runnk.com01 Feb 2009 - 21:40
Mozilla/4.0_(compatible)01 Feb 2009 - 00:25

ibus

最近在fedora 10上使用scim输入法总是出现问题,按空格选字或词的时候居然只输入了一个空格,十分苦恼,想起曾经听过ibus这个输入法,号称是新一代产品,于是装上试用,感觉不错。安装方法如下:

sudo yum -y install ibus ibus-m17n ibus-pinyin \
  ibus-table ibus-table-additional ibus-table-chinese

使用前必须选择输入法引擎,我只会用汉语拼音,其它的一概没选。ibus还提供了许多特殊命令,以便输入特殊字符,如输入摄氏度符号℃的命令是issd,ibus的特殊命令都是以i开头的,具体参见http://github.com/phuang/ibus-pinyin/blob/master/engine/special_table

二月 11, 2009

Find tags in a included tags file

etags-select首先列出所有候选的tag定义位置,然后由用户选择其中一个;而不像etags那样每次跳到其中一个定义,如果用户发现不是自己想要的结果,则继续往下跳。

etags-select有一个缺陷,不能处理included tags file,如Emacs Lisp的tags文件TAGS-LISP。不过,如果想弥补它也很容易,只需重定义其中一个函数即可。

(defun etags-select-get-tag-files ()
  "Get tag files."
  (if etags-select-use-xemacs-etags-p
      (buffer-tag-table-list)
    (mapcar 'tags-expand-table-name tags-table-list)
    (tags-table-check-computed-list)
    tags-table-computed-list))

二月 07, 2009

Auto complete

hippie-expand提供的补全功能帮了我不少忙,可是我个人不太偏好这种MS Dos方式的补全。auto-complete.el正合我意,它的作者用一段视频展示了auto complete提供怎样的功能。

我的配置如下:

(when (require-maybe 'auto-complete)
  (global-auto-complete-mode t)
  (define-key ac-complete-mode-map "\C-n" 'ac-next)
  (define-key ac-complete-mode-map "\C-p" 'ac-previous)
  (setq ac-auto-start 4)
  (add-hook 'emacs-lisp-mode-hook
            (lambda ()
              (make-local-variable 'ac-sources)
              (setq ac-sources '(ac-source-words-in-buffer ac-source-symbols))))

  (defvar ac-source-etags
    '((candidates
       . (lambda () (all-completions ac-target (tags-completion-table))))))
  (defun wl-add-ac-source-etags ()
    (make-local-variable 'ac-sources)
    (add-to-list 'ac-sources 'ac-source-etags))

  (add-hook 'c-mode-common-hook 'wl-add-ac-source-etags))