2007年2月16日星期五

Mac OSX Newbie

1) Install Packages:
Fink project: it's very familiar with the apt package system in Debian/Ubuntu.

DarwinPorts project: all packages are built from source code, so you need more patient. To get it working, you'd install xcode you can download from apple website or its install CD/DVD

2) install Postgresql:
The easiest way is using Fink or "apt-get install". Different with the distribution in Debian/Ubuntu, the configuration file and data file are both stored at /sw/var/postgresql-8.0/ directory, the owner of which is a non-exist user "postgres".

You can not use "sudo su postgres" to manage the authentication (createuser etc.), but you can use "sudo -u postgres createuser" to add your user of database. Then go to the /sw/var/postgresql-8.0/data directory, and get your postgresql configuration done

3) Fix backspace and delete keys for ssh in Terminal.app
Open a terminal, "File" menu, click "Show Info", then you get a pop-up window, "Terminal Inspector". Choose "Keyboard" in the list box, and then turn on the "Delete key sends backspace" option

4) Subversion with ssl support
Unfortunately, the svn/svn-client package in Fink project don't support ssl. I find a ported version with ssl support:
http://metissian.com/projects/macosx/subversion/
As the README file describes, the subversion-client is installed at /usr/local/lib, and you need add /usr/local/bin to your PATH in your .profile


5) Virtual Machine
VMWare Fusion: It's free right now although it's only beta version and you need to fill a long list registration to get a serial number freely. I have tried it, and installed a Debain-Sarge system with a sarge net-install iso file.

There's a big issue of Fusion: It doesn't support bridged with wireless network card, only supports NAT type.


Another option: Parallels, a commercial virtual tool, and sounds it supports bridging wireless card.

6) Network tools
Terminal: iTerm, it's cooler than the default terminal in OSX: at least supporting tab terminal. http://iterm.sourceforge.net/
IM tools:
Colloquy: http://colloquy.info/, IRC client.
Gaim: ported from Fink project;
MSN
microsoft official IM tool;
Adium: http://www.adiumx.com/ support several kinds of IM protocols.

7) X11 Application related:
There's an official X11 application you can find it from Mac OSX's install disk DVD/CD. Using the application, we can run those GUI applications ported from DarwinPort or Fink very well in OSX. I find a link: http://xanana.ucsc.edu/xtal/xterminator/ to customize the X11.app easily.

You can also get another X11 server application from DarwinPort: XDarwin.

8) Virtual Desktop:
Codetek Virtual Desktop: commercial virtual desktop software.
Desktop Manager: http://desktopmanager.berlios.de/, free software, its features are less than Codetek Virtual Desktop.
VirtueDesktops: http://virtuedesktops.info/ based on Desktop Manager, and looks like it's getting very popular amongst those that like virtual desktop applications.

9) Utils:
iStat: System monitor software. http://www.islayer.com/index.php?op=item&id=25
Stuffit Expander: http://www.versiontracker.com/dyn/moreinfo/macosx/182 Compression file manager, it's useful to decompress kinds of compression files.
vncviwer for Mac: http://www.cl.cam.ac.uk/research/dtg/attarchive/vnc/macvncviewer.html, client software to connect to vncserver, for remote control.
stardict: ported from DarwinPort project.

2007年2月14日星期三

Install Flash plugin for Opera in Ubuntu Edgy

There's a package named "flashplugin-nonfree", in Ubuntu Edgy package repository:

Package flashplugin-nonfree

  • edgy (web): Macromedia Flash Player plugin installer [multiverse]
    7.0.68~ubuntu3: i386
ps: for latest flash plug-in (version 9), you may need some external source list.

install it first. It will install flash plug-in module into "/usr/lib/firefox/plugins" directory.

Then edit your Opera configuration file in your home directory: ~/.opera/pluginpath.ini, adding the following line into the "Paths" section:

/usr/lib/firefox/plugins=1
ps: you can find there's already another two plug-in paths in the file.

Restart Opera, and type "opera:plugins" in the address bar of Opera browser, you can find that Shockwave Flash plug-in has been already installed.

2007年2月2日星期五

Building KDE environment in vncserver

1. Install packages
# apt-get install kdebase (Install KDE)
PS: you will install all necessary packages when install "kdebase"

# apt-get install vncserver
# apt-get install vncviewer (install vnc client & server)

2. create a user for KDE environment
To avoid to disturb your own working environment, I suggest you to add a user for KDE environment
# adduser kde

3. setup for user "kde"
# su kde
$ cd
(change to home directory)
$ cp /etc/vnc.conf .vncrc
$ vi .vncrc (configure vnc server)

configurations I defined in my own machine:
$vncUserDir = "$ENV{HOME}/.vnc";

# $vncPasswdFile contains the filename of the password file for Xvnc.
$vncPasswdFile = $vncUserDir . "/passwd";

# $vncStartup points to a script that will be started at the very beginning.
$vncStartup = "$ENV{HOME}/.vnc/kde";

# $xauthorityFile should be the path to the authority file that should be used
# by your vnc X server.
$xauthorityFile = "$ENV{HOME}/.Xauthority";

# $defaultDesktopName should be set to the default name of the desktop.
# This can be changed at the command line with -name.
$defaultDesktopName = "KDE";

# $geometry sets framebuffer width & height. Default will be calculated if
# server is started from within a running X servers. Can be changed at
# the commandline (-geometry). A fixed default will be used if
# vncserver is not invoked in a running X session.
# Example: $geometry ="640x480";
$geometry ="1024x768"
# $depth sets the framebuffer color depth. Must be between 8 and 32.
# $pixelformat sets the default pixelformat.
# The default will be calculated if none of both is specified
# and when vncserver is called from within a running X servers.
# Can be changed at the command line with option -depth.
# A fixed default value will be used if vncserver is not
# invoked in a running X session.
# Example: $depth = "16";
# $pixelformat = "rgb565";
$depth = "16"
$pixelformat = "rgb565"


PS: pay attention to "$vncStartup", we will define it later


$ mkdir .vnc (create the directory we defined in .vncrc, $vncUserDir, it's the default value)
$ cd .vnc
$ echo "startkde &" > kde (the file name is defined in "$vncStartup", it's the startup script for vncserver.)
(Use startkde & for KDE, gnome-session & for GNOME or fvwm2 & for FVWM2.)
$ vncpasswd (set password for vnc authentication, it will create a file with name defined in "$vncPasswdFile")

4. Start VNCServer
There's two ways to start vncserver:
1) setup crontab with kde user
#su kde
$ crontab -e
add following line in the crontab list:
@reboot vncserver -alwaysshared > /dev/null
It means: starting vncserver when machine startup. You can remove the "-alwaysshared" option if you don't want to share vncserver with multi-users. But only one connection is allowed if you disable the option.

2) start vncserver manually
To start the vncserver manually, you have to log in the 'kde' user in console. I have met a weird thing here: the vncserver doesn't work well in following steps:
open a Gnome Terminal in my own user
sudo su kde
vncserver

But if I log in 'kde' in tty1 (press Ctrl+Alt+F1), the vncserver works well.

For more details please read manual of vncserver.


5. Connect to VNCServer
$ vncviewer localhost:1 (1 means the display#, you should change it if the vncserver is using other display)
PS: run the command in your own user desktop.
Then you can enjoy your own KDE:)

6. Stop VNCServer
$ vncserver -kill :1 (stop the vncserver in display 1)

References:
http://www.linuxjournal.com/article/5499
http://perso.netplus.ch/FCorthay/InstallGentoo/Shortforms/gentoo-kde-2.6.html

Studying Algorithms -- Solving Recurrence

Master method to solve recurrence with some particular form like:
T(n) = a * T(n/b) + f(n)
conditions: a>=1, b>1, f(n): asymptotic positive,

means: problem 'T()' of size 'n' can be separated into 'a' parts of problem 'T()' of size 'n/b', and then merge them for cost of 'f(n)'.

There's three common cases, by f(n) vs power(n, log(b, a)):

1) f(n) = Θ(power(n, (log(b,a) - ∈)) (for ∈> 0)
means f(n) is polynomially smaller than power(n, log(b,a))
SOLUTION: T(n) = Θ(power(n, log(b, a))

Example: T(n) = 4T(n/2) + n
==> f(n) = n; a = 4; b = 2; power(n, log(b,a)) = power(n, 2)
==> f(n) = Θ(power(n, 2-∈)) for ∈= 1
==> T(n) = Θ(power(n, 2))
2) f(n) = Θ(power(n, log(b,a)) * power(lg(n), k)) (for k >= 0)means f(n) grows at similar speeds with power(n, log(b,a))
SOLUTION: T(n) = Θ(power(n, log(b,a)) * power(lg(n), k+1))

Example: T(n) = 4T(n/2) + power(n, 2)
==> f(n) = power(n, 2); a = 4; b = 2; power(n, log(b,a)) = power(n, 2)
==> f(n) = Θ(power(n, 2)) for k = 0
==> T(n) = Θ(power(n, 2) * lg(n))
3) f(n) = Q(power(n, (log(b,a) + ∈)) (for ∈> 0)
and regularity condition:
a*f(n/b) ≤ c*f(n) for constant c less than 1 means f(n) grows polynomially faster than power(n, log(b, a))

Example: T(n) = 4T(n/2) + power(n, 3)
==> f(n) = power(n, 3); a = 4; b = 2; power(n, log(b,a)) = power(n, 2)
==> f(n) = power(n, 2+∈) for ∈= 1 with regularity condition:
==> a * f(n/b) ≤ c * f(n) for (c less than 1)
==> 4 * power((n/2), 3) ≤ c * power(n, 3)
==> if c in [1/2, 1]
==> T(n) = Θ(power(n, 3))

开博了! n_n