Solaris nfs exporting

1. Prepare dir for sharing, (assume "ws" for group member, "tmp" for everyone):

cd /export/home
mkdir ws tmp
chown matt:staff ws
chown root:root tmp
chmod 750 ws
chmod 777 tmp
chmod +t tmp

2. edit /etc/dfs/dfstab, append:

share -F nfs -o rw -d "workspace" /export/home/ws
share -F nfs -o rw -d "tmp" /export/home/tmp

3. use command shareall and unshareall to share/unshare all resources mentioned in /etc/dfs/dfstab, use command share to show current sharing resources

Word 排版要略

小论文写完了,总算觉得轻松点了,前一阵子阅读侯捷的《word排版艺术》所得精要,再加上这段时间的实践,word 排版步骤总结如下:

1. 页面设置
重点是设置节的起始位置,一般定为奇数页,另外编辑过程中随时可以插入分节符,分节可实现多重页码编排。在这里可以设置页眉页脚奇偶页不同

2. 修改样式
各种字体、段落、颜色等样式都在这里设置,如标题一、标题二字体、段间距,脚注引用颜色,等等,只改本文档,不要动 normal.dot。编辑中要改动所有正文的字号,也只要改样式中的正文设置

3. 项目符号
选择一种多级编号的样式,这里可实现章节自动编号

4. 脚注、尾注、题注
这些东西可自动编号,题注实现图、表的自动编号

5. 目录
按标题一、标题二等等样式安排文章,目录很容易生成。更新目录可在目录区右键选"更新域"

6. 参考文献
作为尾注是不合适的,因为尾注无法分栏,而且要得到 [1] 这样的格式需要手工修改,另外一个文献可能多处引用到。我的做法是使用书签加交叉引用,但这样中途插入其他文献时又不能自动编号,写的时候想清楚吧。

7. 域
域是高级用法,StyleRef 可能用到较多,其它可参考 office online hlep

8. 记住术语
记住常用术语和大致步骤,细节不记得了问 Google

9. 几个Tip

删除尾注分隔符
第一步:"视图"/"普通":进入普通视图
第二步:"视图"/"脚注"(或尾注):窗口下方会显示出脚注的窗格
第三步:从脚注窗格的下拉框中选"脚注分隔符",将那条你痛恨的线删除就可以了

减肥:
vsd 和 图片都转成 png,文件大小能大大减小,我的 1.45M 这么做了之后变成 290K

自动编写摘要
工具 -> 自动编写摘要,这个功能很弱,是用来娱乐的

vim: toggle highlight search

原来 :set xxx! 这样加个叹号就是 toogle,例如 :set hls! 就是切换搜索结果高亮显示,可笑我还专门写个小函数去实现它,现在只要给这个设置 map 一个键就可以了。

How to extract a cpio package

$ cpio -idmv < foobar.cpio

-i  input mode
-d make dirs if need
-m preserve mtime
-v verbose mode

tar 用的多,从没用过 cpio,今天要用了,看了会 man page,先记在这。

HOW TO: Add Non-CDE Window Managers to CDE's Dtlogin

HOW TO: Add Non-CDE Window Managers to CDE's Dtlogin

Follow the instruction, I successfully add fluxbox, my favorite window manager, to CDE's dtlogin menu ;). But it seems that fluxbox-0.9.13 is not very stable, I compiled it using gcc and it crashed several times on my Solaris 10 x86 box. After recomplied with cc, it performs better. I am not sure whether the problem is caused by compiler.

搞定 xchm 和 xmms

终于在 Solaris x86 上把那个 xchm 搞定了,原来下的 chmlib 装上后不能正常链接,从 blastwave.org 上 pkg-get 装来一个才算把 xchm 编译出来。相当不错,至少看英文的 O'Reilly Perl CD Bookshelf 是非常棒,中文的还没试过。

xmms 的安装很简单,装好 pkg-get 之后非常容易,pkg-get install xmms 就搞定了,但是启动后播放 mp3 文件报错,提示检查声卡是否驱动、是否选择了正确的 output 插件。看了一下 Perference 菜单,缺省的 output 插件是 OSS Driver,改为 Solaris audio plugin 就正常了。另外发现,只有 root 能播放,用普通用户不行。这当然是权限问题了,摸索了一会,把 /dev/audio 改为普通用户也可读写的就 OK 了,它是个符号链接,不过 chmod 命令是 follow symbolic link 的,直接 chmod a+rw /dev/audio 就可以了。

另外学到:/usr/sbin/prtconf -vp 这样可以看详细的硬件参数,有点类似 Linux 上的 lspci,可以根据 device-id 和 vendor-id 去 google 设备的驱动程序。

古老的SCCS

居然还在用这么古老的源代码控制工具,google 都找不到源码了,没有办法,入"乡"随俗。这里有两个 SCCS 的介绍:

SCCS 简介An Introduction to the Source Code Control System

看起来要做的这个工具多半也不能让我用 Python 了,Perl 才是他们的 official script language :(

Vim 的 Outline 模式

今天要写一个逻辑结构比较明朗的文档,Emacs 的 outline mode 是很好的,但是太久不用了,实在习惯不了 Emacs 的操作方式,Vim 怎么就没有这样的模式呢?Google 了一下,找到了这个: Emacs outline mode for Vim,就在 vim.org 的网站上。把这个 outline.vim 下载下来之后放到 ~/.vim/syntax/ 下面就行了,用的时候 :set ft=outline 就激活这个模式,可以自己调整一下颜色。Outline 模式的格式很简单:

* 一级标题
** 二级标题
*** 三级标题
**** 四级标题
依此类推。

Win32 版本的 gvim 是要放到自己的主目录下的 vimfiles\syntax\ 下面,主目录就是 USERPROFILE 这个环境变量的值,一般就是 C:\Documents and Settings\USERNAME

这里的 ~/.vim 和 vimfiles 目录可以在 vim 里用 :set runtimepath 看到。

贴一下代码,以防原链接失效。

File: syntax/outline.vim
"
" Description:
"
" This uses folding to mimic outline-mode in Emacs. Set filetype to
" 'outline' to activate this functinality. Put it in the modeline to
" preserve outlines between edits. For example:
"
" vim:set ft=outline:
"
" Installation:
"
" Place this file in your home directory under ~/.vim/syntax/, or in the
" system location under the syntax/ directory to provide it to all users
"
" Maintainer: Tye Z.
"
" Customization:
"
" The colors of the outline headers can be changed by linking them to
" whatever you like. For example:
"
" hi! link Outline_1 Statement
"
" History:
"
" Version 1.1:
"
" - Initial version
"

"
" Highlighting for the section header lines. Add to more levels here.
"
syn match Outline_1 /^\*\{1\}[^*].*$/
syn match Outline_2 /^\*\{2\}[^*].*$/
syn match Outline_3 /^\*\{3\}[^*].*$/
syn match Outline_4 /^\*\{4\}[^*].*$/

"hi! default link Outline_1 Comment
"hi! default link Outline_2 Identifier
"hi! default link Outline_3 PreProc
"hi! default link Outline_4 Type

hi Outline_1 cterm=underline ctermfg=4 gui=bold,underline guifg=Blue
hi Outline_2 cterm=underline ctermfg=3 gui=bold,underline guifg=Brown
hi Outline_3 cterm=underline ctermfg=5 gui=bold,underline guifg=Magenta
hi Outline_4 cterm=underline ctermfg=6 gui=bold,underline guifg=SeaGreen

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

setl foldmethod=expr
setl foldexpr=OutlineFoldFunc()

function! OutlineFoldFunc()
let line = getline(v:lnum)
" If the current line starts with a '*', then this is start of a fold
if line =~ '^\*'
return ">" . matchend(line, "^\**")
else
" Since this is not the start of a fold, see if this is the END of
" one. We are at the end of a fold when the next line has nothing
" but whitespace, and the following line is the start of a fold.
" We look two lines ahead so we can display only the LAST blank
" line. If there are no blank lines, then the start of the next
" fold will automatically end this one.
let line2 = getline(v:lnum+1)
if line2 =~ '^\s*$'
let line3 = getline(v:lnum+2)
if line3 =~ '^\*'
return "<" . matchend(line3, "^\**")
endif
endif
endif
return "=" " fold-level has not changed
endfunction

它的折叠功能还不够完善,如果不喜欢,把 setl foldmethod=expr 那句注释掉就行了。

Solaris 添加 pkg-get

pkg-get 这个东西类似 Debian 上的 apt-get,安装 CSW (Community SoftWare) 软件包非常方便。

如果是代理上网,先设置两个环境变量,然后可用 wget 下载安装:

export http_proxy="http://your.proxy:port"
export ftp_proxy="http://your.proxy:port"
wget http://www.blastwave.org/pkg_get.pkg
pkgadd -d pkg_get.pkg all

然后修改 /opt/csw/etc/pkg-get.conf,其实默认的就行了。代理上网的话最好是在 ~/.bashrc 里 export 那两个变量 http_proxy 和 ftp_proxy,而无需修改 pkg-get.conf。

然后可以 pkg-get install vim 这样安装软件包。

相关网站:

Open Source Software for SolarisList of packages on blastwave

Python 格式串的用法

Python 中格式串不仅仅是用于 print,还可以直接用来生成特定格式的字符串,类似 C 中的 sprintf。以前就忽略了这个而为 python 没有 sprintf 犯愁。

>>> rate = 9999
>>> s = 'rate: %.2f K/s' % (rate/1024.0)
>>> s
'rate: 97.66 K/s'

另外两种普通的用法是:

1. 用于普通的格式化字符串,类似 C 中的 printf

>>> host='example.org'
>>> port=1208
>>> print 'hostname: %s, port: %d' % (host, port)
hostname: example.org, port: 1208

2. 用字典,好处是字典只需要写一遍,而且不用考虑顺序

>>> dict = { 'host': 'example.org', 'port': 1208 }
>>> print 'hostname: %(host)s, port: %(port)d' % dict
hostname: example.org, port: 1208
← Previous  1 … 22 23 24 25 26 Next →