New To Ubuntu

Wednesday, November 29, 2006

Make Fonts Looks Like Windows

This post http://www.linuxsir.org/bbs/showthread.php?t=266659(in Chinese) provides detailed explanations for how to set up fonts under Ubuntu (or Debain) to make it looks like fonts under windows. The following is a short version with no technical explanations

1) Install MS core fonts

sudo apt-get install msttcorefonts

This will install following fonts to /usr/share/fonts/truetype/msttcorefonts

Andale Mono, Arial, Comic Sans MS, Courier New, Georgia
Impact, Times New Roman, Trebuchet MS, Verdana, Webdings


2) Install extra MS fonts

Do the following as root

Make a directory

mkdir /usr/share/fonts/truetype/winxp


Copy following fonts to the directory

tahoma.ttf
tahomab.ttf
simsun.ttf
mingliu.ttf

(The last two fonts are for Chinese characters)

For me, my windows C drive is mounted at /media/winC, so the command is:

cd /media/winC/WINDOWS/Fonts/
cp tahoma* /usr/share/fonts/truetype/winxp
cp simsun.ttc /usr/share/fonts/truetype/winxp/simsun.ttf
cp mingliu.ttc /usr/share/fonts/truetype/winxp/mingliu.ttf

And make the file readable to all users

chmod 644 /usr/share/fonts/truetype/winxp/*

3) Create font config files

Extract and save following files

Save this file http://www.box.net/public/oqkaukrzu4 as /etc/fonts/msttcorefonts.conf

Save this file http://www.box.net/public/n7cnpo8co4 /etc/fonts/local.conf

Save this file http://www.box.net/public/cogpitbyc9 as /etc/fonts/cjk.conf

Check which file language-selector.conf is linked to

ls -l /etc/fonts/language-selector.conf

Gives:

lrwxrwxrwx 1 root root 45 2006-11-19 15:12 /etc/fonts/language-selector.conf -> /usr/share/language-selector/fontconfig/zh_CN

So I replace /usr/share/language-selector/fontconfig/zh_CN with this file http://www.box.net/public/vy10g6mhb9

4) Update font by following command

sudo fc-cache -fv

And restart X windows.

After these the fonts look just like under Windows, sharp and clear

Following is the picture before setup
But I am not sure which way is better, sharp and clear fonts are pretty, but I find it's hard for my eyes.

Labels:

Problem 3.5 of A Concise Introduction to Pure Mathematics

Problem
The Fibonacci sequence starts with term 1, 1 and then proceeds by letting the next term be the sum of previous two terms. So the sequence starts 1, 1, 2, 3, 5, 8, 13, 21, 34, ... With this in mind, consider the decimal expansion of x = 100/9899: it is 0.010102030508132134... Note how the Fibonacci sequence lives inside this expansion. Can you explain this? Do you think it continues forever?
(Hint: First show that 100 + x + 100x = 10000x)


Solve
x = 100/9899 => 9899x = 100 => 10000x - 101x = 100 => 100 + x + 100x = 10000x

It is obvious that x < style="font-weight: bold;">.a1a2a3a4....., while all a's are between 0 and 9, then we can write above equation as
100 + (3) 0.a1a2a3.... + (2) a1a2.a3a4.... = (1) a1a2a3a4.a5a6....
100 = (1) a1a2a3a4.a5a6.... - (2) a1a2.a3a4.... - (3) 0.a1a2a3....
To make the right hand side sum up to 100:
a1 can only be 0, otherwise (1) will be bigger than 100
a2 can only be 1
a3 can only be 0 (a3 of (1) - a1 of (2) = 0, and a1 is already 0)
a4 can only be 1 (a4 of (1) - a2 of (2) = 0, and a2 is 1)
for the rest, we have a(n + 4) - a(n + 2) - a(n) = 0, i.e. a(n+4) = a(n + 2) + a(n)
if we consider every two decimal digit as a number, then the sequence follows Fibonacci sequence, but when the number is greater than 100, which occupies more than 2 digits, the sequence will no longer show up.

Labels:

Monday, November 27, 2006

Disk Usage Analyzer



I guess the fact that I am still trying new applications indicates that I am still adjusting to Linux. This is a quite nice application for folks like me who were spoiled by easiness of Windows. It allows you to check how many rooms are used on you hard disk, it's amazingly fast. And it also allows you to search a file on your file system, as well as on a network.

Labels:

Saturday, November 25, 2006

Wifi

Wifi support under Ubuntu Edgy is great. The live CD recognized my Netgear WG511T, and found a non-password-protected wifi network of my neighbor, I changed the SSID and network password to use my own wifi during installation. After installation, my own wifi was ready for use, there is almost nothing left to do.

If you roaming a lot, and has lots of WEP/WAP to setup, this WPAHowTo maybe useful for you.

But I am too lazy, and my laptop is almost used as a desktop, so I installed wifi-radar, just for fun.

sudo apt-get install wifi-radar















Wifi-radar is kind of buggy, and there's no where to find documentation, I am having a hard time to figure out what those icon means. I planned to use it as a wifi browser, but using the command 'sudo iwlist scanning' provides more accurate information. I probably will use network-manager in future.

Labels:

Tuesday, November 21, 2006

Prove 5y^2 + 5y + 1 is prime, where y is integer >= 1

This is exercise 8.e of Chapter 1 of "A Concise Introduction to Pure Mathematics"

Prove 5y^2 + 5y + 1 is prime, where y is integer >= 1

suppose if statement is false, then
5y^2 + 5y+ 1 can be written as
(ay + b)(cy + d)
where (ay + b) and (cy + d) are both integers,
hence a, b, c, d has to be rational numbers
extend it we get:
ac*y + (ad + cb) y + bd
so
ac = 5
ad + cb = 5
bd = 1
bd= 1 => b = 1/d, c = 5/a
then ad +cb = 5 => ad + 5/ad = 5
=> (ad)^2 - 5ad + 5 = 0
make ad = e, e is also a rational number
but e = (5 +- sqrt(25 - 4*5))/2 = (5 +- sqrt(5))/2
sqrt(5) is not a rational number, so e is not a rational number
this is a contradiction

Labels:

Install Scim

I need to use Chinese input, so I followed this guide

sudo fontconfig-voodoo -f -s zh_CN

sudo apt-get install im-switch libapt-pkg-perl
sudo apt-get install scim-pinyin #this part is missing in the guide
sudo im-switch -s scim -z default

And the guide recommends scim-bridge, because scim will crash
Realplayer, Openoffice, Acrobat Reader, etc. But scim-bridge
won't work for me. So to prevent Realplayer from crashing,
I did the following:

Edit /usr/bin/realplay, add this line after #!/bin/bash

GTK_IM_MODULE=xim;export GTK_IM_MODULE

I suspect it's the same for Acrobat Reader and Open office, but since I am not using them right now, it's still remain to be tested.

Labels:

Sunday, November 19, 2006

Autmatically Mount Samba Share

I have a Xbox running Gentoo (cooool) to do some p2p downloading, and I set up a Samba server on it to share the files.

The following is to mount the Samba share:

check this post for detailed instructions.

1) Install Samba file system
sudo apt-get install smbfs

2) Make mount point
mkdir /media/xbox

3) Create a password file for the samba share
nano /root/.smbcredentials
And enter the following:
username=sambasuername
password=sambapassword

This file is needed because my Samba server has password.

4) Edit /etc/fstab, add the following (one line)
//xbox/public /media/xbox cifs credentials=/root/.smbcredentials,
iocharset=utf8,
file_mode=0777,dir_mode=0777,
uid=1000,gid=46,noperm,setuids,rw 0 0

Now try
mount /media/xbox
will mount Samba share on my xbox to /media/xbox.

Because I have some utf8 file names on samba share, I have to use cifs. The uid and gid option will actually be ignored by cifs. The uid of mounted files will be the actual uid of that file on the samba server, i.e. my xbox. For example, all my sharing files on the server belong to user 1002, so all files under /media/xbox in my Ubuntu will belong to user 1002.

But 1002 does not exist on my Ubuntu box, and I want only user 1000 have the ownership of the samba share. I am too lazy to find the real solution. I just changed all the sharing files on samba server to a new owner 1000. Like this (executed on xbox):
xbox$chown 1000 /sambaShare/* -R

And of course I have to add user 1000 into my Samba server.

The following is to automatically mount Samba share

My xbox is not up running all the time, and I want it to be mounted whenever it is running. So I wrote following script. Basically it is a daemon pings xbox every couple seconds, if it finds the xbox is alive, then mount it.

Create a new file /usr/local/sbin/mountxbox.sh as following
(or download it from here http://www.box.net/public/7m9e432ypt)
#!/bin/bash

#this is a daemon to detect xbox and mount its samba if the
#xbox is running, it assumes /media/xbox is already defined
#in fstab

CHECK_INTERVAL=40 #check interval, in seconds
MOUNT_DIR="/media/xbox"
XBOX_IP="192.168.1.10"
SHUTDOWN_SIGNAL="/tmp/killmountxbox.sh"

while [ 1 ]
do
#quit if was signled to quit
if [ -f $SHUTDOWN_SIGNAL ]
then
#echo remove $SHUTDOWN_SIGNAL from .sh
rm $SHUTDOWN_SIGNAL #remove the file first
break
fi

#check if the dir is already mounted
#grep -c will output number of lines contain MOUNT_DIR
ALREADY_MOUNTED=$(mount|grep -c $MOUNT_DIR)

#check if xbox is alive
if ping -c 1 -q $XBOX_IP &> /dev/null
then
XBOX_ALIVE=1
else
XBOX_ALIVE=0
fi

#do nothing if already mounted
if [ $ALREADY_MOUNTED -gt 0 ]
then
#unmount the share if xbox is not alive
if [ $XBOX_ALIVE -eq 0 ]
then
umount -f $MOUNT_DIR
fi

#echo "already mounted"
sleep $CHECK_INTERVAL
continue
fi

#check if the xbox is open
if [ $XBOX_ALIVE -eq 1 ]
then

#echo "xbox is alive, try to mount"
mount $MOUNT_DIR
fi

sleep $CHECK_INTERVAL
done


And then
chmod +x /usr/local/sbin/mountxbox.sh
To make it executable

Create a start up script /etc/init.d/mountxbox
(or download it from here http://www.box.net/public/q7jlp0huxk)
### BEGIN INIT INFO
# Provides: mountxbox
# Default-Start: S
# Default-Stop:
# Short-Description: Start or stop auto mount script for /media/xbox
# Description: Starts or stops auto mount script for /media/xbox
### END INIT INFO

#!/bin/bash

#call /usr/local/sbin/mountxbox.sh to start
#a daemon to auto mount /media/xbox
CMMD_PATH="/usr/local/sbin/mountxbox.sh"
SHUTDOWN_SIGNAL="/tmp/killmountxbox.sh"


ACTION="$1"
case "$ACTION" in
start)
if [ -f $SHUTDOWN_SIGNAL ]
then
echo remove $SHUTDOWN_SIGNAL
rm $SHUTDOWN_SIGNAL
sleep 1
fi

$CMMD_PATH 2>&amp;amp;amp;amp;amp;1 &
;;
stop)
touch $SHUTDOWN_SIGNAL
;;
*)
esac

exit 0
And
chmod +x /etc/init.d/mountxbox
to make it executable.

And make a link
ln -s /etc/init.d/mountxbox /etc/rcS.d/mountxbox

This should start it up when boot. (I actually used Boot-up Manager, so never tested the link command, but it should work)

Labels:

To Make Hibernate/Suspend/Resume Work With Properietary Nvidia Driver

Need to do the following to make suspend/resume work with Nvidia driver:

1) Edit /etc/X11/xorg.conf, add following to "Device" section

Option "NvAGP" "1"

2) Set POST_VIDEO=false in /etc/default/acpi-support

Labels:

Install Nvidia 1.0-9629 Driver

The default nv driver for Nvidia is fine, unless you want to use 3D acceleration. The newest driver from Nvidia is 1.0-9629 as we speak. You can follow the "unofficial guide". Or there is a great tool called "envy" to make it very easy. Just download the "deb" file from that guy's web page and install it.

OK, it's actually not that easy. The new driver make my card (GeForce4 420) show a black screen when you start X. The guy of "envy" has a section in his guide to deal with this (part 7 of Problem Section), but unfortunately it didn't work for me. But the following worked:.

1) Edit /etc/modprobe.d/options, add followings

#to prevent nvidia driver giving black screen
options nvidia NVreg_SoftEDIDs=0 NVreg_Mobile=1


2) Edit /etc/X11/xorg.conf, add following to "Screen" section

#to prevent black screen
Option "UseDisplayDevice" "DFP-0"

Now direct render works

~$ glxinfo |grep render
direct rendering: Yes
OpenGL renderer string: GeForce4 420 Go/AGP/SSE2

To disable Nvidia's start up logo

Add following to "Device" section of /etc/X11/xorg.conf
 Option  "NoLogo"


X Crashes With ppracer/tuxracer and All Full Screen Games

This is a bug of Nvidia's 9629, check this message. This is happens to all full screen games, because almost all full screen games will try to change the screen resolution, thus cause the crash. Temporary solution will be to set screen resolution before game starts. For ppracer, set the resolution to 800x600 before starting the game will solve the problem. Maybe we have to wait for new driver.

Labels: