Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Friday, February 11, 2011

Vim Usage: Change upper case/lower case

I am addicted to use vim all the time, in programming (except eclipse), in text editing. I like to use it since it increase my working progress and the command helps me a lot.

I am going to post some notes when I learn some new useful command/macro.
One useful function is to change letter case. For one character, you can simply use "~" to change to case from upper to lower or vice versa.

However, what if I want to change whole passage to UPPERCASE or lowercase. We can use gU / gu command.

1. Change whole passage to lower case
you can use "ggguG" in command mode.

Explain:
  • gg - go to the first line and first character
  • gu - change letter to lower case
  • G - go to the last character of last line
Thus, it goes to the first character, change to lower case until the last character.

2. You can use motion command to change case

guw、gue、gUw、gUe

3. some special combinations

  • gUU - change current line to uppercase
  • 10gUU - change 10 lines including current line to uppercase
  • gU0 - change first character of current line to uppercase
  • gU$ - change last character of current line to uppercase
  • gUG - change character from current position to last charactor of last line

Tuesday, February 8, 2011

Install Longman Dictionary under 64-bit Ubuntu

Since I need to reinstall my computer as the previous post said, I install Longman Dictionary again, but I got the following error:

The setup program seems to have failed on amd64/glibc-2.1
Fatal error, no tech support email configured in this setup

I remember I faced this error before but I have forgotten the reason and how I solve it. After googling, it seems to be that the software doesn't support 64-bit system. To solve it, we need to sacrifice a bit and use 32-bit.
$ linux32 ./setup.sh
Then you should install it without problem.

Ubuntu 10.10 is not stable for ATI display

I upgrade my computer to Ubuntu 10.10 from 10.04 LTS without any problem. However, when I use it, it hangs randomly. The whole screen freezes and the only thing I can do is to hard reboot. I think it is related to my display card driver (I use ATI HD 4300 series). Thus, I deleted it and the problem is that the session will automatically logoff randomly. It seems that it is better than freezing the screen, huh..at least I can login again.... Then, I download the driver from ATI ...after installation, freezing screen problem occurred again.....Then I have no choice and I am setting up Uunutu 10.04 LTS again right now........

This experience tells me that it is better to use LTS version.... and it seems that Ubuntu 10.10 doesn't support the display well for ATI. However, for my netbook, this is ok..

Monday, February 7, 2011

Set default half punctuation in IBUS

I usually use half punctuation even when I am typing Chinese character. I should use full punctuations unless I need to type some formal and official documents. Every time, I launch IBUS which these two action "Ctrl+space" to turn on IBUS and then "Ctrl+." to switch to half punctuation mode.

Recently, I take a look of IBUS source code and I found how IBUS determine which mode is turned on by default. It look at the table database file. For me, I use cangjie3. Thus I edit the database with sqlite3 (you can use apt-get to install it)
$ sqlite3 /usr/share/ibus-table/tables/cangjie3.db

Then, you can view your current setting by:
select * from ime;

You can see that by default,def_full_width_punct is set to be TRUE. Thus, I simply set it to be FALSE using sql:
update ime set val='FALSE' where attr='def_half_width_punct';

Finally, you just need to restart IBUS and you will find the default punctuation mode is half.

Sunday, February 6, 2011

Set Default Traditional Chinese in IBUS under English Ubuntu 10.10

I am using Ubuntu 10.10 in my netbook. Basically, this is good and I used it for a long time. However, I hate the Ibus default setting for my usual chinese input method (cangjie) as the default chinese mode is simplied chinese if I use English Ubuntu (locale: LANG: en_HK). Thus, I found a way to solve my problem and set the default chinese mode to be traditional. I modified the ibus problem.

1. Edit /usr/share/ibus-table/engine/table.py
2. Find the following code (at about line 116)
if __lc.find('zh_') == 0:
                # this is a zh_XX
                __place =__lc.split('_')[1]
                if __place == 'cn':
                    return 0
                else:
                    return 1
            else:
                if self.db._is_chinese:                                                                               
                    # if IME declare as Chinese IME
                    return 0
                else:
                    return -1
3. Edit as following
if __lc.find('zh_') == 0:
                # this is a zh_XX
                __place =__lc.split('_')[1]
                if __place == 'cn':
                    return 0
                else:
                    return 1
            else:
                if self.db._is_chinese:                                                                               
                    # if IME declare as Chinese IME
                    # return 0
                    return 1  #Edit this line to return 1 instead of 0
                else:
                    return -1
4. Restart IBUS and DONE

Saturday, January 29, 2011

Use Text based GUI Runlevel configuration tool to add or remove services

In Fedora, we can use chkconfig command to set the run level of the serveice. However, it is missing in Ubuntu.

rcconf is Debian runlevel configuration tool. Rcconf allows you to control which services are started when the system boots up or reboots. It displays a menu of all the services which could be started at boot. The ones that are configured to do so are marked and you can toggle individual services on and off. If rcconf is not installed use apt-get command:
$ sudo apt-get install rcconf


Now run rcconf and just follow on screen instructions:
$ sudo rcconf

Thursday, January 27, 2011

Setting Lenovo IdeaPad S10-3′s touchpad with two finger scroll support on Ubuntu 10.10


After buying my Lenovo IdeaPad S10-3 I read some reviews about the hardware and all of them agreed that to integrate the mouse’s buttons to the touchpad wasn’t the best thing Lenovo have done... I agree too.



On Windows 7 the touchpad has a better performance than on Linux without setting Synaptics in the graphical environment, so I thought it should be a way to set it on Linux. As the x11 config file has been removed in Ubuntu 10.10. I need to use synclient to set the mouse pad value. Thus, I created a bash script and if you like, you can put it as startup program. Also, I added two finger scroll support in this script

1. You can copy the script below and save it as "lenovo_mousepad.sh" (change it whatever you like).

#!/bin/bash                                                                                 

synclient LockedDrags=false
synclient VertEdgeScroll=true
synclient HorizEdgeScroll=false
synclient TapButton1=1
synclient LTCornerButton=2
synclient MaxDoubleTapTime=120
synclient TapButton2=3
synclient EmulateTwoFingerMinZ=20
synclient EmulateTwoFingerMinW=5
synclient AreaBottomEdge=4200

# comment the following 4 lines if you don't want two finger scroll support
synclient VertTwoFingerScroll=1
synclient HorizTwoFingerScroll=1
synclient EmulateTwoFingerMinW=5
synclient EmulateTwoFingerMinZ=48


2. set it as executable
$ chmod +x lenovo_mousepad.sh


3. execute the script
$ ./lenovo_mousepad.sh


4.(Optional) put it as startup program under the administration menu

Note: you can query all current values by typing this
$ synclient -l


Here the parameters of interest are:

Parameter Description
TapButton1 Which mouse button is reported on a non-corner one-finger tap.
LTCornerButton Which mouse button is reported on a left top corner tap.
TapButton2 Which mouse button is reported on a non-corner two-finger tap.
EmulateTwoFingerMinZ This sets the Z pressure threshold to emulate a two finger press.
EmulateTwoFingerMinW This sets the finger width threshold to emulate a two finger press.
AreaBottomEdge Ignore movements, scrolling and tapping which take place below this edge.

Saturday, January 8, 2011

Taglist for vim

ctags is a very important tools for programmers who use vim as the major editor. You can install taglist plugin for vim. However, ctags program is not installed by default in Ubuntu. Thus, it shows the following error when lauching vim with taglist.

Taglist: Exuberant ctags (http://ctags.sf.net) not found in PATH. Plugin is not loaded.


To solve this, for sure we need to install ctags. To do so
$ sudo apt-get install exuberant-ctags

`gnome-256color' not known

When using vim, I usually set it to be gnome-256color to have better appearance.
However, it showed an error to me when I launched vim. The error is :
E558: Terminal entry not found in terminfo
'gnome-256color' not known. Available builtin terminals are:
builtin_riscos
builtin_amiga
builtin_beos-ansi
builtin_ansi
builtin_pcansi
builtin_win32
builtin_vt320
builtin_vt52
builtin_xterm
builtin_iris-ansi
builtin_debug
builtin_dumb
defaulting to 'ansi'


To solve this problem, we need to install the corresponding package
$ sudo apt-get install ncurses-term

Friday, December 31, 2010

`multirow.sty' not found

When I use package multirow in Latex, error occurs when compiling the source file. The error is saying `multirow.sty’ not found.

We can fix under Ubuntu:
$ sudo apt-get install texlive-latex-extra

Friday, October 1, 2010

[HOWTO] Connect Creative Zen with Ubuntu

I have a Creative Zen, and if you need to transfer music to the device, you need another software to help you. In the past when I was using Fedora, there is a software named Gnomad2 http://gnomad2.sourceforge.net/. After compilation, you can use it can transfer your favorite songs.

However, it seems that Ubuntu 10.04 has some problem about this software. I use apt-get to install it first. Then, plugged in the zen, unmounted and started gnomad2. Gnomad2 crashed immediately. I tried "gnomad2" in terminal and received the following output:

Queried Creative ZEN
Segmentation fault

Then, I googled this situation and some tell me I should compile from the source. But it doesn't work for me, here is the guide and you can try

1. Uninstall gnomad2 from your system
$ sudo apt-get remove gnomad2


2. Clean out any left over dependencies
$ sudo apt-get autoremove


3. Download the source files for gnomad2
$ apt-get source gnomad2

Note:
a. You may get some error about dependency, you need to use apt-get to install the dependency if needed.
In my case, it told me I do not have "dpkg-source" then I
$ sudo apt-get install dpkg-dev

b. "apt-get" not "sudo apt-get", you don't need root permissions here as we're not installing anything. Using the sudo command will cause permissions problems later when trying to delete the source files.

4. Configure
$ ./configure

Note:
a. For the first time, it may get following errors
No package 'glib-2.0' found
No package 'gthread-2.0' found
No package 'libnjb' found
No package 'gtk+-2.0' found
Then to solve this problem,
sudo apt-get install libglib2.0-dev

sudo apt-get install libgtk2.0-dev

sudo apt-get install libnjb-dev

b. For the second time,
checking for id3tag.h... no
configure: error: *** id3tag.h C header is needed (missing -dev package?) ***\n*** You might have erroneously installed id3lib instead of libid3tag ****\nThis distinction is very delicate, so PLEASE pay attention! ***
To solve this problem,
$sudo apt-get install libid3tag0-dev


c.For the third time
configure: error: Your intltool is too old. You need intltool 0.35.0 or later.

$ sudo apt-get install intltool


5. compile
$ make


6. install
$ sudo make install


7. Gnomad2 installed successfully! Delete the files and directs apt-get downloaded.

Unfortunately, when I launch Gnomad2, it said it cannot find the device. Finally, I realized that Ubuntu can support my Zen using RhythmBox by default and I can use it to transfer music. Awesome!