这个设计不错,俺刚把一个 project “转让”给了别人 :-)
2007-07-31
Google Code 上的 project 可以转让
Posted by
Display Name
-
10:21 AM
0
comments
Labels: Google, Version Control
2007-07-30
svnsync
- svnsync 的主要用途是创建 svn repository 的 readonly mirror, 如果向 mirror 进行了 commit, 则以后的 sync 会 fail
- svnsync sync 之后, mirror 的 source repository 是不允许再修改的
- svnsync init 只能 init 一个刚创建的空的 repository, 否则报错: svnsync: Cannot initialize a repository with content in it
Posted by
Display Name
-
7:47 PM
0
comments
Labels: Version Control
2007-07-27
AutoIt: Windows Automation Language
AutoIt is a freeware Windows automation language. It can be used to script most simple Windows-based tasks (great for PC rollouts or home automation).
AutoIt has been in popular use since 1999 and continues to provide users and administrators with an easy way to script the Windows GUI. In February 2004 the latest version of AutoIt - known as AutoIt v3 - was released and added powerful scripting features.
AutoIt v3 was developed in a small team with the help of contributors around the world and this has led to a great set of help files, examples, support forum, mailing list, editor files, and third-party utilities. Oh, and lets not forget some nice graphics and wallpapers too!
All development is focused on AutoIt v3 but v2 will continue to be downloadable and supported as it is in such widespread use.
Posted by
Display Name
-
1:20 PM
0
comments
Labels: Utils
2007-07-26
Perl Misc
近两年没怎么用 perl, 忘得差不多了:
- perldoc perlre
- perldoc -f ref
- perldoc -m Socket
- perl -de 0 ARGV ...
- apt-get install zoidberg
- perldoc.perl.org
Posted by
Display Name
-
6:01 PM
0
comments
Labels: Debian/Ubuntu, Perl
2007-07-25
2007-07-24
New screen features
New screen features available
From: | Michael Schroeder |
Subject: | New screen features available |
Date: | Tue, 6 Feb 2007 23:34:31 +0100 |
User-agent: | Mutt/1.4.2.1i |
Hi Screen Users,
you probably wonder why the new version of screen is not already
available. Well, it got delayed a bit because of a couple of new
features I've added. The development version is available from
GNU savanna:
cvs -z3 -d:pserver:address@hidden:/sources/screen co screen
Here are the new features:
- vertical split, complete with resizing
^A | split vertically
resize [-l] [-h] [-v]
-l : resize is local to slice
-h : resize horizontally
-v : resize vertically
amount: 10 resize to size 10
amount: +10 make 10 bigger
amount: -10 make 10 smaller
amount: 10% make it 10% of all
amount: = make all windows equal
- better resize code using weights
the layout will stay in shape even after heavy resizing
- window groups
currently a bit ugly to create:
screen -t//group
creates a group named
a group is a subset of windows, ^Aw will only display the
current group and next/prev will not leave the group.
Use ^A" to list all windows of the current group (this also
leaves to group, so that next/prev or a second ^A" will
show the other windows.
- layouts
A layout stores the current setup of the display, i.e. all the
slices and the window assignments.
layout save Desktop1
will save the current setup under the name "Desktop1". If you
detach and reattach later on, the layout will automatically
be restored. "Desktop1" will become the current layout.
layout autosave off
This turns the autosafe feature off. Layouts are automatically
saved if autosave is on and the user detachs or switches to
another layout.
layout new Desktop2
Create a new empty layout named "Desktop2".
layout name "foo"
Rename the current layout to "foo".
layout next
layout prev
layout load "name"
Load the next/prev layout / the layout named "name".
layout attach :last
layout attach "name"
Set the layout used when somebody is attaching. Default is ":last",
this is the layout that was current when the last detach was done.
Besides the restoring of the screen on re-attach, layouts can be
used to implement a kind of "virtual desktop" in screen. Say
you put "layout save Desktop1" in your ~/.screenrc. If you
need a new Desktop, do "^A:layout new Desktop2". You can then
use "layout next" to switch between both layouts.
So, feedback welcome. You probably have a lot of suggestions and
enhancement requests. Sorry that development is a bit slow at
the moment due to not enough spare time...
Cheers,
Michael.
Posted by
Display Name
-
10:01 AM
0
comments
Labels: Utils
2007-07-23
Screen available for Cygwin
前天新装 cygwin 时发现 package 列表中有 screen (4.0.3) 了, 喜
screen is now available in Cygwin
From: | Andrew Schulman |
Subject: | screen is now available in Cygwin |
Date: | Fri, 20 Jul 2007 05:09:46 -0400 |
screen 4.0.3 is now available in the Cygwin distribution. Cygwin users can
install it using the setup utility; screen is in the "Utils" category.
Questions or bug reports about screen in Cygwin should be directed to the
Cygwin list, cygwin at cygwin dot com.
Andrew.
Posted by
Display Name
-
9:11 PM
0
comments
2007-07-21
SVN 1000
今日俺的 svn repository 的 revision 增至 1000, 留念 :-)
Posted by
Display Name
-
5:27 PM
0
comments
Labels: Version Control
Dixie Chicks - Not Ready to Make Nice
Forget, I'm not sure I could.
They say time heals everything,
But I'm still waiting
I'm through, with doubt,
There's nothing left for me to figure out,
I've paid a price, and i'll keep paying
I'm not ready to make nice,
I'm not ready to back down,
I'm still mad as hell
And I don't have time
To go round and round and round
It's too late to make it right
I probably wouldn't if I could
Cause I'm mad as hell
Can't bring myself to do what it is
You think I should
I know you said
Why can't you just get over it,
It turned my whole world around
and i kind of like it
I made by bed, and I sleep like a baby,
With no regrets and I don't mind saying,
It's a sad sad story
That a mother will teach her daughter
that she ought to hate a perfect stranger.
And how in the world
Can the words that I said
Send somebody so over the edge
That they'd write me a letter
Saying that I better shut up and sing
Or my life will be over
I'm not ready to make nice,
I'm not ready to back down,
I'm still mad as hell
And I don't have time
To go round and round and round
It's too late to make it right
I probably wouldn't if I could
Cause I'm mad as hell
Can't bring myself to do what it is
You think I should
I'm not ready to make nice,
I'm not ready to back down,
I'm still mad as hell
And I don't have time
To go round and round and round
It's too late to make it right
I probably wouldn't if I could
Cause I'm mad as hell
Can't bring myself to do what it is
You think I should
Forgive, sounds good.
Forget, I'm not sure I could.
They say time heals everything,
But I'm still waiting
Posted by
Display Name
-
2:58 PM
0
comments
Labels: Music
Dixie Chicks - The Long Way Around
Moved into houses in the same ZIP codes
Where their parents live
But I, I could never follow
No I, I could never follow
I hit the highway in a pink RV with stars on the ceiling
Lived like a gypsy
Six strong hands on the steering wheel
I've been a long time gone now
Maybe someday, someday I'm gonna settle down
But I've always found my way somehow
By taking the long way
Taking the long way around
Taking the long way
Taking the long way around
I met the queen of whatever
Drank with the Irish and smoked with the hippies
Moved with the shakers
Wouldn't kiss all the asses that they told me to
No I, I could never follow
No I, I could never follow
It's been two long years now
Since the top of the world came crashing down
And I'm getting' it back on the road now
But I'm taking the long way
Taking the long way around
I'm taking the long way
Taking the long way around
The long
The long way around
Well, I fought with a stranger and I met myself
I opened my mouth and I heard myself
It can get pretty lonely when you show yourself
Guess I could have made it easier on myself
But I, I could never follow
No I, I could never follow
Well, I never seem to do it like anybody else
Maybe someday, someday I'm gonna settle down
If you ever want to find me I can still be found
Taking the long way
Taking the long way around
Taking the long way
Taking the long way around
Posted by
Display Name
-
2:54 PM
0
comments
Labels: Music
2007-07-20
养鸡场的死鸡哪去了
南方周末 2007-07-19 15:38:07
一种畸形养殖模式,导致鸡大批死亡。而当中国人每年吃掉近五十亿只鸡时,我们不得不去关注——
养鸡场的死鸡哪去了
□周思妤 成希 郑焕坚 □本报记者 穆彤 张英 发自北京 上海
广州
■只有比较新鲜的死鸡才会整只出售给商家,用于加工烧鸡、烤鸡;不太新鲜的,会把鸡翅、鸡腿、鸡爪切出来,制成冷冻食品
■吃死鸡并不会感染禽流感,因为高温可以杀死禽流感病毒。但有可能得病的是那些杀鸡、抓鸡的人,禽流感是接触传染的
■“集中营式”养殖,使得这些鸡异常脆弱。一位专家在肉鸡场做调查,竟然还发现了放在地上连路都不会走的鸡!这样的鸡进入食物链,对人体的危害可想而知
当中国人每年吃掉的鸡接近50亿只时,一个问题必须引起高度关注--这种餐桌上必不可少的食物是否安全?
中科院专家调研得出惊人结果
一位资深学者揭开了这个公开的秘密--他叫蒋高明,中国科学院植物研究所首席研究员。2005年7月至今,他与他的课题组在山东、内蒙古、北京等多个省份,展开了一项对“养鸡场死鸡去向”的调查,其结论是:大部分死鸡被端上了餐桌。
“养殖户大都是比较淳朴的农民,他们对死鸡的去向都直言不讳--全部卖给了收死鸡的人。”蒋高明说,“有的鸡农还向我炫耀:一次他拉了三千多只鸡进城,送到批发市场已经死了三百多只。他把这些死鸡直接运到附近的农贸市场卖掉,省了很多成本。”
南方周末记者的调查进一步印证了这个结论。而当记者以鸡贩子的身份致电陕西、湖北、安徽、江苏的十多家养鸡场后,发现小型养鸡场大都出售死鸡。这个交易过程很简单:买者直接过去,看货、给钱,他们负责找个车拉走。
只有拥有10万只鸡以上的大型养殖场拒绝出售死鸡。“这只是表面现象,因为你和他们不熟。”一名死鸡贩子对记者说,“他们不敢拿自己的信誉做赌注。”
“在我们调查的养鸡场中,进入食物链的死鸡超过八成。”蒋高明说。
另一个事实也被揭开:大量死鸡从禽病医院流入了市场。蒋高明发现,医院里的死鸡本是鸡农带来让医生诊断的--这些可能有疫病的家禽,应该做焚烧或掩埋处 理。“但是通过熟人介绍,医院发现死鸡可以卖钱。”蒋高明说,“于是,卖死鸡就成了禽病医院的生意。现在,每天都有专人到医院收购死鸡。”不要小看禽病医 院里的死鸡量,有些养殖户会带半麻袋鸡来看病--他们宁愿多带些样本,让大夫瞧个明白。
它们这样走上餐桌
这些令人作呕的死鸡,养活了一群人。他们清晨四五点钟出门,每天甚至要跑四五百公里的路程,到各个养鸡场收购死鸡。当然,如果把这个生意做大,就可以在家中等货上门。而在每个禽类交易市场,也活跃着专收死鸡的群体。每天,他们像淘宝一样,在各个“档口”以低价进货。
在华南一个禽类批发市场里,记者以业务员的名义认识了鸡贩子陈仔。他只有22岁,但从事禽畜动物批发已经7年,3年前就拥有自己独立的档口。按他的说 法,批发市场中的绝大部分死鸡都被出售,除了极少数高度腐烂的。“每天至少有50万只鸡流入市场,按照5%的最低死亡率,大约2.5万只死鸡被市民吃 掉。”陈仔说。
为证实上述观点,这个批发商带记者在多个禽类市场进行了考察。死鸡都被装进编织袋,扔在每个档口的臭水沟里,皮毛不整、异味扑鼻。它们也被明码标价,并随着市场行情上下浮动。比如竹丝鸡目前每只3元,清远鸡每只9元。
无论是去养殖场取货,还是在禽类批发市场收购,死鸡都有一个“再分解”的加工过程。在河北的一个死鸡加工点,本报记者曾亲眼目睹这一系列肮脏的工序-- 首先是用热水甚至沥青烫,再放入褪毛机,最后放在水中浸泡,以去除其身上的淤血。一般人是无法忍受工作的“艰辛”的--在现场,一个刚来不久的小工突然呕 吐不止。
只有比较新鲜的死鸡才会整只出售给商家,用于加工烧鸡、烤鸡;不太新鲜的,会把鸡翅、鸡腿、鸡爪切出来,制成冷冻食品。“冷冻食品都 不新鲜,很难看出哪是病死鸡哪是健康鸡,所以容易掩人耳目。”一位业内人士说。另外,死鸡的内脏--比如说鸡胗,大多流向烧烤摊位;而腐烂比较严重的鸡, 还能制成火腿肠。值得注意的是,有些饭店的“乳鸽”,或者那些油炸“麻雀”,其实就是剥过皮的小死鸡。
此间的产业链已非常成熟。在下游,有专门要内脏的商贩,有专取白条鸡的商贩,还有加工熟食的。其终端就是饭店、熟食店、烧烤摊甚至超级市场,死鸡由此进入人们的餐桌。
流通背后的利益链
某禽病中心医生称,他正准备享受“美味”烧鸡时,被吓出了一身汗。眼前的食品是由“包心包肝”的鸡做成的--所谓“包心包肝”,是指鸡死于大肠杆菌感染 后,心脏或肝脏外会形成厚约1毫米的蛋白分泌物,呈黄白色。烧鸡店老板没有将此分泌物处理干净,就做了烧鸡。“专业人员可以吃出死鸡来,普通人怎么吃得 出?”一位禽类专家说。
但黑心商人不会在乎这些,对于他们,利润才是第一位的。有位老板给暗访的央视记者算过一笔账:“收一只死鸡平均2元钱。加工成烧鸡半成品重约1公斤,按批发价是一斤4.5元,每只鸡能挣6-7元。如果一天做300只,就收入2000元左右。”
“对养殖户来说,也是因为回收成本心情急切让他们不顾食物安全。”蒋高明说,“在政府方面,只有禽流感死亡的鸡才给养殖户补偿,虽然大部分地区规定了每 只补助10元,但是农民要拿到是很困难的。这也并非政府的完全不作为--一个五六万人的乡镇,有30-40个大型养殖场,活鸡两三百万,但政府工作人员只 有三五个人。怎么管理呢?”
有关部门的不作为,助长了死鸡的流通。“卫生标准往往是摆在那里应付检查的。”一位养殖户说,“养殖场里难闻的气味,令检查的官员避之惟恐不及,很多时候在外面转转就交差了。”
这种情况同样出现在禽类批发市场。广州一个鸡贩子说,禽流感严重的时候,市场加大了监管力度,派出专人每天去各个档口收集死亡的禽畜,买卖死禽被严惩。但禽流感一过,有关部门睁一只眼闭一只眼,商户出售死鸡也越来越明目张胆。
死鸡伤人有多深?
尽管这些死鸡让人很反感,但可以肯定的是,煮熟的它们不会传播禽流感。接受南方周末记者采访时,中国工程院院士、中国疾病预防控制中心专家陈君石解释:“高温可以杀死禽流感病毒。但有可能得病的是那些杀鸡、抓鸡的人,禽流感是接触传染的。”
“但动物死后,尸体的腐烂会很快开始,过程会产生对人体有害的物质。”中国健康教育协会副会长、复旦大学教授李枫说,“何况死鸡往往是病鸡,带有各种传染性病菌。加工者为了掩盖死鸡的异味,往往又加了过多的添加剂,这对人体的危害更大。”
一般情况下,鸡的死因有两种:传染病死亡和非传染病死亡--比如药物中毒、天气过热、环境污染、打斗致死等。南方周末记者根据多方调查总结,目前,大部分养鸡场的死亡率为5%-10%。“这是一个不正常的数字。”蒋高明说。
据蒋高明调查,很多养殖户为了让鸡少患病,将磺胺类药物掺入它们的食物中,甚至使用禁用药物喹乙醇。“工厂化养殖的鸡,每天吃着大量的添加剂、安眠药、 抗生素和激素,养殖者把它们的生命周期由200多天缩短到40天左右。”蒋高明说,“这样不科学的喂养,怎能不提高鸡的死亡率?”
同时被这位研究者严厉指责的,还有“集中营”式的养殖方式。在天津、北京等北方城市,本报记者曾亲眼目睹这种方式--至少七八十只鸡一直挤在1平方米的狭小空间里,身体都转不过来。惟一可以享受自由的,是它们探出笼子的头。
“严重违背生物学规律的养殖,使得这些鸡异常脆弱,放个鞭炮都能被吓死。”蒋高明说,“集约化养殖的鸡,不会飞已不是什么令人大惊小怪的事了。但是我这次在肉鸡场的调查,竟然还发现了放在地上连路都不会走的鸡!”
而这样的鸡进入食物链,无论是否死亡的,对人体的危害可想而知。即使这些鸡粪做成的肥料,都会因为重金属含量超标而产生危害。
在某些养鸡已经形成产业的地方,村民间已经形成了一条不成文的规矩:如果哪家人办喜事招待客人,图便宜买了肉鸡,就会让乡亲们笑话,从此抬不起头来。所以,即使最穷的人都要花高价买散养的柴鸡下厨。
更令一些生物专家担忧的是,这种严重违背生物学的养殖方式,已经扩大到了鸭和鹅。后者的出笼时间也是40天左右,甚至连它们戏水的基本权利都被剥夺了。
“很多食品安全问题不是突发性的--不是说,人一吃了就会马上发病。”一位消费者说,“而这种在畸形环境里成长起来的鸡,就可能给人体带来长期的威胁。”
为改变这种畸形养殖模式,蒋高明及著名学者温铁军等人提议:将“集中营”式的养殖转变为自由散养,利用广阔的草原、林下空地等生态空间,把鸡解放出牢 笼,还原其150-200天的“长大成鸡”周期。这被他们总结为“畜南下,禽北上”。这也是身为植物生态学家的蒋高明等人为什么开展死鸡调查的起因。
(有关中国法律禁止销售死鸡的规定,参见本报网站www.infzm.com)
Posted by
Anonymous
-
10:21 PM
0
comments
Labels: Misc
Dixie Chicks - Taking The Long Way
Dixie Chicks《Taking The Long Way》
http://www.sina.com.cn 2006年06月20日15:52 新浪娱乐

专辑名:《Taking The Long Way》
演唱者:Dixie Chicks
发行时间:2006年5月23日
发行公司:Sony
音乐风格:Neo-Traditionalist Country(新传统主义乡村),Pop/Rock(流行/摇滚)
[曲目介绍] |
1. The Long Way Around
2. Easy Silence
3. Not Ready To Make Nice(推荐单曲)
4. Everybody Knows(推荐单曲)
5. Bitter End
6. Lullaby
7. Lubbock Or Leave It
8. Silent House
9. Favorite Year(推荐单曲)
10. Voice Inside My Head(推荐单曲)
11. I Like It
12. Baby Hold On
13. So Hard
14. I Hope
[唱片点评] |
在将近四年之后,美国最受欢迎的当代乡村组合南方小鸡(Dixie Chicks)终于推出了她们最新的录音室专辑《Taking The Long Way》。这张《Taking The Long Way》在发行首周的单周销量达到52万6千张,力压同样由里克·鲁宾(Rick Rubin)制作的红辣椒乐队(Red Hot Chili Peppers)的最新双张专辑《Stadium Arcadium》,如愿登顶本周的Billboard 200专辑榜,成为Dixie Chicks第三张在Billboard 200专辑榜中折桂的专辑。Dixie Chicks此前两张冠军专辑分别是1999年发行的《Fly》和2002年发行的《Home》,而上张专辑《Home》在发行首周的销量更高,达到了 78万张。
在这张专辑中,Rick Rubin不仅担当制作人,而且还为Dixie Chicks召集来了Red Hot Chili Peppers乐队的鼓手查德·史密斯(Chad Smith),为汤姆·佩蒂(Tom Petty)伴奏的“伤心者”乐队(Heartbreakers)的键盘手本蒙特·坦奇(Benmont Tench)和吉他手麦克·坎贝尔(Mike Campbell)等实力不俗的乐手为Dixie Chicks的三位女将助阵。另外,在专辑歌曲的创作名单中,还包括了著名民谣摇滚女歌手雪儿·克洛(Sheryl Crow),当代布鲁斯吉他手Keb' Mo'以及另类乡村摇滚乐队The Jayhawks的成员加里·罗里斯(Gary Louris)等创作高手。更多新鲜血液的注入使Dixie Chicks这张专辑显得更加的丰润,《Not Ready To Make Nice》,《Everybody Knows》,有Sheryl Crow参与创作的《Favorite Year》以及《Voice Inside My Head》都是十分有Dixie Chicks特点的优秀单曲。而从歌词上来看,Dixie Chicks这三位女将也是非常值得钦佩的,面对各种威胁恐吓丝毫没有任何妥协,依然光明磊落,兢兢业业的做着她们自己的音乐。
从各方面来说,这张《Taking The Long Way》都丝毫不比四年前大卖的专辑《Home》逊色。相反,Dixie Chicks用实力证明了她们与Rick Rubin以及各界创作精英的合作是相当成功的。尽管已经四年没有新作问世,但Dixie Chicks用这张歌迷们已经期盼已久的专辑证明了她们仍是当今美国最有实力的乡村组合之一。KFC MAN/文
[歌手介绍] |

Dixie Chicks这个名字最早来源于美国布鲁斯摇滚乐队Little Feat的歌曲《Dixie Chickens》。直到上世纪90年代末,Dixie Chicks才在美国主流乡村音乐界大红大紫。但早在1989年,Dixie Chicks组合就已经在达拉斯成立,最初组建Dixie Chicks的四位成员分别是:小提琴手马蒂·塞德尔(Martie Seidel)和他弹班卓琴的姐妹埃米丽·艾尔文(Emily Erwin),贝斯手劳拉·林奇(Laura Lynch)和吉他手罗宾·林恩·梅西(Robin Lynn Macy)。乐队最初也只是能够在街角以及当地的小酒吧演出,但随着Martie Seidel在美国小提琴大赛中获得季军,Dixie Chicks组合的事业也开始有了明显的好转。Dixie Chicks逐渐确定了自己将传统乡村音乐,民谣以及兰草等多种音乐融为一体的独特风格。1990年,Dixie Chicks独立发行了她们的首张专辑《Thank Heavens for Dale Evans》。
1992,在《Little Ol' Cowgirl》发行之后,Robin Lynn Macy宣布离队,而Laura Lynch开始担任主唱。1993年,Dixie Chicks首次以三人阵容发行了专辑《Shouldn't a Told You That》。1995年,在Dixie Chicks与Sony新设立的厂牌Monument签约后不久,Laura Lynch也离开了Dixie Chicks。之后,曾有媒体报道Robin Lynn Macy以及Laura Lynch的离队都是由于年龄问题。在Laura Lynch退出后不久,乡村吉他大师Lloyd Maines 21岁的女儿Natalie Maines成为了Dixie Chicks的新任主唱。
拥有了新阵容的Dixie Chicks将传统的乡村音乐做的愈加的流行化。正如媒体预言,Dixie Chicks组合1998年在大厂牌Monument发行的首张专辑《Wide Open Spaces》获得了巨大的成功,不仅获得了当年Billboard乡村专辑榜的冠军,而且在Billboard 200专辑榜中也取得第四名的好成绩。专辑中首支单曲《I Can Love You Better》成为Dixie Chicks第一支打入排行榜前十名的单曲,而《There's Your Trouble》以及同名单曲《Wide Open Spaces》都在乡村单曲榜中成功问鼎。在《Wide Open Spaces》专辑发行后的一年之内,专辑在美国的总销量达到四白金,Dixie Chicks一跃成为美国最受人瞩目的乡村组合之一,她们不仅获得美国乡村音乐协会评出的最佳组合以及Horizon奖两项大奖,而且在当年的美国音乐奖 的角逐中还被评为“歌迷最喜爱的乡村新人”。Dixie Chicks也凭借这张叫好又叫座的专辑获得1998年第41届格莱美奖的“最佳乡村组合”以及“最佳乡村专辑”两项大奖。
1999年8月,Dixie Chicks再接再厉,发行了加盟Monument之后的第二张专辑《Fly》。专辑中首支单曲《Ready to Run》以及之后的《Goodbye Earl》在乡村单曲榜中的表现很快就十分抢眼,而《Fly》也成为Dixie Chicks首张在Billboard 200专辑榜中夺冠的专辑。Dixie Chicks凭借这张《Fly》再度获得格莱美最佳乡村专辑奖。
2002年5月,Dixie Chicks和莎奇拉(Shakira),马丽·J·布里奇(Mary J. Blige),雪儿(Cher)和席琳·迪翁(Celine Dion)一起参加了VH1台在拉斯维加斯举办的Divas Show。仅仅三个月之后,Dixie Chicks发行了她们的第六张专辑《Home》。《Home》是Dixie Chicks组合在她们自己的厂牌Open Wide发行的第一张专辑,也是Dixie Chicks的第二张冠军专辑。在2002年第45届格莱美奖中,Dixie Chicks再次捧得三项大奖。2003年11月,Dixie Chicks发行了她们首张现场专辑《Top of the World Tour: Live》。2004年,Dixie Chicks依靠这张现场专辑得到了她们第八座格莱美奖杯。
2006年5月23日,Dixie Chicks的最新录音室专辑《Taking The Long Way》面世。专辑在美国发行首周共售出52万6千张,成为Dixie Chicks第三张在Billboard 200专辑榜中登顶的专辑。KFC MAN/文
Posted by
Display Name
-
12:33 PM
0
comments
Labels: Music
2007-07-18
2007-07-11
Bash on Debian/Ubuntu does not support using the /dev/tcp and /dev/udp files
$ cat < /dev/tcp/localhost/daytime
bash: /dev/tcp/localhost/daytime: No such file or directory
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=6.06
DISTRIB_CODENAME=dapper
DISTRIB_DESCRIPTION="Ubuntu 6.06.1 LTS"
$
Posted by
Display Name
-
10:19 AM
0
comments
Labels: Debian/Ubuntu, Shell/Scripting
[Mac OS X] Deleting users with dscl
Deleting Mac OS X users remotely with dscl
I had occasion recently to need to remotely delete a user — let’s call him “George” — on a Mac OS X box that is running the Client version of Tiger. I have ssh access to that machine and, since I keep meaning to learn how to do it, I decided to take the time to make a few notes on the process for the next such occasion.
What I needed to do was, first, remove him from any groups he was in and then delete his account. On OS X, this is usually handled by the NetInfo database, so I needed a way to manipulate it without using the GUI /Applications/Utilities/NetInfo Manager
that I’d probably use were I physically sitting at the machine.
The command I’ll use is /usr/bin/dscl
— the Directory Service command line utility. If you’re familiar with CLI utilities, the syntax of dscl
won’t be problematic for you. It is a truly powerful program, bringing pretty much anything involved with NetInfo under your control. This is a good thing, but it is also dangerous. Which brings us to this warning:
Do not start doing this if you don’t know what you’re doing or are disconcerted by the idea of telling your computer what to do by typing. You can damage your system, not to mention possibly leaving you unable to have children. ¡Cuidado!
Before you make any changes to NetInfo, you should back its database up. That Apple article has a couple of methods. Use one of them. For the children.
With that out of the way, let’s talk about NetInfo domains. Assuming you didn’t RTFA at the link above, the basic idea is that there is a hierarchical database that handles all the user and group data (just to mention a couple of things) for Mac systems. NetInfo has been around since the NeXT days.
The NetInfo hierarchy starts with what it calls Domains. (This is a mite confusing at first since it doesn’t refer to Internet domain names.) Under each Domain there are Directories, and they can have Properties with accompanying Values, as well as contain other Directories. We’ll cover these ideas in practice as we go along.
Here’s an applicable example: like every Mac, my remote server has a /users
directory under the local domain.
It’s important to differentiate here that this is not referring to the /Users
folder in the filesystem where a user’s home folder usually is. This can be somewhat bewildering for NetInfo neophytes.
Now, inside the NetInfo /users
Directory are a bunch of other Directories corresponding to all the users on the machine — human accounts (like my own and the one I’ll be deleting), but also system “users” like daemon, mysql, nobody, root, and www. In fact, here’s a command to give us a list of all the users on the machine:
dscl . list /users
Breaking it down: there’s dscl
, a period “.” representing the local machine, the list
command, and then the directory we want a listing of. This is also the basic syntax we’ll be dealing with throughout our exercise.
So, I run that on my remote machine and get a long list of users, including the about-to-be-deleted George. To see what NetInfo has to say about good old Georgie:
dscl . read /users/george
Pretty much the same idea as before, except we’re using the read
command rather than list
. Using the Finder as an analogy, list
is like viewing a list of text files in a folder, and read
is like viewing the contents of one of those files.
Here’s some (though not all) of what I got in response to my read
request:
AppleMetaNodeLocation: /NetInfo/DefaultLocalNode
AuthenticationAuthority: ;ShadowHash;
NFSHomeDirectory: /Users/george
Password: *
PrimaryGroupID: 530
RealName: George Costanza
RecordName: george
UniqueID: 530
This can get overwhelming with all kinds of unfamiliar text flying by, so it can be useful to focus in on one value, e.g. where their home folder is. We find that out by examining NFSHomeDirectory
, which is a users Property. Other such Properties include PrimaryGroupID
, RealName
, UniqueID
, and the rest of /users/george
.
Much like a variable in algebra, a Property has a corresponding Value. To ask for George’s home directory only, we use:
dscl . read /users/george NFSHomeDirectory
Which returns this line:
NFSHomeDirectory: /Users/george
So, for the Property NFSHomeDirectory
the Value is /Users/george
Again, to keep it straight, that’s the /Users/george
home folder in the Finder.
Now I have George in my sights, and I’m almost ready to get rid of him. But first, let’s deal with the groups he’s a member of. Similarly to getting a list of users on the local machine, we can do the same thing for groups:
dscl . list /groups
Long list there, but it includes the two groups I need to deal with. I happen to know that George is in only two groups: handmodels
and george
(a user is by default a member of a group with the same name).
Just for our edification, let’s get a list of the users in handmodels
. We can do this by zeroing in on one Property like we did above, GroupMembership
:
dscl . read /groups/handmodels GroupMembership
This returns:
GroupMembership: grady mia ramon mike george
A-ha! There he is, along with a few other folks. To kick him out of there, I’ll need to use sudo
because you need admin access to make this kind of change to the database:
sudo dscl . delete /groups/handmodels GroupMembership george
A password prompt appears. Enter the admin password, hit Return, and George is gone from handmodels. Let’s just make sure:
dscl . read /groups/handmodels GroupMembership
And we get back:
GroupMembership: grady mia ramon mike
If George were HAL, he would be feeling his mind going right about now.
Getting rid of the george
group is handled a bit differently since it’s a whole Directory and not the Value of a Property. To delete his group completely:
sudo dscl . delete /groups/george
And that’s it for George’s groups. George/HAL is singing “Bicycle Built For Two.”
For safety’s sake, please note the similarity between this last command and the one above that deleted his name from handmodels. Imagine how easy it could be to really screw things up by deleting something accidentally. Have you backed up lately?
Finally, we’re ready to delete George himself. The syntax is much the same as the last command:
sudo dscl . delete /users/george
Poof! George has ceased to be. He has expired and gone to meet his maker. He is an ex-user.
Now all that’s left is to remove the vestiges of George scattered around the filesystem, starting with his home folder /Users/george
. Just to play it safe, you might want to archive George’s stuff. You know, if he happens to re-enter your good graces.
Maybe when you’re feeling magnanimous around Festivus time. ;)
Comments
Posted by
Display Name
-
9:36 AM
0
comments
Labels: Apple, Shell/Scripting
2007-07-10
[Mac OS X] User Template
Linux 系统里有个 /etc/skel 目录, Mac OS X 上对应的目录为 /System/Library/User Template
Posted by
Display Name
-
8:45 PM
0
comments
[Mac OS X] Adding a User From the Command Line
Adding a User From the Command Line
This section shows a simple example of using the Directory Service command-line tool, dscl(1)
, to add a user to the system. The example specifies some of the properties that you would normally associate with any user.
Note: These commands must be run as the root user. If you are executing them from the command line manually, you should do this with sudo(8)
. If you are using them in a script, you should use sudo
when running the script.
Create a new entry in the local (
/
) domain under the category/users
.dscl / -create /Users/portingunix
Create and set the shell property to
bash
.dscl / -create /Users/portingunix UserShell /bin/bash
Create and set the user’s full name.
dscl / -create /Users/portingunix RealName "Porting Unix Applications To Mac OS X"
Create and set the user’s ID.
dscl / -create /Users/portingunix UniqueID 503
Create and set the user’s group ID property.
dscl / -create /Users/portingunix PrimaryGroupID 1000
Create and set the user home directory. (Despite the name
NFSHomeDirectory
, this is the local path to the home directory.)dscl / -create /Users/portingunix NFSHomeDirectory /Local/Users/portingunix
Set the password.
dscl / -passwd /Users/portingunix PASSWORD
or
passwd portingunix
To make that user useful, you might want to add them to the admin group.
dscl / -append /Groups/admin GroupMembership portingunix
This is essentially what System Preferences does when it makes a new user, but the process is presented here so you can see more clearly what is going on behind the scenes with the NetInfo database. A look through the hierarchies in the NetInfo Manager application also helps you understand how the database is organized.
Posted by
Display Name
-
8:42 PM
0
comments
Labels: Apple, Shell/Scripting
2007-07-09
svn+ssh configuration
Tunneling over SSH
svnserve's built-in authentication can be very handy, because it avoids the need to create real system accounts. On the other hand, some administrators already have well-established SSH authentication frameworks in place. In these situations, all of the project's users already have system accounts and the ability to “SSH into” the server machine.
It's easy to use SSH in conjunction with svnserve. The client simply uses the svn+ssh://
URL schema to connect:
$ whoami
harry
$ svn list svn+ssh://host.example.com/repos/project
harry@host.example.com's password: *****
foo
bar
baz
…
In this example, the Subversion client is invoking a local ssh process, connecting to host.example.com
, authenticating as the user harry
, then spawning a private svnserve process on the remote machine running as the user harry
. The svnserve command is being invoked in tunnel mode (-t
) and its network protocol is being “tunneled” over the encrypted connection by ssh, the tunnel-agent. svnserve is aware that it's running as the user harry
, and if the client performs a commit, the authenticated username will be attributed as the author of the new revision.
The important thing to understand here is that the Subversion client is not connecting to a running svnserve daemon. This method of access doesn't require a daemon, nor does it notice one if present. It relies wholly on the ability of ssh to spawn a temporary svnserve process, which then terminates when the network connection is closed.
When using svn+ssh://
URLs to access a repository, remember that it's the ssh program prompting for authentication, and not the svn client program. That means there's no automatic password caching going on (see the section called “Client Credentials Caching”). The Subversion client often makes multiple connections to the repository, though users don't normally notice this due to the password caching feature. When using svn+ssh://
URLs, however, users may be annoyed by ssh repeatedly asking for a password for every outbound connection. The solution is to use a separate SSH password-caching tool like ssh-agent on a Unix-like system, or pageant on Windows.
When running over a tunnel, authorization is primarily controlled by operating system permissions to the repository's database files; it's very much the same as if Harry were accessing the repository directly via a file://
URL. If multiple system users are going to be accessing the repository directly, you may want to place them into a common group, and you'll need to be careful about umasks. (Be sure to read the section called “Supporting Multiple Repository Access Methods”.) But even in the case of tunneling, the svnserve.conf
file can still be used to block access, by simply setting auth-access = read
or auth-access = none
. [43]
You'd think that the story of SSH tunneling would end here, but it doesn't. Subversion allows you to create custom tunnel behaviors in your run-time config
file (see the section called “Runtime Configuration Area”). For example, suppose you want to use RSH instead of SSH. In the [tunnels]
section of your config
file, simply define it like this:
[tunnels]
rsh = rsh
And now, you can use this new tunnel definition by using a URL schema that matches the name of your new variable: svn+rsh://host/path
. When using the new URL schema, the Subversion client will actually be running the command rsh host svnserve -t behind the scenes. If you include a username in the URL (for example, svn+rsh://username@host/path
) the client will also include that in its command (rsh username@host svnserve -t). But you can define new tunneling schemes to be much more clever than that:
[tunnels]
joessh = $JOESSH /opt/alternate/ssh -p 29934
This example demonstrates a couple of things. First, it shows how to make the Subversion client launch a very specific tunneling binary (the one located at /opt/alternate/ssh
) with specific options. In this case, accessing a svn+joessh://
URL would invoke the particular SSH binary with -p 29934
as arguments—useful if you want the tunnel program to connect to a non-standard port.
Second, it shows how to define a custom environment variable that can override the name of the tunneling program. Setting the SVN_SSH
environment variable is a convenient way to override the default SSH tunnel agent. But if you need to have several different overrides for different servers, each perhaps contacting a different port or passing a different set of options to SSH, you can use the mechanism demonstrated in this example. Now if we were to set the JOESSH
environment variable, its value would override the entire value of the tunnel variable—$JOESSH would be executed instead of /opt/alternate/ssh -p 29934.
SSH configuration tricks
It's not only possible to control the way in which the client invokes ssh, but also to control the behavior of sshd on your server machine. In this section, we'll show how to control the exact svnserve command executed by sshd, as well as how to have multiple users share a single system account.
Initial setup
To begin, locate the home directory of the account you'll be using to launch svnserve. Make sure the account has an SSH public/private keypair installed, and that the user can log in via public-key authentication. Password authentication will not work, since all of the following SSH tricks revolve around using the SSH authorized_keys
file.
If it doesn't already exist, create the authorized_keys
file (on Unix, typically ~/.ssh/authorized_keys
). Each line in this file describes a public key that is allowed to connect. The lines are typically of the form:
ssh-dsa AAAABtce9euch… user@example.com
The first field describes the type of key, the second field is the uuencoded key itself, and the third field is a comment. However, it's a lesser known fact that the entire line can be preceded by a command
field:
command="program" ssh-dsa AAAABtce9euch… user@example.com
When the command
field is set, the SSH daemon will run the named program instead of the typical svnserve -t invocation that the Subversion client asks for. This opens the door to a number of server-side tricks. In the following examples, we abbreviate the lines of the file as:
command="program" TYPE KEY COMMENT
Controlling the invoked command
Because we can specify the executed server-side command, it's easy to name a specific svnserve binary to run and to pass it extra arguments:
command="/path/to/svnserve -t -r /virtual/root" TYPE KEY COMMENT
In this example, /path/to/svnserve
might be a custom wrapper script around svnserve which sets the umask (see the section called “Supporting Multiple Repository Access Methods”). It also shows how to anchor svnserve in a virtual root directory, just as one often does when running svnserve as a daemon process. This might be done either to restrict access to parts of the system, or simply to relieve the user of having to type an absolute path in the svn+ssh://
URL.
It's also possible to have multiple users share a single account. Instead of creating a separate system account for each user, generate a public/private keypair for each person. Then place each public key into the authorized_users
file, one per line, and use the --tunnel-user
option:
command="svnserve -t --tunnel-user=harry" TYPE1 KEY1 harry@example.com
command="svnserve -t --tunnel-user=sally" TYPE2 KEY2 sally@example.com
This example allows both Harry and Sally to connect to the same account via public-key authentication. Each of them has a custom command that will be executed; the --tunnel-user
option tells svnserve -t to assume that the named argument is the authenticated user. Without --tunnel-user
, it would appear as though all commits were coming from the one shared system account.
A final word of caution: giving a user access to the server via public-key in a shared account might still allow other forms of SSH access, even if you've set the command
value in authorized_keys
. For example, the user may still get shell access through SSH, or be able to perform X11 or general port-forwarding through your server. To give the user as little permission as possible, you may want to specify a number of restrictive options immediately after the command
:
command="svnserve -t --tunnel-user=harry",no-port-forwarding,\
no-agent-forwarding,no-X11-forwarding,no-pty \
TYPE1 KEY1 harry@example.com
Posted by
Display Name
-
8:21 PM
0
comments
Labels: Version Control
svn+ssh does not support non-standard port
目前 svn+ssh://user@server/path 不能指定 ssh 的 port, 已经有人发了 bug.
Posted by
Display Name
-
8:08 PM
0
comments
Labels: Version Control
[转] PuTTY 中文教程
http://blog.chinaunix.net/u/553/showart.php?id=335551
http://docs.google.com/View?docid=ajbgz6fp3pjh_2dwwwwt
Posted by
Display Name
-
9:48 AM
0
comments
Labels: Utils
2007-07-07
Inblogs.net blocked?
近日用 www.inblogs.net 也不能访问 blogspot 了,难道也被 GFW 给 block 了?
Posted by
Display Name
-
7:21 PM
0
comments
ssh 相关的几个环境变量
SSH_CLIENT='192.168.3.102 1051 10022'
SSH_CONNECTION='192.168.3.102 1051 192.168.3.38 10022'
SSH_TTY=/dev/pts/0
其中 SSH_TTY 只有在 interactive shell 中才会被设置.
Posted by
Display Name
-
5:08 PM
0
comments
Labels: Network/Security, Shell/Scripting
Google Code: Failed to checkout svn repository
svn { ls | cat | info } http://xxx.googlecode.com/svn 等命令都 work,就是不能 checkout:
$ svn co http://xxx.googlecode.com/svn
svn: REPORT request failed on '/svn/!svn/vcc/default'
svn: REPORT of '/svn/!svn/vcc/default': 400 Bad Request (http://huan.googlecode.com)
$
但是用 https 的话就能 checkout,不知何故,有人说是跟 firewall 上的设置有关。
(回家用俺的 ADSL 试了一下,没有问题,看来是公司的 firewall 把 http 的 svn checkout 给 block 了)
Posted by
Display Name
-
2:51 PM
0
comments
Labels: Google, Version Control
Upload your svn repository to Google Code
今日听 jiahuan 说可以在 Google Code 上创建自己的 svn repository,好是激动了一番,俺早就想找个地方安置俺的 svn 目录了。
申请步骤很简单,到 http://code.google.com/hosting/ 创建一个 new project 就成了。每个 project 空间好像是 100M,一般来说足够用了。project 创建之后就可以用 svn client 往里面添加内容了;另外 google code 也允许把一个已经存在的 svn repository 用 svnsync 给 upload 上去,着实方便。唯一一点不足之处是,project 里面的的所有东西都是 open 的,任何人都能够 svn checkout,不爽,一点隐私都没有!看来目前俺还不能充分利用 Google Code 的这个 service。:-(
Posted by
Display Name
-
2:29 PM
0
comments
Labels: Google, Version Control
svnsync
From: http://svn.collab.net/repos/svn/trunk/notes/svnsync.txt
==== What Is It? ====
svnsync is a tool for creating and maintaining read-only mirrors of
subversion repositories. It works by replaying commits that occurred
in one repository and committing it into another.
==== Basic Setup ====
First, you need to create your destination repository:
$ svnadmin create dest
Because svnsync uses revprops to keep track of bookkeeping information
(and because it copies revprops from the source to the destination)
it needs to be able to change revprops on your destination repository.
To do this you'll need to set up a pre-revprop-change hook script that
lets the user you'll run svnsync as make arbitrary propchanges.
$ cat <<'EOF' > dest/hooks/pre-revprop-change
#!/bin/sh
USER="$3"
if [ "$USER" = "svnsync" ]; then exit 0; fi
echo "Only the svnsync user can change revprops" >&2
exit 1
EOF
$ chmod +x dest/hooks/pre-revprop-change
$ svnsync init --username svnsync file://`pwd`/dest \
http://svn.example.org/source/repos
Copied properties for revision 0
$
Note that the arguments to 'svnsync init' are two arbitrary repository
URLs. The first is the destination, which must be empty, and the second
is the source.
Now you can just run the 'svnsync sync' command to synchronize pending
revisions. This will copy any revisions that exist in the source repos
but don't exist in the destination repos.
$ svnsync sync file://`pwd`/dest
Committed revision 1.
Copied properties for revision 1.
Committed revision 2.
Copied properties for revision 2.
Committed revision 3.
Copied properties for revision 3.
...
==== Locks ====
If you kill a sync while it's occurring there's a chance that it might
leave the repository "locked". svnsync ensures that only one svnsync
process is copying data into a given destination repository at a time
by creating a svn:sync-lock revprop on revision zero of the destination
repository. If that property is there, but you're sure no svnsync is
actually running, you can unlock the repository by deleting that revprop.
$ svn pdel --revprop -r 0 svn:sync-lock file://`pwd`/dest
==== FAQ ====
Q: So what can I do with this thing anyway?
A: Well, anything that's read-only. As long as you don't commit changes
to the destination repository you're all set. This means destination
repositories are good for providing offsite mirrors, read-only mirrors,
etc.
Q: What if I want to check out from a mirror, but commit to the master?
A: That's possible, but requires some gymnastics. You see, each repository
has its own UUID, which is stored in the working copy, so if you check
out from the mirror, and then do a 'svn switch --relocate' to point to
the master it'll error out. To make this work you need to make sure that
the mirrors have the same UUID as the master. You can set a repository
UUID via the following technique:
$ cat - <
Posted by
Display Name
-
2:19 PM
0
comments
Labels: Version Control
vim 中编辑不同编码的文件时需要注意的一些地方 - ChinaUnix
vim编码方面的基础知识:
- 存在3个变量:
fileencoding—-该选项是vim写入文件时采用的编码类型。
termencoding—-该选项代表输出到客户终端(Term)采用的编码类型。
- 此3个变量的默认值:
fileencoding—-vim打开文件时自动辨认其编码,fileencoding就为辨认的值。为空则保存文件时采用encoding的编码,如果没有修改encoding,那值就是系统当前locale了。
termencoding—-默认空值,也就是输出到终端不进行编码转换。
由此可见,编辑不同编码文件需要注意的地方不仅仅是这3个变量,还有系统当前locale和文件本身编码以及自动编码识别、客户运行vim的终端所使用的编码类型3个关键点,这3个关键点影响着3个变量的设定。
如果有人问:为什么我用vim打开中文文档的时候出现乱码?
答案是不确定的,原因上面已经讲了,不搞清楚这3个关键点和这3个变量的设定值,出现乱码是正常的,倒是不出现乱码那反倒是凑巧的。
再来看一下常见情况下这三个关键点的值以及在这种情况下这3个变量的值:
- locale—-目前大部分Linux系统已经将utf-8作为默认locale了,不过也有可能不是,例如有些系统使用中文locale zh_CN.GB18030。在locale为utf-8的情况下,启动vim后encoding将会设置为utf-8,这是兼容性最好的方式,因为内部 处理使用utf-8的话,无论外部存储编码为何都可以进行无缺损转换。locale决定了vim内部处理数据的编码,也就是encoding。
- 文件的编码以及自动编码识别—-这方面牵扯到各种编码的规则,就不一一细讲了。但需要明白的是,文件编码类型并不是保存在文件内的,也就是说没有任何 描述性的字段来记录文档是何种编码类型的。因此我们在编辑文档的时候,要么必须知道这文档保存时是以什么编码保存的,要么通过另外的一些手段来断定编码类 型,这另外的手段,就是通过某些编码的码表特征来断定,例如每个字符占用的字节数,每个字符的ascii值是否都大于某个字段来断定这个文件属于何种编 码。这种方式vim也使用了,这就是vim的自动编码识别机制了。但这种机制由于编码各式各样,不可能每种编码都有显著的特征来辨别,所以是不可能 100%准确的。对于我们GB2312编码,由于其中文是使用了2个acsii值高于127的字符组成汉字字符的,因此不可能把gb2312编码的文件与 latin1编码区分开来,因此自动识别编码的机制对于gb2312是不成功的,它只会将文件辨识为latin1编码。此问题同样出现在gbk,big5 上等。因此我们在编辑此类文档时,需要手工设定encoding和fileencoding。如果文档编码为utf-8时,一般vim都能自动识别正确的 编码。
- 客户运行vim的终端所使用的编码类型—-同第二条一样,这也是一个比较难以断定的关键点。第二个关键点决定着从文件读取内容和写入内容到文件时使用 的编码,而此关键点则决定vim输出内容到终端时使用的编码,如果此编码类型和终端认为它收到的数据的编码类型不同,则又会产生乱码问题。在linux本 地X环境下,一般终端都认为其接收的数据的编码类型和系统locale类型相符,因此不需关心此方面是否存在问题。但如果牵涉到远程终端,例如ssh登录 服务器,则问题就有可能出现了。例如从1台locale为GB2310的系统(称作客户机)ssh到locale为utf-8的系统(称作服务器)并开启 vim编辑文档,在不加任何改动的情况下,服务器返回的数据为utf-8的,但客户机认为服务器返回的数据是gb2312的,按照gb2312来解释数 据,则肯定就是乱码了,这时就需要设置termencoding为gb2312来解决这个问题。此问题更多出现在我们的windows desktop机远程ssh登录服务器的情况下,这里牵扯到不同系统的编码转换问题。所以又与windows本身以及ssh客户端有很大相关性。在 windows下存在两种编码类型的软件,一种是本身就为unicode编码方式编写的软件,一种是ansi软件,也就是程序处理数据直接采用字节流,不 关心编码。前一种程序可以在任何语言的windows上正确显示多国语言,而后一种则编写在何种语言的系统上则只能在何种语言的系统上显示正确的文字。对 于这两种类型的程序,我们需要区别对待。以ssh客户端为例,我们使用的putty是unicode软件,而secure CRT则是ansi 软件。对于前者,我们要正确处理中文,只要保证vim输出到终端的编码为utf-8即可,就是termencoding=utf-8。但对于后者,一方面 我们要确认我们的windows系统默认代码页为cp936(中文windows默认值),另一方面要确认vim设置的termencoding= cp936。
最后来看看处理中文文档最典型的几种情况和设置方式:
- 系统locale是utf-8(很多linux系统默认的locale形式),编辑的文档是GB2312或GBK形式的(Windows记事本默认保 存形式,大部分编辑器也默认保存为这个形式,所以最常见),终端类型utf-8(也就是假定客户端是putty类的unicode软件)则vim打开文档后,encoding=utf-8(locale决定的),fileencoding=latin1(自动编码判断机制不准导致的),termencoding=空(默认无需转换term编码),显示文件为乱码。
- 解决方案 1
首先要修正fileencoding为cp936或者euc-cn(二者一样的,只不过叫法不同),注意修正的方法不是:set fileencoding=cp936,这只是将文件保存为cp936,正确的方法是重新以cp936的编码方式加载文件为:edit ++enc=cp936,可以简写为:e ++enc=cp936。
- 解决方案2
临时改变vim运行的locale环境,方法是以LANG=zh_CN vim abc.txt的方式来启动vim,则此时encoding=euc-cn(locale决定的),fileencoding=空(此locale下文件 编码自动判别功能不启用,所以fileencoding为文件本身编码方式不变,也就是euc-cn),termencoding=空(默认值,为空则等 于encoding)此时还是乱码的,因为我们的ssh终端认为接受的数据为utf-8,但vim发送数据为euc-cn,所以还是不对。此时再用命令: set termencoding=utf-8将终端数据输出为utf-8,则显示正常。
- 情况与前面基本相同,只是使用的ssh软件为secure CRT类ansi类软件。
vim打开文档后,encoding=utf-8(locale决定的),fileencoding=latin1(自动编码判断机制不准导致的),termencoding=空(默认无需转换term编码),显示文件为乱码。
- 解决方案 1
- 解决方案 2
与上面方案2类似,不过最后一步修改termencoding省略即可,在此情况下需要的修改最少,只要以locale为zh_CN开启 vim,则encoding=euc-cn,fileencoding和termencoding都为空即为encoding的值,是最理想的一种情况。
可见理解这3个关键点和3个参数的意义,对于编码问题有很大助力,以后就可以随心所欲的处理文档了,同时不仅仅是应用于vim,在其他需要编码转换的环境里,都可以应用类似的思路来处理问题解决问题。
最后推荐一款功能强大的windows下的ssh客户端—-xshell,它具有类似secure CRT一样的多tab 的ssh窗口的能力,但最为方便的是这款工具还有改变Term编码的功能,这样我们就可以不用频繁调整termencoding,只需在ssh软件里切换 编码即可,这是我用过的最为方便的ssh工具。它是商业软件,但非注册用户使用没有任何限制,只是30天试用期超出后会每次启动都提示注册,对于功能没有 丝毫影响。
Posted by
Display Name
-
11:41 AM
0
comments
Labels: Vim
Controlling your locale with environment variables
Controlling your locale with environment variables
By Bill Poser on May 01, 2006 (8:00:00 AM)You choose your locale by setting environment variables. Different variables control different things. LC_MESSAGES determines the language and encoding of messages as well as of labels in GUI components if they use GNU gettext or one of its relatives to obtain translations. A few programs obtain translations in other ways and may not be affected by LC_MESSAGES.
LC_CTYPE defines character classes, which are named sets of characters used by a variety of programs, especially regular expression matchers. In programs such as grep that use character classes like [:alnum:], class membership varies with locale. If the writing system distinguishes upper- and lower-case letters, LC_CTYPE specifies the relationship between the two.
Sort order is controlled by LC_COLLATE. Sort orders can differ within the same writing system. In ASCII order, the upper-case letters as a group precede the lower-case letters: A B C ... a b c.... In French, upper-case letters immediately follow their lower-case counterparts: a A b B c C.... In some other locales upper-case letters immediately precede their lower-case counterparts: A a B b C c....
Sort order affects not only sorting but character ranges in regular expressions. In ASCII order, the range expression [A-Z] stands for the 26 upper-case letters. That is because the expression stands for the characters starting with A and ending with Z. In ASCII, the upper-case letters form a contiguous block of 26 running from A to Z. However, in the French locale the letters starting with A and ending with Z consist of all of the letters except for lower-case a.
The format of times and dates is controlled by LC_TIME. In American English, the date command produces results like this:
Fri Apr 14 20:33:28 PDT 2006
In Catalan, the language is different but the format is the same:
dv abr 14 20:33:49 PDT 2006
But in Japanese the year comes first, then the month, then the day, then the day of the week, and finally the time:
2006年 4月 14日 金曜日 20:34:42 PDT
The format of numbers is determined by LC_NUMERIC. In American English, a period serves as decimal point and commas break the integers into groups of three:
652,314,159.278
In German, the grouping is the same but the roles of period and comma are reversed:
652.314.159,278
In Hindi the period and comma play the same roles as in American English, but the integers are broken into groups of two, except for the hundreds downward, which form a group of three:
65,23,14,159.278
The format of amounts of money is controlled by LC_MONETARY. In addition to the formatting of the numbers, this environment variable specifies the symbol for the unit of currency and things like how negative values are written.
Additional variables include:
- LC_PAPER: paper size
- LC_NAME: personal name format
- LC_ADDRESS: address format
- LC_TELEPHONE: telephone number format
- LC_MEASUREMENT: measurement units
The environment variable hierarchy
Most of the time you'll want to set all of these variables to the same value, but occasionally it makes sense to use different values. For example, if you want your interface language to be English but are sorting French data, you could set LC_MESSAGES to en_US
but LC_COLLATE to fr_FR
.
When you don't want to use different values, it isn't necessary to set all of the variables individually. Instead, you can set LC_ALL or LANG. When a program looks at the environment variables to determine what locale to use, it follows the following procedure:
- If the LC_ALL environment variable is defined and is not null, its value is used.
- If the appropriate component-specific environment variable -- e.g. LC_COLLATE -- is set and non-null, its value is used.
- If the LANG environment variable is defined and is not null, its value is used.
- If the LANG environment variable is not set or is null, an implementation-dependent default locale is used.
Notice that this means that if you want to use different locales for different purposes you should unset LC_ALL.
There is one further environment variable, LANGUAGE, which is used only by GNU gettext, the system that provides translations of messages for many programs. Unlike the others, this variable can be assigned multiple locales separated by colons. The locales are tried in order until a message catalog is found. For example, the specification sv_SE:nn_NO:de_DE
indicates that the user prefers Swedish, to use Norwegian if Swedish is not available, and to use German if Norwegian is not available. If defined, LANGUAGE takes precedence over LC_ALL, LC_MESSAGES, and LANG.
Locale names
Locale names take the form:
language(_territory)(.encoding)(@modifier)
The only obligatory part is the language code, such as en
for English. The same language may be used in different ways in different countries, so locale names commonly include a territory code as second component. Thus, fr_FR
is the locale for French in France, fr_CA
for French in Canada, and en_CA
the locale for English in Canada. An encoding may also be specified. English will by default be encoded in ASCII, but en_US.UTF-8
specifies American English in the UTF-8 Unicode encoding. Language codes are usually taken from the list of two-letter codes defined in ISO-639-1, country codes from the two-letter codes defined in ISO-3166-1.
The modifier you are most likely to see is euro
, which is used for locales using the euro currency where the original locale definition was created before the introduction of the euro in the European Union. For example, es_ES@euro
is the current Spanish locale, while es_ES
is the pre-euro locale.
A few special locales do not follow these naming conventions. The POSIX
locale, also known as the C
locale, sets up a traditional Unix environment, with the ASCII encoding, POSIX character classes, and American English time, date, number, and monetary formats. If things seem off when you use programs such as sort and grep, the problem may be that you are using a locale that defines a different sort order or character classes from what you are used to. Setting your locale to POSIX
may set things right.
To find out what your current locale is, use the locale
command with no arguments. It will print the values of all of the relevant environment variables except for LANGUAGE. locale charmap
prints the name of the current encoding. To find out what locales are available, type locale -a
. To find out what encodings are available, type locale -m
.
Installing locales
You may find that the locale you need is not installed on your machine. If so, you may be able to install it yourself. Locale definitions are stored in plain ASCII files that follow a special format described in the locale(5) man page. How to write your own locale definitions would be fodder for a whole other article, but you can find quite a few locale definitions in localedata/locales in the glibc distribution directory, in files whose names are the same as the locale name, e.g. zu_ZA for Zulu in South Africa.
To install a locale file, use localedef
. This command installs Zulu:
localedef -i zu_ZA -f ../charmaps/UTF-8 zu_ZA
The last argument here is the locale name. The argument to the -i
flag is the locale definition file. The argument to the -f
flag is the appropriate character set definition file, most frequently UTF-8.
Many languages do not have a two-letter code, so three-letter codes from ISO-639-2 are increasingly seeing use. Similarly, three-letter country codes defined in ISO-3166-2 are on the horizon.
Another development is the Common Locale Data Repository project sponsored by the Unicode Consortium. Recognizing that it is inefficient for different operating systems and developers to compile localization information and store it in different formats, the CLDR project is developing a new, XML-based, cross-platform system for storing locale information which is already in use by Java and some other programs.
Posted by
Display Name
-
11:19 AM
0
comments
Labels: *nix, Shell/Scripting
2007-07-05
[gcc] -rdynamic
> BTW, why is it that the -soname option and the -rdynamic
> option are not in the man page for gcc?
Essentially because they are really linker options, passed by gcc down to
ld. This is strictly true for -soname: the comma-separated list
following -Wl option of gcc is passed directly to the linker, after
replacing the commas with spaces (you can see this if you gcc -v). No
other processing is done on it by the compiler proper.
The -rdynamic option is slightly different. It seems to have been
introduced as a high-level interface to the linker, to (a) force the
allocation of a global symbol table in the final executable, even if it's
not strictly needed, and (b) cause the inclusion of the global symbols in
that symbol table.
- Under linux, gcc interprets it by setting the "-export-dynamic" option for ld, which has that effect, according to the linux ld manpage.
- Under IRIX it's ignored, and the program's happy as a clam.
- Under SunOS-4.1, gcc interprets it by setting the -dc -dp options for ld, which again forces the allocation of the symbol table in the code produced (see ld(1) on a Sun).
Wonder if we should mailbomb gcc-bug@gnu.org until they fix their man/info
pages ;-)
-- From http://www.cim.mcgill.ca/~franco/OpSys-304-427/messages/node59.html
Posted by
Display Name
-
3:10 PM
0
comments
Hacking HelloWorld
HackingHelloWorld (PDF)
- From Jim Huang (黃敬群 / jserv)
[Keywords: hello world]
Posted by
Display Name
-
1:52 PM
0
comments
修改常量字符串导致的 segmentation fault
昨天一同事遇到的问题, 帮他解决了一下, 备忘 :-)
$ cat foo.c
#include
int main(int argc, char *argv[])
{
char *s = "foo;bar;car";
strtok(s, ";");
return 0;
}
$ gcc foo.c
$ ./a.out
Segmentation fault
$ gcc -S foo.c
$ cat foo.s
.file "foo.c"
.section .rodata ; read only data (?)
.LC0:
.string "foo;bar;car"
.LC1:
.string ";"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
andl $-16, %esp
movl $0, %eax
addl $15, %eax
addl $15, %eax
shrl $4, %eax
sall $4, %eax
subl %eax, %esp
movl $.LC0, -4(%ebp)
movl $.LC1, 4(%esp)
movl -4(%ebp), %eax
movl %eax, (%esp)
call strtok
movl $0, %eax
leave
ret
.size main, .-main
.ident "GCC: (GNU) 4.0.3 (Ubuntu 4.0.3-1ubuntu5)"
.section .note.GNU-stack,"",@progbits
$
Posted by
Display Name
-
9:42 AM
0
comments
svn: Not authorised to open root of edit operation
如果启用了 svn 的 path-based access control, svnserve.conf 中的 anon-access 要设成 none 才行:
$ cat svnserve.conf
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = My Realm
$ cat authz
[/]
admin = rw
[/project1]
guest = r
$
Posted by
Display Name
-
9:24 AM
0
comments
Labels: Version Control
2007-07-04
crypt(): DES or MD5
DES 算法的 crypt() 函数最多只支持 8 个字符的 password, 超过 8 个字符的部分被忽略掉了; 而 MD5 算法的 crypt() 则没有这个限制. 因此现在的 passwd 命令一般用 MD5 加密方式.
From crypt's man page:
=====================
The glibc2 version of this function has the following additional features. If salt is a character string starting with the three characters "$1$" followed by at most eight characters, and optionally terminated by "$", then instead of using the DES machine, the glibc crypt function uses an MD5-based algorithm, and outputs up to 34 bytes, namely "$1$
Posted by
Display Name
-
10:46 AM
0
comments
MacPorts: Installed ports
autoconf
automake
bash
cmake
colordiff
expect
findutils
gawk
gnutar
gsed
lftp
libtool
subversion
tcl
vim
watch
wget
wireshark
Posted by
Display Name
-
10:12 AM
0
comments
Labels: Apple, Tcl/Expect
Bash: COLUMNS and LINES not set on startup
Mac OS X (10.4) 上默认安装的 bash 还是经典的 2.05b 版, 不如 3.x 强大. 自己下载编译了 3.2.17 编译安装, 一切顺利. 但是启动 bash 3.2.17 后发现 COLUMNS 和 LINES 这两个变量没有定义, 不过在改变终端窗口大小后就有定义了, 有些麻烦, 只好在 bashrc 里面给 bash 发一个 SIGWINCH 信号:
Posted by
Display Name
-
9:54 AM
0
comments
Labels: Apple, Shell/Scripting
2007-07-01
MacPorts: The port command
- port selfupdate
- port search subversion
- port install bash
- port variants vim
- port install vim +perl +cscope subversion +no_bdb
- port cat vim
- port deactivate vim @7.1.002_0
- port upgrade vim
- port upgrade installed
- port info bash
- port deps subversion
- port dependents readline
- port outdated
- ... ...
Posted by
Display Name
-
1:18 PM
0
comments
Nice review - but what about the OTHER groups which George may be a member of? You state "I happen to know that George is in only two groups: handmodels and george" - but what if George was an administrative user? In this case, he would also be a member of the "admin", "appserveradm" and "appserverusr" groups.
Any suggestions on how to scan ALL potential locations for a given shortname entry, to ensure you catch them all?
Try this :
dscl . -list /groups GroupMembership
It will give you all the groups with their members in a second column, you can then try to grep...
There is something I'd like to add, don't forget to delete the password files in /var/db/shadow/hash
% id -G -n george
Take a look at
http://www.ubergeeks.com/~jmalone/software/
Mac OS X command line user tools
These are wrapper scripts around the netinfo commands that mimic the useradd, userdel, groupadd, groupdel commands of other *nix operating systems. Still under development, but quite useful here where I work.
PLEASE let me know about any bugs/improvements you find/think of.
* niuseradd
* niuserdel
* nigroupadd
* nigroupdel