24 June, 2005

Mechanize, pullparser, and python-spidermonkey

I found this site accidentally, and quite surprised! Especially python-spidermonkey, the python binding of the mozilla js engine. I shall try this out if I have time!

For the mechanize and pullparser, here is an example.

TCP port 32768?

When I use netstat to check about the opened ports, I found this:

netstat -tlnpe Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name tcp 0 0 0.0.0.0:32768 0.0.0.0:* LISTEN 0 16493 -

I'm shocked, what's this port? Hacked?

Then, I checked /proc/net/tcp:

sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode 0: 00000000:8000 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 16493 1 cd672000 3000 0 0 2 -1

I think, may be just opened by kernel, but why?

Just for save, I goggled about this and found this interesting thread! hm... rpc

What happen?

I used to mount a few NFS shared directory from another box, hence, the nlockmgr of RPC is always running and listening of port 32768. nlockmgr is a RPC service which is used for NFS lock recovery when machine crashed or reboot.

This time, I learn the usefulness of this commands :)

$ lsof -i tcp:32768 $ fuser -v -n tcp 32768 $ rpcinfo -p 127.0.0.1

22 June, 2005

My frist try on GIMP script-fu!

I have just read the tutorial on GIMP about script-fu!

Scripting in GIMP is pretty easy, but debuging is quite trouble. This tutorial help me a bit, at least, I leart to use 'print' to do basic debug.

Though scheme is not difficult, It would be better if I can do it in python, but I can't found any python-fu tutorial, where is it?

So what I've done? I'm managed to resize a set of images to another fixed size, I try to do it first with ImageMagick by "convert -resize", but ImageMagick doesn't convert the image properly. When I say -resize 130x41, the resulting image is 128x41 (Am I misunderstand this option?). May be it is only some rounding problem but, not acceptable in this case. On the other hand, GIMP do it great, so I try to script it!

The solution is simple. First write a small script-fu, and run gimp in batch mode.

The script is like this: ; It will resize image in batch (define (bresize filename width height) ; load (set! img (car(gimp-file-load RUN-NONINTERACTIVE filename filename))) ; not really used, but gimp-file-save need it (set! lyr (car(gimp-image-get-active-layer img))) ; scale (gimp-image-scale img width height) ; save (file-png-save-defaults RUN-NONINTERACTIVE img lyr filename filename) ) (script-fu-register "bresize" "/Xtns/Script-Fu/byMe/Batch resize" "Batch resize image" "Zarick Lau " "Zarick Lau" "2005-06-22" "" SF-VALUE "filename" "a.png" SF-VALUE "width" "130" SF-VALUE "height" "41")

And to run it in a batch, easy!

$ for f in *.png; do \ gimp-2.0 -i -b "(bresize \"$f\" 130 41)" '(gimp-quit 0)'; \ done

14 June, 2005

Building Redhat Enterpris Linux from Source

I have to make some time to try this out, quite interesting!, By the way, RHEL4 source is here.

03 June, 2005

My OFBiz Journey

The following my advice, do it first!

  • Read existing documents and wiki
  • OFBiz is a "big" software, the best way to learn it, is to set it up, and try to use it
  • After setting it up, try to use the webtools, it will let you access most of the administrative functions
  • Inside the "applications" directory, the ecommerce application is a web store, which use a lots of OFBiz functionality, by studying this application you can have a more solid understanding about OFBiz, for example, how a HTTP request is processed, and how a view composed, also you can have a taste on how to use the entity engine.

This document record what I have learned when I try to use 'ecommerce' module as a webstore for a chocolate company

Datasource
Use the latest version from subversion repository directly $ svn co http://svn.ofbiz.org/svn/ofbiz/trunk ofbiz-trunk

By default, ofbiz use 'derby' a Java based standalone database, you can change to use other data source. All you have to do is:

  1. Create a database 'ofbiz' (or whatever you want)
  2. Create user 'ofbizUserName' and 'ofbizPassword' and grant the permission appropriately.
  3. Then you can chagne the setting so that ofbiz will use your database.
    The file should be changed is: [ofbiz-trunk/framework/entity/config/entityengine.xml]

For all the delegator element, change the attr. 'datasource-name'. For example, I use MySQL, I will change this attr to 'localmysql'

Why localmysql, because, more detail data source parameter is defined at the lower half that XML config file. The name (or ID) for the MySQL config is 'localmysql'.

Then you should also change the setting for the datasource. So found the 'datasource' element and change the following entry:

  • jdbc-uri
  • jdbc-username
  • jdbc-password

NOTE: The "table-type" attr will make ofbiz generate wrong SQL to create table. So comment it out.
Seed Data

After setting the datasource, it is ready to install the seed data Seed data is a set of basic data will is required for ofbiz to run normally, for example, some UOM, and Geograpical data. To install, you can run $ ant run-install-seed

OFBiz will startup in 'install mode'. In this mode, it will found out all 'seed data' and install (insert) it into the datasource

This seed data is defined in XML file with root element named 'entity-engine-xml'. Each element in the XML correspsond to a ROW in the datasource.

The list of all seed data file is defined in ofbiz-component.xml. Each component in OFBiz will have one such file. It is read by the component loader when OFBiz starting up (as install mode).

For example, under framework/common, ofbiz-component.xml contains these lines: <entity-resource type="data" reader-name="seed" loader="main" location="data/CommonTypeData.xml"/>

Demo data

Demo data is similar to seed data, they are defined in the same way. The differnce are the data is not 'required' by OFBiz operation, rather, they are used as demo. For example, "applications/ecommerce" has provided a set of demo data, if the data is installed, you can see a 'fake' product catalog when you asscess the ecommerce website

Another difference between seed and demo data is, how it is defined inside ofbiz-component.xml; For demo data, the element is look like this: <entity-resource type="data" reader-name="demo" loader="main" location="data/DemoProduct.xml"/> Please note that reader-name is now "demo", but no "seed"

To install all demo data, you can $ java -jar ofbiz.jar install readers=demo

However, if you are now going to 'customize', there is no reason to install the "stock" demo data. You have at least two choice.

Simply remove all those demo data xml or comment out the relevant lines in various ofbiz-component.xml

Other configuration

Under base/config directory, you can found some base configuration. Among the list, the most important files:

  • ofbiz-containers.xml
  • cache.properties
  • debug.properties

The meaning of cache.properties and debug.properties is obvious. For the ofbiz-containers.xml, it is the core config file for OFBiz OFBiz will parse this during normal startup. Inside this file you can found some some definition for various container which is started up by OFBiz at the very first moment.

The most import should be cataline-container (tomcat). You can adjust various tomcat properties at there. For example, changing the listening ports, and comment out ajp stuff, if not really used, etc