วันจันทร์, พฤษภาคม 29, 2549

Upgrade PHP from 4.4.1 to 5.1.4

Old Configuration:

PHP Version 4.4.1


Configure Command '/SourceCache/apache_mod_php/apache_mod_php-18.4/php/configure' '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-dependency-tracking' '--with-apxs' '--with-ldap=/usr' '--with-kerberos=/usr' '--enable-cli' '--with-zlib-dir=/usr' '--enable-trans-sid' '--with-xml' '--enable-exif' '--enable-ftp' '--enable-mbstring' '--enable-mbregex' '--enable-dbx' '--enable-sockets' '--with-iodbc=/usr' '--with-curl=/usr' '--with-config-file-path=/etc' '--sysconfdir=/private/etc' '--with-mysql=/usr' '--with-mysql-sock=/var/mysql/mysql.sock'
Server API Apache
Virtual Directory Support disabled
Configuration File (php.ini) Path /private/etc/php.ini
PHP API 20020918
PHP Extension 20020429
Zend Extension 20050606
Debug Build no
Zend Memory Manager enabled
Thread Safety disabled
Registered PHP Streams php, http, ftp, compress.zlib

ขี้เกียจคอมไพล์เอง เลยอัพเดทแบบไบนารี่ เอามาจากเว๊บนี้ http://www.entropy.ch/software/macosx/php/#update

โหลดอันของ Apache 1.3 มาเพราะไม่อยากอัพเกรด Apache ไปเป็น ๒ ไม่งั้นคงลำบากน่าดู.
php5 ถูกติดตั้งลงไปที่ /usr/local/php5.
หลังจากติดตั้งแล้วสตาร์ทอะปาชี่ไม่ติดเพราะเหมือนกับว่า php4 และ php5 มันถูกโหลดทั้งคู่เลยตีกัน.
(php5 ถูกโหลดโดย /etc/httpd/users/+entropy-php.conf ซึ่งเป็น symbolic link ไปที่ /usr/local/php5/entropy-php.conf

ลองลบส่วนที่เป็นของ php4 ออก
แล้วอาศัยการ include โดยแยกส่วนที่ include php4 กับส่วนของ php5 ออกจากกันแล้วใช้การรีเนมเอา
Include /private/etc/httpd/users/*.conf
/private/etc/httpd/users/+php4.conf กับ +php5.conf

วันอาทิตย์, พฤษภาคม 28, 2549

DSpace : Export items in a collection.

refer to the system document, we can export items in a specific collection by :

$ /bin/dsrun org.dspace.app.itemexport.ItemExport --type=COLLECTION --id= --dest=/some/where/destination/ --number=


ทำโหลดบาลานซิ่ง http://sunsite.utk.edu/diglib/dspace/contrib/loadbal.txt
######################################################
# This document was kindly contributed by Larry
# Lansing (lansil @ fuzzynerd.com). For any questions
# regarding this information, please contact him
# directly.
######################################################

As promised, here are my loadbalancing configuration files. These are
still works-in-progress--there are probably mistakes and omissions. I
hope someone finds these useful.

Notes: The apache server (I'll call it "www") relays connections to
two tomcat servers called "jsp1" and "jsp2", using ajp13. www runs
Apache2.0, with mod_jk. jsp1 and jsp2 run Tomcat 4.1.24. I have
tried to simplify my configs by disabling unnecessary tomcat
connectors, such as the standalone port 8080 HTTP connector.

www configs
-----------
httpd.conf must include these lines in appropriate places:
***
LoadModule jk_module libexec/apache2/mod_jk.so
Include /usr/local/etc/apache2/mod_jk.conf
***

mod_jk.conf:
***


JkWorkersFile /usr/local/etc/apache2/workers.properties
JkLogFile logs/jk.log
JkLogLevel warn
JkMount /dspace/* loadbalancer
JkMount /dspace-oai/* loadbalancer

***

workers_properties:
***
worker.list=loadbalancer

worker.jsp1.port=8009
worker.jsp1.host=jsp1
worker.jsp1.type=ajp13
worker.jsp1.lbfactor=1

worker.jsp2.port=8009
worker.jsp2.host=jsp2
worker.jsp2.type=ajp13
worker.jsp2.lbfactor=1

worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=jsp1, jsp2
***

jsp1 and jsp2
-------------
Tomcat's server.xml (still a bit "raw" until I figure out what each
option does):
***








port="8009" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>





prefix="catalina_log." suffix=".txt"
timestamp="true"/>





unpackWARs="true" autoDeploy="true">


directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="common"/>


directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>





allowLinking="true" docBase="" />


allowLinking="true" docBase="" />









***

วันเสาร์, พฤษภาคม 27, 2549

jLibrary

หลังจากลง tomcat ใหม่เป็น 5.5 แล้วก็ลองใส่ jLibrary ดู ทำตามนี้ตรงๆ :


To install the jLibrary WAR application you should follow the next steps:

  1. Go to the jLibrary downloads section on sourceforge.net and download the .WAR distribution bundle. If you want to create an up-to-date distribution, checkout the build guide on the developers section to find how to build jLibrary sources from CVS.
  2. Once you have downloaded the bundle, you'll find a zip file with the web application archive. Also there is some documentation in the form of a README.txt file, and a jaas.config file. Now, you can place the jlibrary.war file on your webapps directory.
  3. The next step is to add the jaas.config file to your Apache Tomcat conf directory. If you already have a jaas.config file, then you can add to it the following lines:
    Jackrabbit {
    org.apache.jackrabbit.core.security.SimpleLoginModule required anonymousId="anonymous";
    };
  4. And finally you must tell to tomcat where is the jaas.config file if you haven't done yet. This can
    be done in several ways from your catalina file. For example adding the following line to the
    java command, or to the CATALINA_OPTS environment variable:

    -Djava.security.auth.login.config=%CATALINA_HOME%/conf/jaas.config

Configure different storage locations.

On the jLibrary configuration file there are several locations in which you will have to define paths to directories in which content will be stored. For example, the he first section of the jLibrary configuration allows you to change the location on the file system where the jLibrary repositories system data will be created. You can see it here:

    



As you can see, this section (and many others on the configuration file) is using a special variable ${rep.home}. The real location on the file system for this variable depends on the applaction server in which you are running jLibrary. For example, on Apache Tomcat it will be the bin directory. Proabably you really won't like to store contents on that place. If this is the case, you can replace all the occurrences of the ${rep.home} with any other custom location. Even more, you can use different locations for different things. This is a sample with the location changed:
    


These are all the places in which the ${rep.home} variable appears and that you can easily replace by other locations:
  • Base repository structure location (seen on the example)
  • Workspaces location. This will correspod with each jLibrary repositry.
  • Versions location. The place in which version history file data will be stored.
  • System index. The place in which the search information for version history will be stored.

วันพุธ, พฤษภาคม 24, 2549

find และ xargs

เค้าว่าใช้ find ... | (ไปป์ไปที่) xargs ... นั้นมันให้เพอร์ฟอร์มานซ์ดีกว่าใช้ find ... -exec ...
เพราะว่า find -exec มัน fork เยอะ
(อ้างอิง)
http://www.sunmanagers.org/pipermail/summaries/2005-March/006255.html

Thanks very much for the quick responses - herewith a summary of what I learned:

The problem is not one of recursion limit, but one of (in)efficiency.

It is much more efficient to use find | xargs than find -exec {} \;

"find ... -exec command {} \;" runs the command once for each name.

If find identifies 10000 files, using -exec grep ... as an example,
find would fork off a child copy of itself, the copy would become a
grep working on a single file. Meanwhile the original parent find
would sleep waiting for its child (grep) to finish before searching
for the next file that meets the find criteria. That means 10000
executions of grep and pauses of find.

"xargs command" reads names on its standard input, and feeds them in
bunches to command, so that command is run fewer times (only once, in
most cases). So, if we use find | xargs grep ..., the find is able to
work "non-stop" filling the pipe with found file names. xargs
collects groups of about 20 - 50 names and does a single grep for the
collection. Find doesn't pause and you only do about 200 greps, not
10000. There isn't a forked process for every single file.

The weaknesses of xargs are (1) it can be confused by "funny"
filenames (which is why Gnu has find -print0 |xargs -0, or you can
pipe through sed to add backslashes everywhere), and (2) it can feed
zero arguments to command which might then
just sit there waiting (this is why Gnu xargs has -r which means:
don't run command if stdin is empty).

These days, you can use "find ... -exec command {} +" which groups
arguments together. However, I found that this did not give
satisfactory grep results when invoked as:

find /usr/include -type f -exec grep NFS_VERSION {} \+ -print (or
without the escaped +)

The following examples show the time difference (and slightly more
useful output of xargs):

$ time find /usr/include -type f -exec grep NFS_VERSION {} \; -print
#define NFS_VERSION ((rpcvers_t)2)
/usr/include/nfs/nfs.h
#define NFS_VERSION 2
/usr/include/rpcsvc/nfs_prot.h
version NFS_VERSION {
/usr/include/rpcsvc/nfs_prot.x

real 0m9.883s
user 0m3.340s
sys 0m5.900s
$ time find /usr/include -type f|xargs grep NFS_VERSION
/usr/include/nfs/nfs.h:#define NFS_VERSION ((rpcvers_t)2)
/usr/include/rpcsvc/nfs_prot.h:#define NFS_VERSION 2
/usr/include/rpcsvc/nfs_prot.x: version NFS_VERSION {

real 0m0.677s
user 0m0.380s
sys 0m0.310s

Thanks,

Steve Nelson


ตัวอย่างการใช้ เช่น เราจะหา md5 checksum ของไฟล์หลายๆไฟล์แบบเวียนเกิด recursively ก็ใช้คำสั่ง

$ find . -type f \! -name "._*" -print0 | xargs -0 md5sum

เอาเฉพาะ regular file
อันที่ไม่ได้ขึ้นต้นด้วย ._ ใน Mac OS มันชอบมีไฟล์ที่ขึ้นต้นด้วย ._ เยอะ
print ออกมาโดยใส่ null (\0) แทน whitespace ธรรมดา เพราะ xargs มันไม่ค่อยฉลาดตรงนี้

t I jojo$ time find . \! -name ".*" -print0 | xargs -0 md5sum
17c6d0eb1e725ef16e78bfd8c99219c7 ./01 ใคร.m4a
a0bbe221525288210e0a1cdb4f03eb95 ./02 ผมแอบชอบคุณอยู่.m4a
df68e7fc0984fa7dbe1172d476300c2b ./03 คนข้างล่าง.m4a
ccf9def29b9027d62f597c6e31e07066 ./04 Live & Learn.m4a
a1be585bd5e1b304aec8905a1959621c ./05 นานแค่ไหน.m4a
9759b2c841786f07d70260975932a4d7 ./06 ล้มบ้างก็ได้.m4a
214db53c2c2f519f59cc3b24fd6eb360 ./07 เหมือนเคย.m4a
3945193b6ecb2497cf04acb5f26d5ea3 ./08 พอ.m4a
7d2d16c919de20d1e3d174699f0aa821 ./09 หัวใจผูกกัน.m4a
babba2eb62de6f080280ec896016fe5c ./10 Who,What,When,Where,Why.m4a
55f6de761c829ea1adc227f14ad181f6 ./11 ต่างมุม.m4a
afe989790d19fd36b8f8c28fa8e555c4 ./12 เพลงรัก.m4a

real 0m56.337s
user 0m12.174s
sys 0m1.962s

วันอังคาร, พฤษภาคม 23, 2549

Samba บน Solaris และ PostgreSQL บน Mac สำหรับ DSpace

จะลงแซมบ้า บนโซลาลิสเครื่อง lxx-xx16 มาหลายทีแล้ว แต่ว่ามีปัญหาหลายๆอย่าง จนกิ๊บอัพไปหลายครา คราวนี้เอาจริง คอมไพล์เอง ไม่ใช้จากแพคเกจแล้ว พอดีก็มีปัญหาอีกที่ว่า ไอ่ /usr/local มันถูกเมาท์โดย NFS ทำให้เราไม่อยากจะเข้าไปแก้ ก็เลยต้องลงใน $HOME/sys เอาละกัน
คำสั่งคอนฟิก

./configure --prefix=$HOME/sys/opt/samba --with-acl-support --with-quotas --with-included-popt --localstatedir=$HOME/sys/var/lib/samba --with-piddir=$HOME/sys/var/run --with-logfilebase=$HOME/sys/var/log/samba --with-privatedir=$HOME/etc/samba/private --with-configdir=$HOME/etc/samba
--with-ldap=no --with-ads=no
คอมไพล์ไม่ผ่าน สุดท้ายต้องใช้ package pkgadd -d samba...pkg.bz
มันจะติดตั้งไปที่ /opt/samba. เป็น Samba เวอร์ชั่น 3.0.22
samba-3.0.20a-1-noads-sunos5.9-sparc.pkg:
./configure --prefix=/opt/samba --with-acl-support --with-quotas --with-included-popt --localstatedir=/var/lib/samba --with-piddir=/var/run --with-logfilebase=/var/log/samba --with-privatedir=/etc/samba/private --with-configdir=/etc/samba --with-ldap=no --with-ads=no


ขั้นต่อมาแก้ /etc/samba/smb.conf เพิ่มส่วนที่ต้องการแชร์ลงไป ตัวอย่างเช่น
[myshare]
comment = My FileServer
path = /some/where/to/share
valid users = my_user_name
public = no
writable = yes
printable = no
create mask = 0700 or 0644
directory mask = 0700

---
create mask = 0644

The option create mask specifies and sets the necessary permissions according to the mapping from DOS modes to UNIX permissions. With this option set to 0644, all file copying or creating from a Windows system to the Unix system will have a permission of 0644 by default.

directory mask = 0755

The option directory mask specifies and set the octal modes, which are used when converting DOS modes to UNIX modes when creating UNIX directories. With this option set to 0755, all directory copying or creating from a Windows system to the Unix system will have a permission of 0755 by default.

และเพื่อความปลอดภัย อย่าลืม disable anonymous เพิ่มบรรทัดนี้เข้าไปในส่วน [global]
restrict anonymous = 2
client plaintext auth = no
---
ขั้นต่อมาก็เช็ค smb.conf ว่าโอมั้ย
# /opt/samba/bin/testparm

จากนั้นก็ต้องแก้ไข inetd เล็กน้อยเพื่อให้มัน start Samba daemons:

Most of Samba's services are provided by means of three servers or daemons: smbd is the Samba server, nmbd is the NetBIOS name server and swat is a Web-based Samba configuration tool. These deal with incoming connections on ports 137, 139 and 901 respectively and we need to tell the Solaris internet daemon, inetd, to start the appropriate Samba daemons whenever an incoming request is received on these ports.

Edit /etc/services and make the following changes.

Immediately after the line which reads:

sunrpc 111/tcp rpcbind
insert the two lines:

netbios-ns 137/udp # Samba nmbd
netbios-ssn 139/tcp # Samba smbd
and, after the line which reads:

ldaps 636/udp # LDAP protocol over TLS/SSL (was sldap)
insert the line:

swat 901/tcp # Samba swat
Now edit /etc/inetd.conf and add the following three lines to the end of the file:

netbios-ssn stream tcp nowait root /usr/local/samba/bin/smbd smbd
netbios-ns dgram udp wait root /usr/local/samba/bin/nmbd nmbd
swat stream tcp nowait.400 root /usr/local/samba/bin/swat swat
If you have TCP wrappers installed (see Installing and configuring TCP Wrappers on Solaris), the three lines to be added should read:

netbios-ssn stream tcp nowait root /usr/sbin/tcpd /usr/local/samba/bin/smbd smbd
netbios-ns dgram udp wait root /usr/sbin/tcpd /usr/local/samba/bin/nmbd nmbd
swat stream tcp nowait.400 root /usr/sbin/tcpd /usr/local/samba/bin/swat swat
Tell the inetd daemon to re-read its configuration file:

# pkill -HUP inetd
and Samba is installed and working.


ระวัง: ถึงแม้เวลาเรา ps -ef | grep smbd ดูโพรเสสแล้วไม่เจอ แล้วก็คิดว่ามันไม่เวิร์คตรงไหน?
จริงๆมันรันอยู่แล้ว เราต้องลอง connect เข้าไปดูถ้า connect ติดถึงจะมี smbd รันให้เห็นกะตา

นอกจากนี้เรายังสามารถให้ swat ได้ที่ http://localhost:901/ แต่ผมยังไม่ได้ลอง

เย่ สำเร็จ เท่านี้ก็มีไฟล์เซิร์ฟเวอร์ให้ถลุงแล้ว


ลง PostgreSQL ใน Mac OS X
อ้างอิงจาก: http://developer.apple.com/internet/opensource/postgres.html

เริ่มจากลง readline ใน Fink ด้วยคำสั่ง
$ sudo /sw/bin/fink install readline

แล้วก็ดาวน์โหลด postgresql มา ครั้งนี้เราโหลด 8.1.4 มา

./configure --prefix=$HOME/sys/usr/local/pgsql --with-includes=/sw/include --with-libraries=/sw/lib --enable-multibyte --enable-unicode --enable-locale --with-java --with-openssl --with-pam --with-bonjour
จากนั้นก็อาจจะ make check เพื่อความชัวร์ แต่ไม่จำเป็น install ได้เลยโดย make install

su -l postgres

$POSTGRESQL/bin/initdb -D $POSTGRESQL/data

Success. You can now start the database server using:

./bin/postmaster -D ./data
or
./bin/pg_ctl -D ./data -l logfile start
PostgreSQL ships with fairly lax access rules. If you’ll be using your
database in a production environment, or on any kind of shared server,
you should add at least a basic level of security. User authentication
rules are defined in the file /usr/local/pgsql/data/pg_hba.conf. As explained in the PostgreSQL documentation,
you can edit this file to password-protect user accounts, change
authentication methods for local and remote connections, and enable or
disable user access to various parts of the system.

# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD

host all postgres 127.0.0.1 255.255.255.255 md5
host samegroup all 127.0.0.1 255.255.255.255 md5
local all postgres md5
local samegroup all md5

After editing the file, I need to create a password for the “postgres” superuser, and restart the database server so the changes will take effect:

postgres@mail:~> psql test

test=# alter user postgres with password 'your_password';
test=# \q

For 8.0+, in postgresql.conf uncomment the line starting:

listen_addresses = 'localhost'

Then tighten up security a bit by editing pg_hba.conf and adding this line:

host dspace dspace 127.0.0.1 255.255.255.255 md5

# Jakarta Tomcat 4.x/5.x or equivalent, such as Jetty or Caucho Resin.

Note that DSpace will need to run as the same user as Tomcat, so you might want to install and run Tomcat as a user called 'dspace'. สำหรับกรณีนี้เราไม่

You need to ensure that Tomcat has a) enough memory to run DSpace and b) uses UTF-8 as its default file encoding for international character support. So ensure in your startup scripts (etc) that the following environment variable is set:

JAVA_OPTS="-Xmx512M -Xms64M -Dfile.encoding=UTF-8"

You also need to alter Tomcat's default configuration to support searching and browsing of multi-byte UTF-8 correctly. You need to add a configuration option to the element in [tomcat]/conf/server.xml:

URIEncoding="UTF-8"

e.g. if you're using the default Tomcat config, it should read:

URIEncoding="UTF-8" />

Jetty and Resin are configured for correct handling of UTF-8 by default.


DSpace Quick Installation Steps

First, a Word on Directories and Path Names

DSpace uses three separate directory trees. Although you don't need to know all the details of them in order to install DSpace, you do need to know they exist and also know how they're referred to in this document:

  • the source directory, referred to as [dspace-source]
  • the install directory, referred to as [dspace]
  • the web deployment directory. If you're using Tomcat, this will be [tomcat]/webapps/dspace (with [tomcat] being wherever you installed Tomcat--also known as $CATALINA_HOME). This directory is generated by the web server when it unpacks dspace.war, and should never be edited.
  1. Download the latest DSpace source code release and unpack it:

    gunzip -c dspace-source-1.x.tar.gz | tar -xf -
  2. Copy the PostgreSQL JDBC driver (.jar file) into [dspace-source]/lib. Download it directly from the PostgreSQL JDBC site. Make sure you get the driver for the version of PostgreSQL you're running and for JDBC2. เราลองใช้ JDBC3 ถ้าไม่เวิร์คเราจะกลับมาใช้ 2

  3. Create a dspace database, owned by the dspace PostgreSQL user:

    createuser -U postgres -d -A -P dspace ; createdb -U postgres -O dspace -E UNICODE dspace

    เราเปลี่ยนคำสั่ง createdb โดยให้ postgres ซึ่งเป็น DB admin ครีเอท เพราะไม่สามารถให้ dspace DB user create ได้โดยตรง

  4. As the dspace UNIX user, compile and install DSpace:

    cd [dspace-source] ; ant fresh_install

ติดตั้ง handle server
  1. Run /dspace/bin/dsrun net.handle.server.SimpleSetup /dspace/handle-server. Follow the instructions, answering relatively simple questions. Another option might be to run /dspace/bin/make-handle-config after configuring dspace.cfg, but we did not do this.
  2. Mail the file /dspace/handle-server/sitebndl.zip to hdladmin@cnri.reston.va.us. They will quickly create your global identifier and email you with the appropriate information.
  3. Once you receive the email, you must edit the Handle configuration file (/dspace/handle-server/config.dct). Just as the DSpace instructions say, เพิ่ม "storage_type" = "CUSTOM" และก็ "storage_class" = "org.dspace.handle.HandlePlugin" ลงไปในส่วนของ server_config.
  4. While still in config.dct, update any lines that say something like YOUR_NAMING_AUTHORITY with the appropriate number as sent to you in the email from the Handle admin people. For instance, here at UTK we have a line that reads "server_admins" = ( "300:0.NA/1785" ). We made this change in three places, under server_admins, backup_admins, and replication_admins.
  5. Edit /dspace/config/dspace.cfg, changing handle.prefix to whatever number you were assigned (in our case, the line reads handle.prefix = 1785), and changing if necessary handle.dir to point to the right place, usually /dspace/handle-server.
====================================================================
[echo] The DSpace code has been installed, and the database initialized.
[echo]
[echo] To complete installation, you should do the following:
[echo]
[echo] * Install the DSpace UI (dspace.war) and OAI-PMH (dspace-oai.war)
[echo] Web applications from the 'build' directory in the appropriate
[echo] place for your servlet container. e.g. '/opt/tomcat/webapps'
[echo]
[echo] * Make an initial administrator account (an e-person) in DSpace:
[echo]
[echo] /Users/jojo/sys/usr/local/dspace/bin/create-administrator
[echo]
[echo] * Start up your servlet container (Tomcat etc.)
[echo]
[echo] You should then be able to access your DSpace's 'home page':
[echo] https://bossanova.jaist.ac.jp:8080/dspace
[echo]
[echo] You should also be able to access the administrator UI:
[echo]
[echo] https://xxx.xxx.xxx.xxx:8080/dspace/dspace-admin
====================================================================



ปัญหา!!!!
สตาร์ทอัพ DSpace ไม่ได้เพราะเหมือนกับว่า หลังรันคำสั่งแล้วมันจะให้ใส่ passphrase ซึ่งไม่สามารถใส่ได้
ทางแก้: ลองใหม่โดยไม่ encrypt key ด้วย passphrase ก็จะสามารถสตาร์ทได้

== ไม่จำเป็นต้องติดตั้งใหม่ทั้งหมด ==
หลังจาก Handle-server เอย การ customize ไฟล์ input-forms.xml เอย ลงตัวแล้ว
เราสามารถเคลียร์ db เก่าโดยไม่ต้องลงใหม่ทั้งหมด (fresh_install) ด้วยการ:
1. ลบ dspace database ทิ้ง
2. ไปที่ [dspace-src] แล้ว $ ant setup_database && $ ant load_registries
3. ไปที่ [dspace] แล้ว $ ./bin/create-administrator

วันอาทิตย์, พฤษภาคม 14, 2549

Firefox Extensions

ที่ใช้อยู่ตอนนี้ก็มี
  1. Tab Mix Plus
  2. Mouse Gestures
  3. PDF download
  4. Down Them All
  5. Permit Cookies
  6. Flashblock
  7. Firefox Google Bookmarks

วันพฤหัสบดี, เมษายน 27, 2549

XSCF ของ PRIMEPOWER 250

config by execute /opt/FJSVmadm/sbin/madmin
แล้ว เราก็จะเห็น hostname, IP, ssh-enabled/disabled, web interface-enabled/disabled
จากนั้นก็ connect to the xscf console via ssh

วันพฤหัสบดี, มีนาคม 30, 2549

คำศัพท์ที่ใช้ในไวยากรณ์ภาษาญี่ปุ่น (Words used in Japanese Grammar)

Access Levels
JA TH
文法ไวยากรณ์

ประโยค

วลี

อนุประโยค
単語
คำศัพท์
修飾(しゅうしょく)
การขยายคำ (modify)


名詞
คำนาม
動詞
คำกริยา
助詞
คำบุพบท
副詞
คำวิเศษณ์
接続詞
คำสันธาน
数詞
คำบอกจำนวน
助数詞
คำลักษณะนาม
疑問詞
คำแสดงคำถาม


主語
ประธาน(หัวเรื่อง)
述語
ส่วนขยาย
目的語
กรรม
主題
หัวข้อเรื่องหลัก


肯定(こうてい)
บอกเล่า
否定
ปฏิเสธ
完了
สมบูรณ์
未完了
ไม่สมบูรณ์
過去
อดีต
非過去
ไม่อดีต

วันพุธ, มีนาคม 22, 2549

LaTeX package for typesetting books, reports

Memoir is a LaTeX package which has predefined primitives ex. chapter, page, caption and styles.
It can potentially help in typesetting a book.
I'm to check it later.

วันศุกร์, มีนาคม 10, 2549

Upgrade MediaWiki to 1.57 and Apache 2

หลังจากอัพเกรด Mac OS X ไปเป็น Tiger 10.4 แล้ว wiki ก็ไม่เวิร์ค วันนี้จะ troubleshoot แล้วก็เลย
ถือโอกาส อัพเกรดไปพร้อมๆกันเลย

รายละเอียดเริ่มอ้างอิงจากที่นี่
http://meta.wikimedia.org/wiki/Running_MediaWiki_on_Mac_OS_X

==== Apache 2 ====
download Apache 2 จาก http://www.serverlogistics.com/downloads.php
Files ต่างๆของ Apache 2 ถูกติดตั้งลงไปยัง /Library/Apache2 ไม่ทับ Apache ที่ติดมากับ OS
แต่ดั้งเดิม. นอกจาก start กับ stop แล้ว ยังมี graceful ที่ใช้เป็น parameter สำหรับ apachectl ได้
# /Library/Apache2/bin/apachectl {start,stop,graceful}
ลง preference pane เพิ่ม ได้ที่ /Library/PreferencePanes หรือ $HOME/Library/PreferencePanes เวลาจะ uninstall ก็อย่าลืมเอาออกด้วย

Preference pane ของ Apache 2 ที่ติดตั้งลงไปมันจะทำการเซตค่า APACHE2 ใน /etc/hostconfig
เพื่อกำหนดว่าจะให้ Apache 2 start ตอน boot หรือไม่
จะ uninstall ก็ลบไดเรคทอรี่เหล่านี้ออกซะ (อ้างอิง Install Guide ใน dmg installer file)

/Library/Apache2
/Library/StartupItems/Apache2
/Library/Receipts/Apache2.pkg



==== MySQL ====
MySQL เดี้ยงต้องจัดการก่อน เพราะเคยลง CompleteMySQL 4.0.21 ของ serverlogistics ไว้ แต่มันใช้กับ Tiger ไม่ได้?? หรือได้หว่า??

การลบ CompleteMySQL (อ้างอิงจาก Install Guide ที่อยู่ใน dmg installer file) ออกทำโดย:
- Backup databases ที่มีอยู่ทั้งหมดก่อน
- ลบ directory เหล่านี้
  • /Library/MySQL
  • /Library/StartupItems/MySQL
  • /Library/Receipts/MySQL.pkg
- หากต้องการ/จำเป็น ลบ mysql user ออกจากระบบด้วยก็
# sudo niutil -destroy . /users/mysql
- ลบ MySQL.prefPane ออกจาก /Library/PreferencePanes หรือ $HOME/Library/PreferencePanes


การติดตั้ง MySQL 5
(ดูเพิ่มเติม http://dev.mysql.com/doc/refman/5.0/en/upgrading-from-4-1.html)
- download mysql-standard-5.0.18-osx10.4-powerpc-64bit.dmg จาก
http://dev.mysql.com/downloads/mysql/5.0.html
- MySQL จะ install ไปที่ /usr/local/mysql-VERSION และทำ symbolic link ชี้มาจาก /usr/local/mysql
- หลัง install แล้วต้องทำ
- Install MySQLStartupItem.pkg ถ้าต้องการให้ MySQL start up automatically ตอน system
startup Startup Item for MySQL 5.0 is installed into
`/Library/StartupItems/MySQLCOM'. (Before MySQL 4.1.2, the location was
`/Library/StartupItems/MySQL)
- secure the default accounts หลังจากติดตั้ง MySQL เสร็จใหม่ๆ installer ของ Mac มันจะ initialize database ให้อยู่แล้ว (mysql_install_db) แต่ grant tables ที่มัน init มาให้จะไม่มี password ดังนั้นเราต้องเซต password ด้วยเพื่อความปลอดภัย
  • start MySQL server ด้วย คำสั่ง #sudo ./mysqld_safe [-u mysql] (ใน [...] optional)
  • ทดสอบ ด้วยคำสั่ง #sudo ./mysqlshow mysql
  • เซต password หรือลบ MySQL's anonymous account ออก และเซต password ให้ MySQL's root account. ข้อควรระวัง: มันมี anonymous account อยู่สองแบบ คือ ของ localhost กับของ host_name. ของ localhost มันจะมี privilege เท่า root ดังนั้นอันตราย ในครั้งนี้เราจะลบ anonymous account ทิ้งและเซตพาสเวิร์ดให้ root โดย
    • shell> mysql -u root
      mysql> DELETE FROM mysql.user WHERE User='';
      mysql> FLUSH PRIVILEGES;
    • shell> mysql -u root
      mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_pasword');
      mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('new_password');
    • ตรง User=''; นั้นเป็น single quote 2 อัน ไม่ใช่ double quote.
    • ถ้าจะเช็คให้แน่ใจว่า host_name ควรเป็นอะไร ใช้คำสั่ง
      mysql> SELECT Host, User FROM mysql.user;
  • ดูรายละเอียดจาก หน้านี้ http://dev.mysql.com/doc/refman/5.0/en/default-privileges.html

ปล. มี CocoaMySQL ที่เคยลงไว้ มันเป็น client เอาไว้ connect ไปจัดการกับ MySQL server แต่ CocoaMySQL ใช้กับ version 4.0.21 ได้ แต่ไม่สามารถใช้กับ version 5 ได้เพราะว่า password
encryption มันต่างกัน ต้องไปใช้ CocoaMySQL version beta0.7 ถึงเวิร์ค
- copy database ที่ dump ออกมาจากตัวเก่าไปยัง version ใหม่
(อ้างอิง: http://dev.mysql.com/doc/refman/5.0/en/upgrading-to-arch.html?ff=nopfpls)
  • shell> cat /some/where/dumped_db.mysql | mysql -u root -p db_name
หลังจาก upgrade จาก Panther ไปเป็น 10.4 Tiger แล้ว PHP communication with MySQL server มีปัญหาเพราะ socket ถูกย้ายด้วยเหตุผลทางด้าน security (อ้างอิง: http://docs.info.apple.com/article.html?artnum=301457, http://docs.info.apple.com/article.html?artnum=302977)
Mac OS X Server 10.4: Issues connecting PHP to MySQL (ลองดูใน script mysqld_safe ดูได้ว่ามันเรียกไปยัง /tmp/mysql.sock)

When running MySQL and PHP on the same Mac OS X 10.4 server, you may find that PHP cannot connect to MySQL. When PHP is communicating with a MySQL server on the same host, it uses a socket file to communicate, and looks for it at /tmp/mysql.sock. On Mac OS X Server 10.4, MySQL creates this socket file at /var/mysql/mysql.sock.

To resolve this issue, you can either change the location where MySQL creates its socket file, or modify the location where PHP looks for the file. Please note that the first option is less secure than the second. Before delving in, you should also review new information relevant to PHP and MySQL on Mac OS X Server 10.4.4 and later.

To change the location where MySQL creates its socket file, do this:

  1. Open your preferred text editor and create a plain text file.
  2. Type this text (on two lines as shown):

    [mysqld]
    socket=/tmp/mysql.sock


  3. Save the file as: /etc/my.cnf

To change the location where PHP looks for the socket file, follow these steps:

  1. In Terminal: sudo cp /etc/php.ini.default /etc/php.ini
  2. Open /etc/php.ini in your preferred text editor.
  3. Find the [MySQL] section, and change the mysql.default_socket directive:
         ; Default socket name for local MySQL connects.  If empty, uses
    the built-in
    ; MySQL defaults.
    mysql.default_socket = /var/mysql/mysql.sock

  4. Change the permissions on /var/mysql so that www can read the socket, by executing this in Terminal:

    sudo chmod 775 /var/mysql

การย้าย database
http://meta.wikimedia.org/wiki/How_to_move_a_MediaWiki_Database

An example command on how to dump the database on a Debian GNU/Linux machine using mysqldump:

mysqldump --user=USERNAME --password=PASSWORD --single-transaction --all-databases > BACKUPFILE.sql

dump database named "wikidb"

mysqldump -u root -B wikidb > wikidb.sql

restore database named "wikidb"

mysql -u root -B wikidb <>

Create user ใหม่ขึ้นมาบน MySQL database อันใหม่ที่เรา import เข้ามาแล้ว โดยใช้คำสั่ง GRANT
คำสั่ง GRANT จะ encrypt password ให้ดังนั้นไม่จำเป็นต้องเรียกใช้ PASSWORD('password')

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
-> ON wikidb.*
-> TO 'wikiuser'@'localhost'
-> IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.05 sec)

bossanova:~/tmp/php-5.1.2 jojo$ ./configure '--prefix=/usr/local/php5.1.2' '--with-apxs2=/Library/Apache2/bin/apxs' '--with-ldap' '--with-kerberos' '--enable-cli' '--with-zlib' '--with-xml' '--enable-exif' '--enable-ftp' '--enable-mbstring' '--enable-mbregex' '--enable-sockets' '--with-iodbc' '--with-cure' '--with-config-file-path=/usr/local/php5.1.2/etc' '--with-mysql=/usr/local/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-mysql-sock=/var/mysql/mysql.sock'



Compile Turck MMCache with your PHP

download ที่นี่ --> http://turck-mmcache.sourceforge.net/
วิธีการ compile ที่นี่ --> http://www.phpmac.com/articles.php?view=166

shell> /usr/bin/phpize
shell> ./configure --enable-mmcache=shared --with-php-config=/usr/bin/php-config

shell> make
shell> sudo make install


add below to the bottom of your php.ini (/usr/local/lib/php.ini <--ผิด
ที่ถูกคือ /etc/php.ini แต่มันยังมี /private/etc/php.ini ด้วย อันหลังนี้คิดว่าคงไม่ได้ใช้)
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20020429/mmcache.so"
mmcache.shm_size="16"
mmcache.cache_dir="/tmp/mmcache"
mmcache.enable="1"
mmcache.optimizer="1"
mmcache.check_mtime="1"
mmcache.debug="0"
mmcache.filter=""
mmcache.shm_max="0"
mmcache.shm_ttl="0"
mmcache.shm_prune_period="0"
mmcache.shm_only="0"
mmcache.compress="1"


รัน install จาก web เพราะลองรัน php จาก cli ดูแล้วมันไม่เวิร์ค
กรอกข้อมูลให้ถูกต้องเหมือนของเก่า แล้วก็ไปแก้ไฟล์ LocalSettings.php ที่ installer มัน generate
มาให้ โดยอ้างอิงจาก LocalSettings.php ของเก่า แก้ไปรีเฟรช browserใหม่ไปดู เท่านี้ก็เรียบร้อย

วันอังคาร, มีนาคม 07, 2549

การ setCellRenderer / setCellEditor ใน JTable

ใน JTable หนึ่งสมมุติว่าชื่อ tbl มันจะมี defaultRenderer / defaultEditor สำหรับ วาด / แก้ ข้อมูลใน field ตาม type ต่างๆ เช่น สำหรับ String หรือ Integer หรือ Boolean เป็นต้น.

ทีนี้เราสามารถ setCellRender / setCellEditor ในแบบ per-column-basis ได้ โดยมี idiom ดังนี้

TableColumnModel tcm = tbl.getColumnModel();
TableColumn tc = tcm.getColumn( columnIndex );
TableCellRenderer thisColumnRenderer = tc.getCellRenderer(); // อันนี้จะ return null ออกมา

เพราะว่า ถ้าเราไม่เซตเอง มันจะไปใช้ defaultRenderer ของ table ดังนั้น

นอกจากนี้แล้ว การใช้คำสั่ง {get,set}InputMap, {get,set}ActionMap ในการ assign action to keyStroke เพื่อให้, ตัวอย่างเช่น, key Enter มีพฤติกรรมเหมือน, tab key ได้

วันจันทร์, กุมภาพันธ์ 27, 2549

install / uninstall codec or filter files by regsvr32 command

see this page http://www.free-codecs.com/guides/How_to_install_uninstall_DLL_and_AX_files.htm

1. Unarchive the package and use the files from Release folder if you're running Windows 9x/Me or Release Unicode if you're running Windows 2000/XP.

2. Copy DLL or AX files in system32 folder [ C:\WINDOWS\system32 ]

3. Click on Start > Run...

• To install the files, type: regsvr32 filename.dll or regsvr32 filename.ax
• To uninstall the files, use: regsvr32 -u filename.dll or regsvr32 -u filename.ax

Run dialog box




4. In the end, you should receive a message saying that your file was succesfully installed/uninstalled.

The file was succesfully installed




An easy way to register/unregister [install/uninstall] the files is to use one of these small tools:
RadLight Filter Manager - can be used to list all registered codecs and to register or unregister codecs.
DirectShow Filter Manager: helps to list, sort, find, add or remove DirectShow filters.
RegShell - a handy utility that will help you avoid the inconvenience of running regsvr32 from the start menu all the time.
Emsa DLL Register Tool - register dll/ocx filters, codecs... and get extended file informations.



Some of the more common filters

• "iviaudio.ax" - WinDVD Audio Decoder filter.
• "ivivideo.ax" - WinDVD Video Decoder filter.
• "claud.ax" - PowerDVD Audio Decoder filter.
• "clvsd.ax" - PowerDVD Video Decoder filter.
• "DSCinemAudioDecoder.dll" - CineMaster v4 Audio Decoder filter.
• "DSCinemVideoDecoder.dll" - CineMaster v4 Video Decoder filter.

Note: Sometimes you need to specify the fully qualified path name to files (i.e. c:\program files\intervideo\common\bin\iviaudio.ax)

วันอาทิตย์, กุมภาพันธ์ 26, 2549

ลิ้งก์เกี่ยวกับ EPWING

แปะไว้กันหายเฉยๆ

http://hp.vector.co.jp/authors/VA021723/dessed/

http://openlab.jp/edict/

http://hp.vector.co.jp/authors/VA000022/unixdic/index.html

http://ebsnap.lkj.jp/

http://members2.jcom.home.ne.jp/babelkund/palm05.html

http://www.yo.rim.or.jp/~mono93/mobile/linuxzau/dic_able.html

วันจันทร์, กุมภาพันธ์ 20, 2549

เกี่ยวกับ Ubuntu, Kubuntu, KNOPPIX

เช็คเกี่ยวกับแต่ละตัวว่า เป็นมายังไง, เหมาะสำหรับทำอะไร, มีอะไรเป็นจุดน่าสนใจ...

--

OliveBSD : OpenBSD แบบ LiveCD

วันจันทร์, กุมภาพันธ์ 06, 2549

วันพุธ, มกราคม 18, 2549

Installing ESC/Java2 บน FreeBSD

Today's class was a little bit boring. In the last period, I have to get ESC/Java2 installed on my machine. The problem was I have jdk1.5 installed on my windows OS and the ESCJ is not happy to run on 1.5. I don't want to add jdk1.4 so I tried to put ESCJ on the FreeBSD box.
Here is the memo.

  1. Get the file by google for ESC/Java2
  2. Unpack it probably by 'tar jxf ESCJ-binary.tbz'
  3. Edit the script called escj. For the sake of safety, let's copy it to myescj and I edited myescj instead.
  4. What need to be defined are:
    1. export ESCTOOLS_RELEASE to the absolute path of the directory in which you placed the release files.
    2. export OSTYPE='linux'; I use linux library.
    3. export SIMPLIFY environment variable to the name of one of the Simplify.linux executables contained in $ESCTOOLS_RELEASE
    4. I need to branch the executable Simplify.linux to tell the FreeBSD that it is linux binary and please use Linux ABI to execute the file:
      • $ brandelf -t Linux Simplify.linux
    5. That's it. Try exercise the edited script with an example in examples/0.0/Bag.java
  • วันพฤหัสบดี, มกราคม 12, 2549

    ogg Vorbis and QuickTime & iTunes

    Today, I googled to see how to play the Vorbis ogg audio format with iTunes which relies on QuickTime. This isn't the first time of putting my effort to allow iTunes integration with Vorbis.
    The useful information is just at my nose, the official Vorbis site .

    Well, to summarize, I need the Xiph QuickTime extension component right at http://www.xiph.org/quicktime/ , a brother site of vorbis.com. Just install the component and he player will be ready to play the Vorbis audio file just fine.

    The only problem with this under-development-version is that the tag can't properly be edited by iTunes and the mandatory information like Artist or Title which appear correctly in Cog aren't properly dislayed. I hope this problem will be fixed up in the upcoming version of Xiph QT component. Anyway, thanks for great work.

    -- after further searching --
    I found a QT component for FLAC right here FLAC decoder for quick time .

    วันพฤหัสบดี, มกราคม 05, 2549

    Hamachi

    โปรแกรมสำหรับทำ VPN บน internet น่าสนใจเลยเอามาบล็อกไว้
    Hamachi

    วันศุกร์, ธันวาคม 09, 2548

    Java : ว่าด้วยเรื่อง Inheritance, Superclass, Subclass

    คำถามคาใจ:

    ในคลาสลูก การเรียก Constructor super() ของคลาสพ่อแบบ explicit กับการไม่เรียก
    ให้ผลต่างกันอย่างไร?

    การใช้ this กับไม่ใช้ this นั้นมีผลต่อ inheritance อย่างไร คือพอถูก subclass ไปแล้ว this ที่ในคลาสพ่อก็ยังคง refer ถึงตัวคลาสพ่ออยู่ดีใช่ป่าว?

    ทั้งหมดนี้น่าจะหาำคำตอบได้ใน Java Specification Book ไว้ว่างๆ ไปเช็คแล้วจะกลับมาตอบ

    วันพฤหัสบดี, ธันวาคม 01, 2548

    Java : Windows Font Look And Feel

    สำหรับ application ที่เจาะจงว่าจะรันบนวินโด้ โดยเฉพาะนั้น เพื่อให้รูปแบบของฟอนต์สอดคล้องกับของวินโด้แต่ดั้งเดิม ควรเลือกใช้ Tahoma ขนาดตั้งแต่ 12 - 15