About This Blog

This is Chunhao's Blog

I'm writing something about life and technology here. As a practice of English writing.

My Chinese Blog: http://blog.chunhao.net

My Chinese Page: http://chunhao.net/index-cn.html

Subscribe

The books I’m reading

The items I’m interested in

License

12 June 2009 - 20:14Are Your Fingers Long Enough to Use Vim?

Note: I wrote this post just for fun. Please don’t take it seriously. Thank you! :)

Which editor are you using, Vim or Emacs? And why?

Next time, when you are arguing with other people about which editor is better and trying to persuade others to use your favorite editor, just forget it. If you believe everything is in destiny, it is not an exception for the editor you choose. The choice is written on your fingers.

Several days ago, I learnt from Mike that the choice between using Vim or Emacs depends on your fingers. As he figured out, people have longer fingers prefer to use Vim, while people have shorter fingers prefer to use Emacs. It is amazing, but reasonable.

Read more…

11 Comments | Tags: Software, linux, vim

4 June 2009 - 0:59Which email client are you using?

What can you do for killing time? Maybe you could figure out what email clients your contacts are using. It’s funny.

Most people prefer webmail, especially Gmail. Webmail is very easy to use and does not require much configuration. Gmail is the most wonderful webmail. It groups messages by threads and it has a powerful searching tool. You can easily find out what you want from the mass.

However, one drawback of webmail is that you cannot access your mail off-line. Although Gmail started to support off-line email recently, I still think that keeping the emails in my local storage is safe and reliable. Moreover, an email client is generally much more customizable than webmail. So, I am using Evolution, which is the most powerful and standard email client in Linux, to receive and send email everyday.

Read more…

1 Comment | Tags: Software, linux

21 May 2009 - 19:39Tools for Reading Sources

Hacking is a good method of learning. And the pre-stage of hacking is reading the source code. You might have this experience: facing a large amount of source code (generally dozens of files), you don’t know how to start, or you even don’t know how to read them. A good tool is very helpful for reading code. It can facilitate your understanding of the code and help you find out the things you want as soon as possible. I will introduce you some wonderful tools of browsing sources.

For me, the must-have feathers of a source browsing tool should be:

  1. Syntax highlighting
  2. Friendly user interface
  3. Identifier and function search

Read more…

No Comments | Tags: Software, linux, programming

26 April 2009 - 23:21Burning Video DVD on Ubuntu

Burning video DVD is harder than you think. It involves transcoding, subtitles, burning and other complicated things. Each step may not work for you, let alone on Ubuntu!

I just created my first video DVD. My experience may help you get less trouble on burning your video DVD on Ubuntu/Linux.

Most DVD videos are encoded in MPEG-2 format. So, if your original video is not encoded into MPEG-2, the first thing you need to do is to transcode it into MPEG-2. There are lots of powerful tools to handle it, such as ffmpeg and mencoder. They are command-line tools. If you are a crazy fan of command line, you definitely should try them. However, the command line arguments will generally be 10 lines! If you cannot handle them(like me), just try some GUI tools.

The first option is Avidemux. It’s powerful and easy to use. However, its H264 support is poor. When I tried to transcode a H264 video into MPEG-2, it crashed every time. Maybe it works fine with other format, but I have no chances to take a try.

Read more…

No Comments | Tags: linux

24 February 2009 - 0:12How to write an auto-downloading script

如何写一个自动下载的脚本?

用Linux有一个很好的地方就是你可以很方便地让计算机为你做体力活。当然,前提是你要了解Linux的思维方式。下面就是一个活生生的例子,大家可以看看用Linux是怎么做事情的。

如果你喜欢听评书,这里是个不错的地方。这个网站有很多评书,还有百家讲坛,甚至有声的金庸小说。上面的东西不光可以在线听,而且都可以免费下载,不用注册。但是,只能一个链接一个链接地下载。例如,如果想下载《大唐惊雷》第1回,就要进入一个页面,然后点下载;要下载第2回,就要进入另一个页面,然后再点下载。这样,就无法批量下载一整部评书了。

如果你用Windows,那么你要么人肉点击这些链接,一个一个地下载(可能有100+回);要么就用C或者Java写一个程序自动下载,前提是你要懂网络编程的细节。

下面,我就说一说在Linux下如何用Shell写一个自动下载脚本:

Read more…

3 Comments | Tags: linux, programming

13 February 2009 - 14:08How to synchronize with SSH

I will share my experience in synchronizing files with SSH here. Following are demonstrated by synchronizing Dokuwiki. Of course, you can synchronize everything as you like.

The wiki I used in my homepage is Dokuwiki. The most great feature is that it does not require database connection. It’s very convenience for personal usage.

I have two Dokuwiki maintained. One is located in localhost, another in the webserver. I always edit the pages on localhost, and synchronize them to the webserver at times. Since Dokuwiki is totally PHP based, without database such as MySQL, I only need to synchronize some files.

All the changes on wiki are reflected on the folder “data” in your Dokuwiki path. So every time, I only need to synchronize this folder.

The best way to communicate with webserver is SSH. Fortunately, my webserver Godaddy support SSH access. Another thing need to concern is synchronizer. Here I use Unison. The best description of Unison comes from it’s the author of this software:

Read more…

No Comments | Tags: Software, linux

28 December 2008 - 23:02How To Write a Spamming Robot

如何写一个灌水机?

摘要:本文介绍了利用Wget在Linux环境中写灌水机的大致方法。

常在论坛灌水的人都想快速而省力地增加自己的帖数,这就是为什么很多人想要一个灌水机的原因。其实,灌水机的作用远不止与此,你可以稍加修改让它可以进行批量操作(例如版主发米);还可以自动顶帖,让你的帖子常居首页;还可以自动抢沙发……总之,只要是体力活儿,它都可以干。

如果你是Windows的用户,那对不起了,你可以根据本文来研究移植到Windows下的方法,但我通常不会回答任何关于这方面的询问。如果你是Linux用户,那么恭喜你,我们有共同学习研究的机会,我很乐意与你一起研究本文所讲的方法。

下面开始正题:

需要工具:

Firefox

–需要插件: Live HTTP headers, Export Cookies(Firefox 3用户需要), Firebug(非必要)

Wget:一般Linux默认都会安装的

就这么多,先说一下灌水机的原理。灌水机就是不借助浏览器发送一个包含数据的HTTP请求,从而达到自动发帖的目的。很多人喜欢用Perl写灌水机,因为Perl能很容易地发送HTTP请求。但既然有现成的Wget可以实现发送HTTP请求,为什么还要reinvent the wheel呢?

Read more…

No Comments | Tags: linux

14 September 2008 - 21:30Upgrading to Hardy

Upgrading is evil.

Although sometimes software need upgrading, in order to fix bugs, or add new supporting, when you find bugs, there are only two things you can do for it. The first is fixing it yourself, while the second is waiting for upgrade. On the other hand, you might find some bugs appears after you upgrading a software, which worked well before. It’s hard to tell why we are willing to upgrade it. Just for upgrading?

Almost 5 months have passed since Ubuntu 8.04 “Hardy Heron” had released. And even “Intrepid Ibex” is coming within one month. I, should like changing, still used “Gutsy” in my laptop. There are several reasons why I keep using it. It’s hard to make all parts of my laptop Dell 1420 work well under Ubuntu 7.10, including the sound card, wireless, and microphone. Thank Dell Ubuntu Wiki a lot to provide patches to fix these issues. About 5 months ago, when “Hardy” was just released, the entry “Known Issues” in Dell Ubuntu Wiki is empty. I cannot put myself in hell to try the new release. Fortunately, issues have be found and fixed now for “Hardy”. I can upgrade my system safely–at least in image.

Another thing is that I have patched something on the kernel, such as VBox. I don’t want to repatch them after upgrading. And I was afraid that some software may don’t work after upgrading to “Hardy”. I have no time and don’t want to reinstall and reconfig them. Maybe a small issue can cause the damage of entire system. Then, I have to reinstall everything, and encounter all kinds of problems. A good thing is that I have my /home located in a separate partition. If my system is down, at least I can retain the things under my home folder, which are very very important.

I have one thousand reasons for not upgrading. However, how could you image that the software you are about to install depend on a newer version of “libglib” or “libc6″? Pidgin 2.5 support off-line messages for MSN, which I desired for a long time. When I tried to install it, it told me that it need a newer version of “libglib”. That meant I have to upgrade almost everything. Sounds like hell. Finally, I decided to do upgrade for Ubuntu.

The whole process took me an afternoon. I followed the official guide. It was not very hard. After downloading everything, dialogues popped up one after another. After I handled all of them, upgrading is over. The following thing is following the Dell Ubuntu Wiki to fix issues. At last, everything seems work fine, including microphone.

The last thing is installing Pidgin 2.5, for which, seems, the whole upgrading is processing.

2 Comments | Tags: linux

13 September 2008 - 0:19Command & Conquer

首先,这篇日志和技术有关,应该用英文写的,但里面夹杂了一些中文的元素,就写成中文了。

这个题目,作为游戏的名字就是“命令与征服”,作为Full Circle中文杂志的一个栏目名,就是“决胜命令行”。

人们总在做关于图形界面与命令行的争论,其实,二者各有优缺点。图形界面总能给人一种直观的感受,在一定程度上提高工作效率。但是,任何事都有它的局限性。如果画一个圆,里面的空间代表图形界面所擅长的工作,那么,这个圆环外面的整个空间都应该属于命令行!

命令行也有它的局限性,用手敲命令的时间有时并不一定比把鼠标移到某个菜单并点一下快。而且,尤其是对于非英语国家的人来说,了解那么多的命令和参数并不是一件容易的事情,尽管man命令可以帮助我们很多。

命令行的一个杀手应用就是批处理。如果你需要对几十个,甚至几百个文件进行类似的操作,摆在你面前的有三条路:1. 等专门的软件被写出来。2. 自己纯手工对这几百个文件处理。3.动手写个脚本。

在Linux世界,如果你要完成一项工作,有三条法则:

  1. 如果有现成的软件,使用它。
  2. 如果需要使用几个软件来完成,用管道或其他东西把他们连接起来。
  3. 否则,自己写程序完成它。

使用命令行,使用脚本,应该是介于第二条和第三条之间。脚本是用于把几个程序连接起来的工具,当然,也算是自己写的一个程序。

在批处理中,我们可以通过脚本,通过定义的一些变量,甚至一些循环、判断语句来很轻松地完成工作。当然,这一些的基础就是命令行,脚本很难通过图形界面和其他程序交互。当然,也有一些在命令行中生成GUI的工具,例如zenity

大概半年前,我做史记的电子书。其中,一个文件夹下的文件是这样的:

Read more…

No Comments | Tags: linux, programming

16 July 2008 - 23:56Ubuntu with parents

几乎每次回家,都要花很大的精力整理家里的台式机。这次回来也不例外,卡巴斯机的病毒库过期了;倒是没有发现病毒,但机子里的应用程序却被卡巴斯机杀了个差不多;而且每次开机Windows都提醒我是盗版用户的受害者(我记得我把自动更新关了)。要是以前,我会忙不跌得杀毒,重装系统,然后配置得和原来一样。可是现在,我却一点动机都没有。

第一个原因可能就是盗版的问题,我自己的笔记本上已经没有盗版软件了,包括操作系统,要是在家里装个盗版的操作系统,多少有点不愿意。手头倒是有正版的XP,可那是英文的,给父母用又不现实。

第二个原因可能是安全的原因,在Windows中,无论用多高级的杀毒软件,无论多仔细地配置组策略,它的系统文件结构就已经决定了它的不安全。况且,Microsoft都承认了Windows NT的安全是不可能的。反反复复得做重复工作,谁都不愿意。

以前也想过装Linux,但总有一些顾虑。首先就是和MS Word交流的问题,如果用OpenOffice生成的文档用Word打开的话可能会造成格式紊乱,而现在单位用得都是MS Word,WPS之流的软件,排版的格式是个大问题。现在唯一可行的就是教会父母格式化排版,而不用空格排版,然后生成PDF。

还有就是游戏,父母喜欢玩纸牌,连连看,老爸还喜欢玩QQ游戏的围棋。其他都好说,Linux也有很优秀的围棋软件,比如gnugo,qgo。也有很好的围棋游戏平台,比如蓝迪。这些到时候都可以尝试一下。

安全自然没问题了,杀毒软件自然都不用考虑了。 :)

昨晚,下载了Ubuntu 8.04 LiveDVD。刻盘,安装。不得不提的是,用LiveDVD安装是非常方便的,一但选择了中文,字体、输入法统统就已经配置好了,系统用的是文泉驿字体,效果不错,中英文衔接也很好。很高兴看到Ubuntu 8.04有这么大的进步,毕竟Ubuntu已经不是两年前的Ubuntu了,想当年光是字体就要配好久。

在“硬件驱动”里把显卡钩上,装好显卡驱动后,发现分辨率变得很难看了,改了xorg.conf后就好了。

然后就是装连连看Linux版。下载好源代码后编译安装,解决了一些依赖问题后一切顺利。然而,这个连连看是的菜单,界面都是英文版的,今天老爸玩的时候也感到很不方便。没关系,开源软件的好处这时候就体现出来了,打开源代码,自己手工汉化之后重新编译,安装。现在玩起来就顺手多了。

目前的进展就是这些了,以后准备把围棋搞上马,然后在根据需求安装点有用的软件,实在不行就wine。 :)

根据我用了这么久Ubuntu的经验以及对Linux的了解,我认为Linux是比Windows更适合新手的。它很重要的一个优点就是它的目录结构。它不像Windows那样有一个又一个“盘”,而是把用户所有的文件都集中到一个目录下,这样更直观和易于管理。

用我现在的观点审视我原来使用电脑的方式,发现原来自己真的很土,一个160G的硬盘竟然都分到H盘,而且居然把应用程序都装到了其他盘上,弄得现在想整理一下都很尴尬。或许是现在都电脑有了更深的认识吧,如果现在让我装Windows系统,我只分两个盘,C和D,再大的硬盘也是这样。其实分区和建立文件夹没有太大的区别。有机会我再写篇文章探讨这两种文件管理方式的好坏。

如果还想更多地了解Linux到底比Windows好在哪里,可以参考这里

1 Comment | Tags: Thinking about life, linux

Page 1 of 212»