November 29th, 2008linux command – xargs

xargs 是用来从标准输入把行中的内容作为某个命令的参数, 并把执行结果输出,
from man:

  xargs - build and execute command lines from standard input<br />

我们在两台机器上同时运行同一个程序,这两台机器的环境应该是一样的, 但我们发发现在其中的一台机器上由于缺少一些运行时库而导致程序无法运行。我们已经在可以运行 的那台机器上得到了一个这个程序所依赖的所有库文件的列表(放在 depends.txt中, 每个文件名占一行),  问题是怎么找出有哪些库丢失了呢?
当然, 你可能会想到, 那直接一个一个的把这些文件在有问题的机器上找一下, 如果没有就表示丢失了呗, 当然这是正确的做法, 不过当文件数量过多的时候, 手工做显然是一个十分烦人的工作, 于是我们的xargs就派上用场了,
cat depends.txt | xargs ls -l | grep “No such file or directory”
首先看命令的前半部分, cat depends.txt | xargs ls -l , 这部分是把depends.txt中的内容作为输出到xargs ls -l 中, 而xargs做的事情就是把文件中的内容当作它的参数’ls -l” 的参数, 并执行ls -l 这个命令,
假如depends.txt 中有以下内容:

/usr/lib/a.so
/usr/lib/b.so

经过xargs处理后的命令行大致如下
ls -l /usr/lib/a.so
ls -l /usr/lib/b.so

我们知道ls遇到一个不存在的文件会输出file not found, 于是咱们再grep 一把, 就把这些不存在的文件找出来了:)
这是今天学到的命令, 现学现卖~~~

November 19th, 2008状态更新

最重要的是平花水平有了一些提高:D

昨天练习的时候终于初步会了”玛丽”这个动作, 想当初(一年前)看到这个动作的时候, 惊为天人, 想不到一年后俺也会一点点了, 哈哈.

下面是这个动作的动画版, 请欣赏:)
图片-动作
另外练平花的时候认识了一些朋友, 不算太熟, 但还可以说几句话.

再另外, 上次卖我鞋的那个卖家还很厚道, 又送了我一对防磨皮和一个旋三模型, 不错:D

November 16th, 2008Biz Markie-Just A Friend

听了很久以后, 才发现这首歌也很不错:) 这类风格的没有听过太多, 不过这首应该算是精品了吧.

从wiki上看到, 这首歌1989年出品, 是Biz Markie唯一的一首成功的单曲, 在Billboard (什么东西?)的排行榜上名列第9.

 

歌词:

Have you ever met a girl that you tried to date
But a year to make love she wanted you to wait
Let me tell ya a story of my situation
I was talkin to this girl from the u.s. nation
The way that I met her was on tour at a concert
She had long hair and a short miniskirt
I just got onstage drippin, pourin with sweat
I was walkin through the crowd and gues who I met
I whispered in her ear, come to the picture booth
So I can ask you some questions to see if you are a hundred proof
I asked her her name, she said blah-blah-blah
She had 9/10 pants and a very big bra
I took a couple of flicks and she was enthused
I said, how do you like the show?
She said, I was very amused
I started throwin bass, she started throwin back mid-range
But when I sprung the question, she acted kind of strange
Then when I asked, do ya have a man, she tried to pretend
She said, no I dont, I only have a friend
Come on, Im not even goin for it
This is what Im goin sing
You, you got what I need but you say hes just a friend
And you say hes just a friend, oh baby
You, you got what I need but you say hes just a friend
But you say hes just a friend, oh baby
You, you got what I need but you say hes just a friend
But you say hes just a friend
So I took blah-blahs word for it at this time
I thought just havin a friend couldnt be no crime
cause I have friends and thats a fact
Like agnes, agatha, germaine, and jacq
Forget about that, lets go into the story
About a girl named blah-blah-blah that adored me
So we started talkin, getttin familiar
Spendin a lot of time so we can build up
A relationship or some undderstanding
How its gonna be in the future we was plannin
Everything sounded so dandy and sweet
I had no idea I was in for a treat
After this was established, everything was cool
The tour was over and she went back to school
I called every day to see how she was doin
Everytime that I ccalled her it seemed somethin was brewin
I called her on my dime, picked up, and then I called again
I said, yo, who was that? oh, hes just a friend
Dont gimme that, dont ever gimme that
Jus bust this
You, you got what I need but you say hes just a friend
And you say hes just a friend, oh baby
You, you got what I need but you say hes just a friend
But you say hes just a friend, oh baby
You, you got what I need but you say hes just a friend
But you say hes just a friend
So I came to her college on a surprise visit
To see my girl that was so exquisite
It was a school day, I knew she was there
The first semester of the school year
I went to a gate to ask where was her dorm
This guy made me fill out a visitors form
He told me where it was and I as on my way
To see my baby doll, I was happy to say
I arrrived in front of the dormitory
Yo, could you tell me where is door three?
They showed me where it was for the moment
I didnt know I was in for such an event
So I came to her room and opened the door
Oh, snap! guess what I saw?
A fella tongue-kissin my girl in the mouth,
I was so in shock my heart went down south
So please listen to the message that I say
Dont ever talk to a girl who says she just has a friend

November 9th, 2008感觉

前几日一次晚上在滑冰中不慎摔倒, 整个人便成坐在了地上, 于是便干脆摔的更彻底些 — 呈大字状摊在地面上,  正好那个时候看到了天空, 天气不算晴朗, 看到的是雾色蒙蒙的天空, 天上没有东西, 看不到星星, 偶尔看到空中有一两个发光的物体, 就在那个时候忽然有种很特别的感觉, 一种自己要溶入这一切, 灵识似乎清析了起来, 这似乎是一种发自灵魂深处的神圣感觉, 那无限的苍穹, 虽然有雾色遮住了我的视线, 但我似乎还能感到这雾云之后的浩大, 这产生的巨大美感似乎是前所未有的, 我的心灵似乎在刹那被这感觉所震撼, 可正当我正要想该用什么语言描述这美妙的感觉的时候, 它忽然消失了, 仅持续了极短的时间, 当我试图再次找回它来 –再次平躺在地面上, 只是这没有结果 — 只能一次次地感觉到冰冷的地面.

似乎在很久以前常有有此种感觉, 只是现在很少再有了.

November 8th, 2008对话

今天晚上去科技馆滑冰, 穿着冰鞋到地下的某德基去吃饭, 正吃着的时候遇到一个可爱小弟弟和我搭讪(五六岁的小孩). 下面就是我们的对话.

小孩: 你的鞋也是从教练那买的吗?

抬头发现斜对面坐着一个小朋友的我: 不是啊. (幸好在科技馆混的有段时间, 知道教练是那个教小孩子们滑冰的轮滑店老板)

小孩: 哦, 我的鞋就是从教练那买的, 很多人都是在教练那买的

我: 你也滑冰吗? (废话, 人家都买鞋了)

小孩: 嗯, blabla…. 从北京到上海….. blabla, (距离稍远, 没听明白他白活些啥)

我(装作听懂的样子, 很认真的): 哦!

小孩: 有的人都把鞋子丢了.

我: 啊? 是吗?!

小孩: 嗯, 那个郭XX就把鞋子丢了, 他不喜欢滑冰

我: 啊.

小孩: 我大名叫黄xx, 小名叫宝宝, 你可以叫我黄XX, 也可以叫我的小名宝宝.

我: ……..

黄xx: 我妈妈都叫我的小名宝宝

当我正在准备说话的时候, 小朋友就被他妈叫回去了….. 

October 18th, 2008emacs muse mode – issues

muse是emacs中emacs-wiki mode的继任者, 兼容原来wiki的所有操作, 当然也有不少改进, 照wiki里讲它的优点, 大致有以下几点(直接从原文翻译过来的):

    • 可以处理不同的输出格式
    • 相对于EmacsWikiMode来讲hack它更容易, 代码的组织结构更加nice
    • 更加容易的从一个已有的样式派生出自己特定的发布样式
    • Muse中有一个大副改进的日志模式(支持输出Rss1.0(Rdf)/Rss2.0)

讲了这么多废话, 其实是因为这两天比较枯燥无聊的时候, 自己在瞎折腾Emacs, 所以找到了这么个东西准备用了当记事本用, 不过配置的时候发现了几个问题, 现在解决了, 写下来, 估计一定会有人和我遇到相同的问题!

问题一: 在Muse的QuickStart Tutorial中的源代码那一小节讲到插入源代码然后再发布出的文件里的代码就是高亮的, 可是我在刚开始试的时候是没有成功的: 发布出的代码是没有任何处理的. 经过调查后发现这个功能是需要htmlize.el 扩展的支持的, htmlize.el是被包含在XEmacs发布的, 所以使用XEmacs的兄弟们不会遇到这个问题, 估计写这个QuckStart的哥们用的就是XEmacs, 而htmlize.el默认是不在Emacs中的, 所以就需要自己手动下载这个文件并放到你的加载路径里喽.

问题二: 如何直接在edit模式就可以看到高亮的代码, 刚才讲到Muse发布时是支持高亮其中的代码的, 但是默认情况下是不支持在编辑状态就高亮代码的, 效果应该和下面的差不多

syntax-hilighting

找了半天总算从这里(作者: 叶文彬)找到了一个比较好看的实现(没办法, 谁让咱是不会写lisp的菜鸟呢!~~~~~), 作者的配置文件里有支持代码高亮的一些自定义函数, 就是从(defun muse-colors-src-tag (beg end) 到(add-to-list ‘muse-colors-tags ‘("src" t nil nil muse-colors-src-tag)) 这一段, 有了这些就可以让你的Muse支持高亮了. 另外建议也把htmlize-region-for-paste这个函数放到你的配置文件里, 有了这个函数, 就会把生成的代码的样式使用css样式而不是直接使用html的颜色标记指定, 当然你需要有一个css文件里包含了所需要的样式, 你要是不知道的话也参考这位作者定义的! 他的CSS样式文件在这里可以找到.

基本上为了支持代码高亮我从作者那抄了如下代码, 版权归原作者所有, 我只是引用一下下:

(defun htmlize-region-for-paste (beg end)
  "Htmlize the region and return just the HTML as a string.
This forces the `inline-css’ style and only returns the HTML body,
but without the BODY tag.  This should make it useful for inserting
the text to another HTML buffer."
  (let ((htmlbuf (htmlize-region beg end)))
    (unwind-protect
        (with-current-buffer htmlbuf
          (buffer-substring (plist-get htmlize-buffer-places ‘content-start)
                            (plist-get htmlize-buffer-places ‘content-end)))
      (kill-buffer htmlbuf))))
;;}}}

;(defvar muse-colors-overlays nil)
(defun muse-colors-src-tag (beg end)
  "Strip properties and mark as literal."
  (let (face)
    (muse-unhighlight-region beg end)
    (save-excursion
      (goto-char beg)
      (let ((fs 1) content face-list fe mode attrs number ov ovs
            (font-lock-verbose nil))
        (when (re-search-forward "<src\\(.*\\)>" nil t)
          (setq beg (match-end 0)
                attrs (mapcar
                       (lambda (pair)
                         (setq pair (split-string pair "="))
                         (setcdr pair (substring (cadr pair) 1 -1))
                         pair)
                       (split-string (match-string 1)))
                mode (and (assoc "lang" attrs)
                          (intern-soft (concat (cdr (assoc "lang" attrs))
                                               "-mode"))))
          (when (and mode (fboundp mode))
            (goto-char end)
            (setq end
                  (if (re-search-backward "</src>" nil t)
                      (match-beginning 0)
                    (point-max))
                  content (buffer-substring-no-properties beg end))
            (with-current-buffer (get-buffer-create "*muse-temp*")
              (funcall mode)
              (insert content)
              (font-lock-fontify-buffer)
              (htmlize-ensure-fontified)
              (or (get-text-property fs ‘face)
                  (setq fs (next-single-property-change fs ‘face)))
              (while (and fs (< fs (point-max)))
                (setq fe (or (next-single-property-change fs ‘face)
                             (point-max))
                      face (get-text-property fs ‘face))
                (and face fe (setq face-list (cons (list (1- fs) (1- fe) face) face-list)))
                (setq fs fe))
              (kill-buffer (current-buffer)))
            (when face-list
              ;; (message "%S" face-list)
              (dolist (f (nreverse face-list))
                (put-text-property (+ beg (car f)) (+ beg (cadr f))
                                   ‘face (nth 2 f)))))
          (when (and (assoc "number" attrs)
                     (setq number (string-to-number (cdr (assoc "number" attrs)))))
            (mapc (lambda (o)
                    (let ((pos (overlay-start o)))
                      (if (or (null pos)
                              (and (> pos beg) (< pos end)))
                          (delete-overlay o)
                        (push o ovs))))
                  muse-colors-overlays)
            (setq muse-colors-overlays ovs)
            (goto-char beg)
            (forward-line 1)
            (while (and (not (eobp)) (< (point) end))
              (when (not (looking-at "</src>"))
                (setq ov (make-overlay (point) (point)))
                (push ov muse-colors-overlays)
                (overlay-put ov ‘before-string (format "%4d " number))
                (setq number (1+ number)))
              (forward-line 1))))))))
(add-to-list ‘muse-colors-tags ‘("src" t nil nil muse-colors-src-tag))

基本在搞Muse的时候就遇到这两个比较麻烦的问题, Over:)


© 2007 pangwa's Blog | iKon Wordpress Theme by Windows Vista Administration | Powered by Wordpress