RIME 中州韵输入法引擎之“五笔朙月流”


又一篇用中文写的。因为这篇反正就是关于中文输入法引擎——RIME中州韵输入法引擎——而写的。这中州韵输入法引擎是从Arch Linux的维基那里看到的。它是一种非常奇特的输入引擎。因为它可以让使用者简单地自制理想的输入法。

在Linux,有好几种中文输入法,谷歌拼音、搜狗拼音、SunPinyin等。其它非拼音输入法也有,如五笔输入法、仓颉输入法。本人虽曾经想学仓颉输入法,但因为太难记难用,最后放弃。因为有些生字不晓得如何读,拼音是没用的,所以最后就学了五笔输入法。

五笔输入法,只要懂得字形就可以输入了。因此用五笔输入比拼音来得准确。比如输入名字,用一般的拼音会出现很多选择,而这些“候选字”要一一看过,是相当的累。而若用五笔输入法,就可以把“候选字”减少到一两个罢了。但本人因为不熟悉五笔输入法,尤其在跟朋友在线对话时,拼音会是基本的思考方式,所以本人用拼音会比五笔来得快。因此,五笔和拼音两种输入法一起使用的话,对我来说就会出现因切换输入法而迟缓和多余动作的问题。因此,最理想的方式就是将两种输入法融合,不需要切换,以五笔为优先,因为五笔输入后,候选字词会比拼音来得少。能够达到这种理想输入法的,就是这个中州韵输入法引擎。

这中州韵输入法引擎,在我用的时候发现有一个字,因为台湾繁体和大陆简体有一些差别,所以中州韵输入法引擎本身的有些字用了不太一样的代码,就是“々”和“𠚤”。但中州韵输入法引擎可以用简单的方法让我解决这个问题。不仅如此,我还借此机会加入“绘文字”。因此,我就先制作了自用的五笔输入法。用这个的话,就可以轻松的输入我要的表情绘文字了😁。

但融合两种输入法,说容易也不是很容易,因为没有完善的说明书。因此本人就在百度贴吧里询问了。经过高人指点,后来就尝试融合。起初有几个问题无法解决,但勉强还是可以使用。后来根据苍颉检字法的制作,终于完成“五笔朙月流”输入法了。用这个输入法,就可以拼音加上五笔,输入人名和跟朋友对话都不成问题了。而且还可以反查五笔代码,即在不知五笔的代码是什么的情况下,还可以反查,这样的话就可以同时学习五笔输入法了。强!

这“五笔朙月”和“五笔拼音”是不同的。五笔拼音无法用拼音输入句子,而这“五笔朙月”就可以做到这点。

源码可在此处下载。

Advertisements

bash less resize terminal overflow problem solved


I always have a problem with terminal emulator when using bash but not zsh. The problem can be produced like this,

  1. Open any terminal emulator (gnome-terminal, xfce4-terminal, etc)
  2. Run any command with less, such as “ls |less”
  3. Resize the window to larger size, such as maximize
  4. Quit less
  5. Type anything in the terminal, then the text will not wrap to new line if the text length beyond the window size before resie. And it will overflow to the same line and overwrite the prompt.

This problem can be solved by adding “shopt -s checkwinsize” in .bashrc.

Web, cloud, virtualization, Docker, and Linux


From time to time, I always feel that I have to choose the “best” Linux distro. And I feel that, various Linux distros are somehow annoying, why not just combine all the best features into one powerful OS? (That is why I always struggle for the distro like Arch Linux and Debian.) With the recent trend of the technology such as LXC and Docker, I found that the varieties of the Linux distros is really a good way as it is diverging and exploring the new solutions for our daily problem.

Web is a cross-platform solution, because whatever OS you are using, as long as you have a web browser which is compatible to the web standard, then you can use the web browser to browse the web and use the service properly. That is why, the Internet is so important and so popular in our daily life. Then the cloud storage solution allows us to store our files in the cloud, and the client software will synchronise the files among multiple devices. The synchronisation solves the problem not only the files, but the contacts, calendar, task lists, email, notes, photos, etc.

OpenStack is a term that connects cloud computing with the virtualisation. Previously, when talking about “virtualisation”, my knowledge is something like virtual machine such as Qemu, VirtualBox or VMware. In the Linux world, other than cross-platform virtual machine like VirtualBox, there are some other terms related to virtualisation, and I personally not very familiar with all of them: KVM, libvirt, vagrant, Xen, etc. And recently, LXC and Docker grab my attention, because they are OS-level virtualisation. Instead of virtual machine, what we created is called “container”. Furthermore, the container uses the same kernel as the host OS in spite of the container image is based on other OS.

As DistroWatch.com mentioned, rolling release is difficult to target, because it keeps changing. That is why some users prefer fixed release instead of rolling release, as they want something which can work tomorrow as it works today, namely, consistent.

With the solution like Docker and LXC, rolling release may not be any problem, because we can use rolling release distro to create container based on the fixed release. For instance, running Debian in Arch Linux, or vice versa. That means, developing a solution by targeting on a fixed release, will also work on any type of distros as long as LXC or Docker can work.

Similar to cloud which solves the cross-platform problem, in my opinion, container is a good solution to solve different distros problem.

Learning in Linux community


If you are using Linux, then you are involved in the Linux community. As in the Linux community, most of the software are open source software, which is about sharing and distributing the source code among the community.

As a Linux user, I am not just learn to use the free software happily without paying money. Using the Linux is more benefit than just saving the money.

As a Linux user, I know that reading manual/documentations is important. There are a lot of questions are mostly answered in the documentations or manual. In order to find the answers, we should read the manual. If the answers are available in the manual, yet a newbie is asking in the forum, he or she will be asked to RTFM.

Internet is a good resource for the answers. Utilise the search engine and look for the solutions. Look for solutions properly before asking. Only if the solution is not available, then only we ask in the forum, IRC, or question-and-answer websites such as unix.stackexchange.com.

When using forum, IRC, or question-and-answer websites, we should practice good netiquette. Always ask politely and be grateful to the person who answers your questions. Besides that, wait patiently for the answers. It is community-based, do not expect there is 24 hours 7 days support to your problem. When asking, please provide necessary information so that others will know what is going on. When using the forum, other than netiquette, choose the related forum to post the topic. We do not ask Ubuntu related questions in Fedora forum.

Sometimes, we may see some annoying problems in a Linux distro. The problems may not be solved manually because those are the bugs. If they are bugs, we should file the bugs report properly. However, before file the bugs, please check whether the bugs are not yet reported. After file the bugs, do not expect the bugs will be solved soon or immediately. If you want to solve the problem immediately, sorry to say, you need to solve it by yourself.

Wiki is a good resource in the Linux community. It is a community-based documentation. Read them, search them, follow the instructions if available. Sometimes, the wiki is not updated or there is minor error, contribute to the wiki and update the page. Also, read the “talks” of the wiki page, which may give you some ideas about what is going on.

If you are a programmer or software developer, and if you are able to patch the bugs, then contribute the patch to the community. This will be a wonderful contribution to the community. Because this is also what you need when you found some bugs.

Some Linux distros may have limited packages available. If we need to have other packages, learn about packaging and share the packages.

As a conclusion, become a Linux user is to be involved in the open source community, which will improve your own learning ability, problem solving skills, and communication skills.

Choosing Linux distros


Linux is something wonderful, which until today I am still learning. Not only the command-line, but also filesystem, distributions, philosophies, open source, packaging, Linux kernel, desktop environment, etc…

It is very interesting to know why there are so many Linux distros. As I was a newbie in Linux, I was thinking on how to choose the distros and what are the differences of these distros. Some users state that Linux is the kernel, not a Linux distribution. And even some users say that whatever Linux distribution, it can be customised until identical to the other distribution (interface only).

There are a lot of reviews and comparisons on the Linux distros on the internet, I will not go through those things.

Philosophy

Firstly to choose Linux, besides we need to try the distro itself, we also need to know the distro’s philosophy, or the purpose of the Linux distro project started. There are so many distros, the main reason is the project leaders have different ideas. That is why they start the project to build their ideal OS using Linux kernel. Some distros adopt open source software and format only, as a result no proprietary software is supported. Then the users may need to get the software through other repository or download the binary files and install. The most prominent issue is the multimedia codecs. For example, OpenSUSE and Ubuntu CDs do not contain the restricted multimedia formats. However, the users can still install these codecs after OS installation. Some of the distros are more lenient with the license, such as Linux Mint or even Arch Linux.

Packaging (distribution)

The philosophy decides how the Linux and the other packages are distributed. Some distros target for the server, some for desktop computer, some for live media only (USB flash drive), some for old computer, some for gaming. Because of the target audience, the developers will package the related software to distribute to the users.

Based on the philosophy, some of the distros will distribute latest packages, or cutting edge packages (such as beta version), or old and stable packages. For example, Debian is well-known for the stable packages; Fedora is well-known for the cutting edge packages.

Package manager

In order to distribute the packages, a package manager is a must. That is why, there are Debian-based, RPM-based, pacman-based, or others. The purpose of the package manager is to manage the packages. It can get the packages from the repository. We can use it to install and uninstall the packages.

Each Linux distro should only use one package manager. It is possible to install several package managers in an OS. It is even possible to run the other package manger and install the package to the OS. For example, let say I am using Arch Linux, I get the source for aptitude (Debian’s package manager) and compile it. Then I can install the packages from Debian’s repository. However, the effect is not good. This is because the packages are built for target distro (for instance, Debian). Even the binary executable file may be compatible, the filesystem hierarchy may be different. In practical, using multiple package managers normally do not work, this is because the package manager will check for the dependencies. Therefore, do not think that you can have an OS which you can just get any packages from any repository.

(But please remember that, you can always build your own package from the scratch. However, some of the application really depending on the distros.)

Patch

Linux is an open source kernel. As a result, some developers may patch the Linux kernel in order to do something special. For example, linux-ice from Arch Linux AUR, it is a patched kernel to support TuxOnIce (suspend and hibernation features). So, no need to surprise why some distros can work like this, some distros cannot work like this.

Similar to the Linux kernel, the kernel modules (normally drivers) can also be patched for special purpose.

Community

Though the community is not part of the Linux distro, it has some influences on the distro. When we have the problems dealing with the distro, we can get some help from the forum. Each distro has different community. We should not ask the questions about other distros in an unrelated forum. Nobody can help. And no one likes to help. Because you are in a wrong channel.

Documentation

Similarly, documentation is not part of the Linux distro, but it is part of the project. Well documented information is very important for the self-learning users.

 

Therefore, to choose the Linux distro, we need to know the philosophy of the distro. Find a distro which fits to our appetite. If there is any problem, read the documentation and ask the correct community. Always bear in mind that, bugs are always there. Even we are using Windows, there are also bugs. The only problem is the severity of the bugs and how long will the bugs be fixed. Use the channel such is IRC, forum, bugs report, or mailing list to help us to utilise the OS better.

And always bear in mind, we can change to another Linux distro any time when we want.

Dream LiveUSB: ArchPup


Recently, I found that Puppy Linux has a higher (visits of page) ranking than KNOPPIX in DistroWatch. Furthermore, Puppy Linux is also well-known for its old computer support. This is interesting.

Previously, I tried KNOPPIX, which I liked most is that it is able to save the user session. That means, if you installed any package or save the files in $HOME, reboot the KNOPPIX in the USB, those settings are still preserved. This is a feature which I didn’t found in other Live Media. I tried KNOPPIX because it is a distro targets on Live Media.

Yet, there is something I don’t like. That is the Debian repository. That is why, KNOPPIX is using Iceweasel instead of Firefox. And some of the packages are not cutting edge.

So, I tried Puppy Linux. It has the exact feature like KNOPPIX, i.e. saves the session. The next thing I found about Puppy Linux something interesting is the term “Slackware-compatible” and “Ubuntu-compatible” from the community site. A Linux distro which has different built with different compatibility. As a result, I discovered ArchPup which is based on Arch Linux.

Previously, I tried to built my dream LiveCD or LiveUSB based on Arch Linux and ArchBang but failed. Several reasons. One of the reasons is the difficulty to load the packages I want.  Even I successfully built the LiveCD, the startup in the X Windows is not satisfying. Furthermore, difficult to test the LiveCD and waste a lot of time to build the LiveCD. The building script provided was not working well.

Now, this ArchPup, it is using pacman (package manager), which I am familiar with. After creating the archsave.4fs (save session), reboot it, then I can install any packages I like. However, the repository used is not the official Arch Linux repository. Thus, one may not get the latest package. Furthermore, Linux kernel and some libraries are ignored. As a result, there is no upgrade of these libraries. (I think the archsave.4fs is compatible with the newer version when it is released, thus I don’t mind there is no upgrade of the kernel.)

So, I installed all the important packages as much as possible, especially utilities for rescuing, such as ddrescue, gparted, chntpw, etc.

Now, the only problem I face is the size of the archsave.4fs. The size can be changed by replacing it with another file. I did it manually using some commands.

ArchPup (Puppy Linux) is really awesome.

(Skip the following for those who are not interested.)

Technical part

I was very interested on how the save session works on Puppy Linux. I knew the SquashFS. It is read-only. And I know that is is possible to save the files in $HOME. This can be done by mounting a file or partition on /home with read-write. That is why archsave.*fs can be ext2, ext3, or ext4. But when I use the pacman to install the packages, the packages are not saved in /home but in root and other directories.

After some studies, then I only know that, there is something called union mount, which can be done by unionfs or aufs. This is the component that used by both Puppy Linux and KNOPPIX.

By doing this, both the ext2/3/4 and squashfs can be mounted in union. As a result, whatever changes to the “/” (root), this will affect the read-write mount. And this effect is happened directly to the archsave.*fs. So, we need not to do some thing like “save on exit”.

Resize save session manually

Actually it is not resizing. The following is what I did. Firstly, create a filesystem using “dd”,

dd if=/dev/zero of=archsave.4fs bs=1024 count=1M
#1 mega of for block size 1024 will produce 1 gigabyte file
#1000 x 1024 

Then, format the file.

mkfs.ext4 archsave.4fs

Now, mount the archsave.4fs in a directory, eg, ~/new/. And we also need to mount the current archsave in the USB in another directory, eg, ~/old/.

Then, we copy from old to new,

cp -a ~/old/* ~/new/

Replace the file in pendrive. Boot and you will get extra space.

initrd and Linux distros


Recently, I was thinking about to use Puppy Linux with my old computer. Yet my computer is already installed with Arch Linux. I wish not to uninstall or replace the Arch Linux, because installing Arch Linux is time consuming and exhaustive.

Puppy Linux is a live media like KNOPPIX. The official website mentioned that it can be installed into the computer without affecting the original OS, that is, installed side-by-side. This makes me re-called side-by-side installation of Ubuntu and Linux Mint. I tried this feature before using Linux Mint installed in a computer with Windows. It works fine until I give up because of the upgrade problem.

I was interested to test how does it work for Puppy Linux to be installed with Arch Linux side-by-side without affecting the partitions. Thus, I tried it with VirtualBox. Finally, I learnt some interesting things.

To install side-by-side, is actually copying the sfs (SquashFS) and some other related files to a computer filesystem path, such as C:\somewhere (for Windows) or /mount_point/somewhere (for Linux). The sfs contains the compressed filesystem for the Linux distro. That means, it will contains the important binary files such as bash, vim, grep, firefox, thunderbird, and so on. However, the question is, how the computer boots and mount the sfs file?

There is a file, called initrd (or initramfs), may be given with different name based on the Linux distro. It is a small file which is archived with “cpio”. It is small enough to load in the computer RAM. It contains a very limited command-line environment, normally using busybox so that it can perform the commands such as cp, mv, ls, grep, [, etc. Therefore, this initrd is responsible to run an “init” script to load the Linux kernel, mount the filesystem, and so on. It actually happens for other Linux distros like Arch Linux, not necessarily the live media like Puppy Linux.

Now, another question is how does computer load this initrd? This can be done through the boot loader such as GRUB, LILO, or Syslinux. The boot loader, will run the initrd so to load into the RAM. Therefore, the filesystem which contains these sfs and initrd must be recognisable by the boot loader. That is why, the filesystem such as FAT32, NTFS, and ext2/3/4, is able to be installed with Puppy Linux (or other distros) without affecting the partitions (side-by-side installation).

So, after trying this, now I have better knowledge about how Linux doing the booting,

  1. starts from the boot loader, such as GRUB,
  2. loads the initrd or initramfs, and finally
  3. initialises the Linux distro.

So, this initrd is actually part of the Linux distro. Different Linux distro may have a little difference for the filesystem structure, as a result, initrd may also work differently.