5/18/2008

地震求生的空间选择 之 Open/Closed原则

PLEASE HEED THIS ARTICLE AT YOUR OWN RISK!

今日上Google Reader,照例先看看好友有什么好文推荐,果然Vanjet 这小子有一篇题为:Earthquake Survival 101 的分享。这篇文章不仅图文并茂,而且非常合时宜;概括起来就是一句话:在地震时如何进行求生空间的选择。但是美中不足的是该文只告诉你:什么样的求生空间 是更安全或更不安全的,而对于处在千奇百怪、千变万化的现实条件下,并且受灾时人们多少会有一定程度的因恐惧而来的心理和行为的慌乱,在这样的情况下我们 应该如何选择,该文并未涉及。但是,我们需要更简单,更具一般性的原则,使我们能够在面临危机时更简单、更高效得作出更好的选择,这也是我在看完 Earthquake Survival 101 全文后的一个下意识的考虑,但是这个问题有答案吗?,答案又是什么呢?。

经过片刻的思考,我想我找到答案了,但是具有讽刺意味的是,寻找答案的过程和答案本身相对于寻找诉说答案的方式和诉说答案的过程,却又显得那么的微不足道:D 答案就是:Bertrand MeyerOpen/Closed 原则。Open/Closed 原则是Bertrand Meyer 在其的鸿篇巨制Object-Oriented Software Construction 中隐含的一个理论,较为准确的说就是:The methods, modules, classes should be open for extension and closed for modification;换句话说就是:我们必须尽可能的在不改变现有软件系统的前题下,以通过扩展软件系统的处理能力的方式来设计软件系统。但是,如 何将Open/Closed 原则应用于地震求生的空间选择问题呢?让我们先来回顾下 Earthquake Survival 101 第一幅图所介绍的场景,并且思考:为什么躲在床与床边沙发的空档处会比直接躲在床底下具有更高的安全性呢?对于上述问题,尝试性地分析:虽然躲在床底下会 在一定程度上封闭(保护)你的身体,但是同时也封闭(阻碍)了你被及时救出的可能;而躲在床与床边沙发的空档处,相应的由于你身体的横向高度同时低于床和 床边沙发的高度,因此你的身体在一定程度上也是被封闭(保护)的,并且同时也开放(增进)了你被及时救出的可能。至此,将Open/Closed原则应用 于地震求生的空间选择问题的答案就是:选择对救援是开放的,并且对身体伤害是封闭的空间。

The end: Open for life surviving and closed for body's modification.

5/14/2008

Google Reader 之 瞒天过海

Google Reader是一个很棒的RSS阅读器,这点毋庸置疑。在此,当然我不会那么无聊地告诉你:Google Reader很棒,赶快改变你现在低效的在线阅读习惯,扔掉蹩脚的其它RSS阅读器...!
我只想告诉你:如果你想要,Google Reader当然不会不给你。如果你不想要,Google Reader当然更不会说:I want u!

你只需要做一件简单的事情:在访问Google Reader时将默认的http://改成https:// 不要问我:Why?,我唯一能说的是,Google Reader为你处理了一切,当然,前提是:你想要 !

Note: There is a whitespace between the last two symbols that on the above sentence.

5/03/2008

How to partition a USB Flash Drive

Goals:
Partitioning a USB flash drive into 2 partitions. One used to general storage task and it will be supported on both the Windows and Linux; And another partition will be only supported on Linux, then you can use this partition to install a USB-bootable Linux.

Requirements:
1. A runnable Linux operating system. At here, I used Ubuntu 8.04.
2. fdisk: a partition table manipulator for Linux that existing on general Linux system.
2. A USB flash drive.

Step1. Find the USB flash drive device.
sudo fdisk -l
On my machine, I had the following output like this:
Disk /dev/sdb: 523 MB, 523091968 bytes
17 heads, 59 sectors/track, 1018 cylinders
Units = cylinders of 1003 * 512 = 513536 bytes
Disk identifier: 0x6f20736b

So, I assume you had same the device with my which is the /dev/sdb.

Step2. Create the one partition for general storage.
sudo fdisk /dev/sdb
2.1 Use "d" command to delete all existing paritions. First, use "p" command to print the partition table, get the partition number, then repeatedly use "d" command to delete if you have more than one existing partitions. My partition table look like the following output from "p" command:
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         718      360047+   6  FAT16
/dev/sdb2   *         719        1018      150450   83  Linux

Then use "d" command to delete:
Command (m for help): d
Partition number (1-4): 2
Command (m for help): d

2.2 Use "n" command to create the partition.
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1

First cylinder (1-1018, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1018, default 1018): 509

After above commands had been done, I got a new partition:
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         509      255234   83  Linux

2.3 Use "t" command to change the partition's system id.
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): b

Finally, the partition has been done, but at here this partition is not compatible with Windows yet.
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         509      255234    b  W95 FAT32


Step3. Create a bootable Linux partition.
Reference Step-2 to create a Linux partition, but use "a" command instead of "t" command that introduced in Step2-3. The "a" command used to toggle partition is bootable.
Command (m for help): a
Partition number (1-4): 2

The final output like this:
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         509      255234    b  W95 FAT32
/dev/sdb2   *         510        1018      255263+  83  Linux


Step4. Make the general storage partition is compatible with the Windows.
Command (m for help): c
DOS Compatibility flag is not set

Command (m for help): c
DOS Compatibility flag is set


Step5. Commit all work that you had done.
Command (m for help): w

If you do something wrong, you can rollback all your work via "q" command.

Step6. Format the Linux partition to ext3.
This step is optional if you like ext3 file system.
sudo mke2fs -j /dev/sdb2