Showing posts with label Linux tips and tricks. Show all posts
Showing posts with label Linux tips and tricks. Show all posts

Saturday, February 12, 2011

HKJC Moonlight

The Hong Kong Jockey Club (香港賽馬會) is one of the shittest websites, their online 投注站 only support IE.

Great news is that finally changed it. Although they are still sticking to Microsoft (Silverlight) now, we do have an alternative Moonlight for Firefox users. When IE and Safari get into the hkjc website, they can automatically detect and download the corresponding plug-in. Firefox failed to do so, because Silverlight is not open-source. Surprisingly, this time Microsoft is kind enough to create a similar open source project Moonlight. They provide a firefox plug-in, letting non-MS people to bet finally.

Tuesday, October 13, 2009

gitweb on Ubuntu/Jaunty

Make sure these GIT packages are installed:

$ aptitude install git git-core gitk gitweb


Assume the default apache web server is /var/www/ ,
gitweb is the directory I want to install gitweb:

$ cd /var/www/
$ mkdir gitweb
$ cd gitweb


copy gitweb graphics and stylesheets(git-favicon.png git-logo.png gitweb.css) to its directory, their path should correspond to what states in /etc/gitweb.conf:

$ cd /var/www/gitweb/
$ cp /usr/share/gitweb/* .


add gitweb directory to apache2 configuration by creating a "gitweb" file inside apache conf.d directory:

$ vi /etc/apache/conf.d/gitweb


Paste the following text and modify if your path is different:

Alias /gitweb /var/www/gitweb

Options Indexes FollowSymlinks ExecCGI
DirectoryIndex /cgi-bin/gitweb.cgi
AllowOverride None


Modify gitweb.conf, assuming the public GIT repositories are located in /var/www/repo/

$ vi /etc/gitweb.conf



$projectroot = "/var/www/repo/";

# directory to use for temp files
$git_temp = "/tmp";

# target of the home link on top of all pages
#$home_link = $my_uri || "/";

# html text to include at home page
$home_text = "indextext.html";

# file with project list; by default, simply scan the projectroot dir.
$projects_list = $projectroot;

# stylesheet to use
# I took off the prefix / of the following path to put these files inside gitweb directory directly
$stylesheet = "gitweb.css";

# logo to use
$logo = "git-logo.png";

# the 'favicon'
$favicon = "git-favicon.png";



restart apache2 web server:

$ sudo /etc/init.d/apache2 restart


Now you should be able to view gitweb listing all GIT projects under /var/www/repo/:
http://localhost/gitweb

Friday, November 07, 2008

vi copy and paste format problem

when copy and paste in vi it automatically inserts many annoying indents and tabs. To disable the auto indents and formatting, use this command before you paste

:set paste


and paste your codes. After that, set it back

:set nopaste

Monday, September 22, 2008

vim autocomplete

For some reason Ubuntu 8.04 didn't install vim by default, thus no syntax.

There's also another tips I always forgot.  vim has a very nice autocomplete feature.  For example you've a variable name "apple", you can type "ap", then press Ctrl-n or ctrl-p, it would show all the functions and variables start with "ap".

Friday, September 12, 2008

How to change the default system shell back to bash

For some reason, Ubuntu changed the default system shell from bash to dash.  To what I noticed, I didn't see any speed improvement but many scripts shows error or are not compatible.

To restore the whole system back to bash, call this command:

sudo dpkg-reconfigure dash

Friday, August 08, 2008

Typing Chinese in English Ubuntu 8.04

Update on Sept 12, 2010
For tips to install Chinese in any Debian based system, please follow this links:





I always prefer to install the OS in English and enable Chinese.  However, Chinese tool (scim) is not installed by default. Followings are my steps to enable Chinese support and typing in Ubuntu(6.04 ?)

  1. Go to System -> Administration -> Language Support
    Choose Chinese (Traditional and/or Simplified)

  2. install packages scim-chinese, scim-tables-zh, and all other dependencies

  3. $ vi /etc/X11/xinit/xinput.d/scim
    change xim input to scim 

    GTK_IM_MODULE="scim"
    QT_IM_MODULE="scim"

  4. without using root, type
    $ im-switch -z <Your locale> -s scim
    your locale can be figured out by command
    $ locale | grep LANG

  5. restart your X (Ctrl-Alt Del), then Ctrl-spacebar should give you a scim toolbar


P.S. After the scim toolbar is poping up, you still need to right click the toolbar to setup what input method you would like to use.  Personally, I used Changjie3 to type Chinese, it seems the closest to the Windows version of Changjie.

P.S.  I wonder if there is easier way...

Thursday, July 03, 2008

yum database clean up

Sometimes when yum is not updating, or simply not synchronized with the repository, it's a good idea to clean up the cache database and fetch a new list from the server.

  1. yum clean all

  2. mv /var/cache/yum/ /tmp/

  3. mv /var/lib/rpm/__db* /tmp/

  4. rpm --rebuilddb


Somehow I tend to move the files to /tmp/ rather then just remove them, since the rm -rf command is the No. 1 enemy of idiocity.

Monday, July 16, 2007

Chinese fonts in Linux ( blur when antialias is true )

If you install your Linux box with English as the primary language, you will notice the Chinese fonts are blurred and hard to read. That is due to anti-aliasing of Chinese characters. I would NOT recommend to disable all font anti-aliasing in Font Preferences, because anti-alias is good and it makes many fonts look easier for eyes, just not Chinese characters when they are small.

The solution is so set false for Chinese fonts under a specific font size. Create a file called local.conf under /etc/fonts/ directory
vi /etc/fonts/local.conf

and copy and paste the following to the file:
<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd">

<fontconfig>

<!-- Disable font alias for Chinese <= 18px -->

<match target="font">

<test qual="any" name="family" compare="eq">

<string>AR PL Mingti2L Big5</string>

<string>AR PL SungtiL Big5</string>

<string>AR PL New Sung</string>

<string>AR PL ShanHeiSun Uni</string>

<string>AR PL ZenKai Uni</string>

<string>Ming(ISO10646)</string>

<string>MingLiu</string>

<string>PMingLiu</string>

<string>Kochi Mincho</string>

<string>Baekmuk Dotum</string>

</test>

<test name="pixelsize" compare="less_eq">

<double>18</double>

</test>

<edit name="antialias">

<bool>false</bool>

</edit>

<edit name="hinting">

<bool>true</bool>

</edit>

</match>

<alias>

<family>serif</family>

<prefer>

<family>Bitstream Vera Serif</family>

<family>Times New Roman</family>

<family>Times</family>

<family>AR PL New Sung</family>

<family>AR PL ShanHeiSun Uni</family>

<family>AR PL Mingti2L Big5</family>

<family>AR PL SungtiL GB</family>

<family>SimSun</family>

</prefer>

</alias>

<alias>

<family>sans-serif</family>

<prefer>

<family>Bitstream Vera Sans</family>

<family>Arial</family>

<family>Verdana</family>

<family>Helvetica</family>

<family>AR PL New Sung</family>

<family>AR PL ShanHeiSun Uni</family>

<family>AR PL kaitiM Big5</family>

<family>AR PL kaitiM GB</family>

</prefer>

</alias>

<alias>

<family>monospace</family>

<prefer>

<family>Bitstream Vera Sans Mono</family>

<family>Courier New</family>

<family>Courier</family>

<family>AR PL New Sung</family>

<family>AR PL ShanHeiSun Uni</family>

</prefer>

</alias>

</fontconfig>