2009-06-24

创建 svn repository 的命令

弄了好几次,每次都得现查一遍。所以整理一下列于此:

摘自于http://www.howtoforge.com/debian_subversion_websvn

// root
# mkdir /var/svn-repos/
# svnadmin create --fs-type fsfs /var/svn-repos/project_name

# groupadd subversion
# addgroup svnuser subversion
# addgroup someuser subversion

# chown -R svnuser:subversion /var/svn-repos/*
# chmod -R 770 /var/svn-repos/*

// normal user (should be in group subversion)
$ mkdir ~/.ssh/
$ cd ~/.ssh/
$ ssh-keygen -t dsa
$ cat ~/.ssh/id_dsa.pub | ssh you@ "cat - >> ~/.ssh/authorized_keys"

$ svn import -m "importing test over ssh+svn" svn+ssh:///var/svn-repos/project_name/trunk
$ svn co svn+ssh:///var/svn-repos/project_name/trunk

2009-06-23

[转]使用Pdftk合并PDF文件

link: http://bbs.haopdf.cn/viewthread.php?tid=441

PDF文件的跨平台特性使其应用广泛,我们在工作学习中经常接触此类文件,但从网上得到的PDF文档,经常是一篇文章中单独页面,怎么把这些单独的页面重新拼合成完整的文档就成了不小的问题。

当然,我们可以借助于Adobe Acrobat中的“Create PDF|From Multiple Files”合并这些单独的页面,但Acrobat是Adobe公司的商业软件,很多朋友由于版权问题并不会安装Acrobat。那么,我们能够使用什么软件来实现同样的功能呢?那就是 Pdftk。

Pdftk是由Sid Steward写的一个PDF增强软件,也就是所谓的PDF Hacks。它可以合并/分割PDF文档、解开必要的输入密码、输出加密、给PDF文档加水印、从PDF文档中解出附件、将PDF文档变成一页等等,能够做到操作PDF文档的所有事情。

其合并文档的具体用法为:

合并多个文档成一个文档:


pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf

使用参数:


pdftk A=1.pdf B=2.pdf cat A B output 12.pdf

使用通配符:


pdftk *.pdf cat output combined.pdf

从几个文档中分割内容合并成一个文档:


pdftk A=one.pdf B=two.pdf cat A1-7 B1-5 A8 output combined.pdf

latex 使用带@的命令

在前后分别加上
\makeatletter
\makeatother

这个虽然很简单,但是不容易google到。。。

2009-06-20

texlive 导致 ubuntu 的一些包卸载错误

卸载(purge, 不知道会不会影响一般卸载和安装)报错install-info: No dir file specified; try --help for more information.

在https://lists.ubuntu.com/archives/universe-bugs/2009-January/039982.html处看到了提示

原因是texlive安装后的其install-info的路径优先级比系统的优先级高,而二者不兼容

解决办法是在卸载包的时候临时将texlive的install-info改名

2009-06-12

Vista 系统每次登陆自动创建加载一个临时用户的profile

症状:
每次登陆桌面会自动还原,增加文件后重启,或者重登陆后就消失

(其实这个只是最明显的症状)

分析:
没有发现可疑进程和自启动项
打开cmd发现所在目录是c:\users\temp.
c:\users\ 目录还在,内容也还在

于是可以看出是系统创建了一个临时用户。

解决:
根据 http://szmmzs.itpub.net/post/3256/482379

在事件查看器中应当可以看到如下事件
Log Name: Application
Source: Microsoft-Windows-User Profiles Service
Date: Date
Event ID: 1511
Task Category: None
Level: Warning
Keywords: Classic
User: User
Computer: Computer
Description:
Windows cannot find the local profile and is logging you on with a temporary profile. Changes you make to this profile will be lost when you log off.

一般来说产生的原因可能是profile目录内容损坏或者权限问题,但我看了一下,似乎都不是
解法是
1 用有管理员权限的其他用户登陆(实在没有别的用这个登录其实也行)
2 备份c:\users\,并改名/删除
3 用管理员打开regedit, 定位于HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
4 找到一个.bak, 其中的ProfileImagePath应当为c:\users\
5 删除.bak这个项,注销,并用出问题的用户登陆
6 这时c:\users\应当被重建
7 恢复备份的内容
8 重登陆

这是应该就没问题


另一说问题是该用户属于guest组,取消即可。 但这次遇到的不是这个情况。

2009-06-02

[转] 22条经典的编程引言

Link: http://cocre.com/?p=808

实在是有意思~

//原文

下面的这些经典的引言来自英文,也许有些我翻译的是不很好,所以,我提供了中英对照,如果有问题,请大家指正。



过早的优化是万恶之源。Premature optimization is the root of all evil!
- Donald Knuth



在水里行走和以一个需求规格进行软件开发,有一点是相同的,那就是如果水或需求都被冻住不了,那么行走和软件开发都会变得容易。Walking on water and developing software from a specification are easy if both are frozen
- Edward V Berard



Hofstadter 定理:“一件事情总是会花费比你预期更多的时间,就算是你已经考虑过本条Hofstadter 定理”。It always takes longer than you expect, even when you take into account Hofstadter’s Law.
- Hofstadter’s Law



有些遇到问题的人总是会说“我知道,我会使用正则表达式”,那么,你现在有两个问题了。(意思是:你本想用正则表达式来解决你已有问题,但实际上你又引入了“正则表达式”的一个新问题)Some people, when confronted with a problem, think “I know, I’ll use regular expressions.” Now they have two problems
- Jamie Zawinski



调试程序的难度是写代码的两倍。因此,只要你的代码写的尽可能的清楚,那么你在调试代码时就不需要那么地有技巧。Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
- Brian Kernighan



用代码行来衡量开发进度,无异于用重量来衡量制造飞机的进度。Measuring programming progress by lines of code is like measuring aircraft building progress by weight.
- Bill Gates



PHP被一些不合格的业余人员造就成了一个小恶魔;而Perl则是被一些熟练的但不正当的专业人员造就成了一个超级大恶魔。PHP is a minor evil perpetrated and created by incompetent amateurs, whereas Perl is a great and insidious evil, perpetrated by skilled but perverted professionals.
- Jon Ribbens



在两个场合我被问到:“请你告诉我,如果你给机器输入了错误的数字,那么,是否还能得到正确的答案?”我并不能正确领会这类想法。(注意,本引言的作者姓Babbage,这个名字和神父同名,意思是,作者在反问提问的人,你是问我还是向神父祈祷?)On two occasions I have been asked, ‘Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?’ I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.”
- Charles Babbage



在编程的时候,我们一定要想像一下,以后维护我们自己的代码的那个人会成为一个有暴力倾向的疯子,并且,他还知道我们住在哪里?Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
- Rick Osborne



现代的编程是“程序员努力建一个更大更傻的程序”和“世界正在尝试创造更多更傻的人”之间的一种竞赛,目前为止,后者是赢家。 Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
- Rich Cook



我才不关于我的代码是否能在你的机器上工作!我们不会给你提供机器。I don’t care if it works on your machine! We are not shipping your machine!
- Ovidiu Platon



我总是希望我的电脑能够像电话一样容易使用;我的这个希望正在变成现实,因为我现在已经不知道怎么去使用我的电话了。I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone.
- Bjarne Stroustrup



计算机是一种在人类历史上所有发明中,可以让你比以前更快地犯更多的错误的发明,同样,其也包括了“手枪”和“龙舌兰酒”这两种发明的缺陷。A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila.
- Mitch Ratcliffe



如果调试程序是一种标准的可以铲除BUG的流程,那么,编程就是把他们放进来的流程。If debugging is the process of removing software bugs, then programming must be the process of putting them in.
- E. W. Dijkstra



教一群被BASIC先入为主的学生,什么是好的编程风格简直是一件不可能的事。对于一些有潜力的程序员,他们所受到的智力上的伤害远远超过了重建他们的信心。It is practically impossible to teach good programming style to students that have had prior exposure to BASIC. As potential programmers, they are mentally mutilated beyond hope of regeneration.
- E. W. Dijkstra



理论上来说,理论和实际是一样的。但实际上来说,他们则不是。In theory, theory and practice are the same. In practice, they’re not.
- Unknown



只有两个事情是无穷尽的:宇宙和人类的愚蠢。当然,我现在还不能确定宇宙是无穷尽的。Two things are infinite: the universe and human stupidity; and I’m not sure about the universe.
- Albert Einstein



Perl这种语言就好像是被RSA加密算法加密过的一样。Perl - The only language that looks the same before and after RSA encryption.
- Keith Bostic



我爱“最终期限”,我喜欢“嗖嗖嗖”的声音就像他们在飞一样。I love deadlines. I like the whooshing sound they make as they fly by.
- Douglas Adams



说Java好的是因为它跨平台就像好像说肛交好是因为其可以适用于一切性别。Saying that Java is good because it works on all platforms is like saying anal sex is good because it works on all genders
- Unknown



XML就像是一种强暴——如果它不能解决你的问题,那只能说明你没有用好它。XML is like violence - if it doesn’t solve your problems, you are not using enough of it.
- Unknown



爱因期坦说,自然界中的一切一定会有一个简单的解释,因为上帝并不是反复无常和独裁的。当然,不会有什么信仰能程序员像爱因期坦那样感到舒服。 Einstein argued that there must be simplified explanations of nature, because God is not capricious or arbitrary. No such faith comforts the software engineer.
- Fred Brooks