Saturday, August 16, 2008

Visiting the Japanese Cemetery Park, Singapore




















Friday, June 06, 2008

Setting up Apache and SVN on Suse Linux 10

Installation

Firstly, lets say that you already have a C compiler. If not, please install that first.

My main reference : http://www.komaii.com/linux/apache2-ssl-subversion-trac-on-SuSE10.0/

To use a different installation path, use

$ wget http://apache.oss.eznetsols.org/httpd/httpd-2.2.6.tar.gz
$ tar -zxvf httpd-2.2.6.tar.gz
$ ./configure --prefix=/path/to/install

The full arguments for ./configure can be referenced from my main reference link above.

$ make
$ make install

Usually I would do a make check, but httpd-2.2.6.tar.gz does not come with test scripts. If I am wrong, someone correct me.

Then you set the environment variables so the $PATH contains the httpd/bin directory. This is useful if you want to run the apachectl script to start and stop the HTTP server.

$ apachectl start
$ apachectl stop

But do run the server yet, you got one more config file to modify; the httpd.conf file. If you are lazy like me, or you do not have root access to the server to create a new user and user group to run the server (creates a more secure environment, according to countless sites that you can actually google it), you can directly set

User mark
Group mark

Then you set the rest of the stuff

ServerName localhost
Listen 80

Then start your HTTP server. It should run nicely. Now you are all set to install SVN.

$ wget http://subversion.tigris.org/downloads/subversion-1.4.6.tar.bz2
$ bunzip2 subversion-1.4.6.tar.bz2
$ tar -xvf subversion-1.4.6.tar
$ cd subversion-1.4.6
$ ./configure --prefix=/path/to/install

Please also refer to the main reference I used for the complete configure arguments

$ make
$ make check

make check will take a very very long time.

$ make install


Then its all done. Just a reminder to myself. SVN requires APR (Apache Portable Runtime) which you can actually download separately and attach the source files in a subfolder under subversion-1.4.6/apr and apr-utils. If you are like me and tried to install SVN without having a HTTP server in your Linux, or you did not point your --with-apr and --with-apr-util to the correct httpd folder, you will be notified with a warning message. The parameters should look like

--with-apr=/path/to/httpd
--with-apr-util=/path/to/httpd

I tried with no luck on using the APR on their own. What worked was installing the HTTP server and using that as the source of APR files.

After all this, you set the $PATH for svn which should point to svn/bin.

After you install SVN, the modules required for httpd,

mod_dav_svn.so
mod_authz_svn.so

to run svn will magically appear in the httpd/modules folder. Make sure they also are in the httpd.conf file.

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

Basic Security

I constructed a basic authentication box using apache's htpasswd. I stored the file outside of the htdocs folder, naming it svn-auth-file which contents look like:

mark:htidkl13hadsfA:

In httpd.conf, I added this.

<location>
DAV svn
SVNPath /path/to/httpd/htdocs/data/project
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /path/to/httpd/svn-auth-file
Require valid-user
</location>

Thursday, May 29, 2008

Project site for Informix dbo for cakephp 1.2

http://code.google.com/p/dboinformixdriver/

courtesy of jmomorales

Code is for Informix 7.3 but I run Informix 9.40 and its quite fine. Just implemented a fix for pagination.

Tuesday, May 20, 2008

Informix and CakePHP 1.2

Today, I tried some kick-ass stuff. Connecting an existing Informix database with cakePHP 1.2. First thing I tried is to use the adodb db wrapper which is built in cakephp. If you need to use adodb, you have to download it from here. Then you extract it and place it in app/vendor.

var $default = array(
'driver' => 'adodb',
'connect' => 'informix',
'persistent' => false,
'host' => 'myserver',
'port' => '9109',
'login' => 'informix',
'password' => 'mypass',
'database' => 'mydb',
'schema' => '',
'prefix' => '',
'encoding' => ''
);

Somehow, this configuration setting works and cakephp's default homepage now shows that it can connect to a database. However, when I try to create a model, and scaffold a controller, it tells me that the table for the model cannot be found.

So then I scour the cyberspace again, looking for the possibility of the existence of a pdo_informix.php file, and I found it hidden in the cakephp google groups, written by Marcelo of San Luis, Argentina. The link can be found here. You need to change the code a little, to set the INFORMIXSERVER environment and get rid of the error

SQLSTATE=IX 000 SQLCODE=-25596


...
function connect()
{
$config = $this->config;
$connect = $config['connect'];
$this->connected = false;

$host = $config['database'] . '@' . $config['host'];
$argHostname = $config['host'];
if ($argHostname) putenv("INFORMIXSERVER=$argHostname");
putenv("INFORMIXSERVER=".trim($argHostname));
if ($config['persistent'])
{
$this->connection = ifx_pconnect($host, $config['login'], $config['password']);
}
else
{
$this->connection = $connect($host, $config['login'], $config['password']);
}

$this->connected = ($this->connection !== false);
return $this->connected;
}
...


Hopefully, the rest of the code can be recycled. I have not tested them yet.

Monday, May 19, 2008

Lunch at Karen's

5+1 people who ate at Karen's. The sixth is the photographer.
Now can you guess who the photographer is? And who's taking the photo now?... Hah Hah
Mmm... nice...
Mmm....not so nice...
Had sweet and sour fish with lots of onions (my favourite), black chicken soup and mixed vegetables. Actually, I should have started cooking the chicken as after an hour, the soup doesnt have much taste. The fish was ok, I guess. The vegetables needed some prawns.

Anyway, always room for improvement.

Sunday, May 18, 2008

Fishing trip

Feeling down 'cause you didn't get any fish?

This tent is amazingly easy to fix up!

Fishermen...

Fresh fish from the reservoir.

The same fish.

The same reservoir.
Fixing the line, it got tangled.
Fixing the fishing line. The line got tangled so many times it got cut to save time.This is what they tried to use to catch fish, without any live bait.
These kids caught some lobster or shellfish by just using a stick with fish meat. They actually caught a few.
Kids caught a few lobsters or shellfishes by just using a stick with fish meat.

I ate junk food while they fished.






Thursday, May 15, 2008

Informix meets Wampserver 2 Part 2

The most beautiful string in a PHP-Informix programmer's life:


$db = new PDO("informix:host=;service=;database=;
server=;protocol=onsoctcp;DB_LOCALE=en_US.8859-1", "username", "password");


PDO constructor: PDO("db:xxxx", "username", "password");

host_computername: the name of the server hosting informix, if unsure, check /etc/hosts

service_port: the port number used by the server, if unsure, check $INFORMIXDIR/etc/sqlhosts for the service name then go to /etc/services to find out the port number

db_name: name of the database you want to connect to, obviously...

server_name: name of the server, don't get confused with host. Yeah, you're already confused...

protocol: I really got no idea what this is, and what difference it makes, will post later when I find out more.

DB_LOCALE: Sets the locality, but I think its more useful in killing this error


'PDOException' with message 'SQLSTATE=HY000, SQLDriverConnect: -23197 [Informix][Informix ODBC Driver][Informix]Unspecified System Error = -23197.'


The username and password is the one you use to log in the linux host, so username must be informix.

I also adapted code copied from http://www.informix-zone.com/informix-script-dbapi#php
to test out the connection string.

<?php
# ------------------------------------
# open connection to database 'stores'
# ------------------------------------
try {
$dbh = new PDO("informix:host=example.com;service=1234;database=stores;
server=myserver;protocol=onsoctcp;DB_LOCALE=en_US.8859-1", "informix", "123456");
}
catch (exception $e) {
print $e;
}
# ----------------
# open transaction
# ----------------
$dbh->beginTransaction();

# --------------------------------------
# prepare and execute 'select' statement
# --------------------------------------
$sth1 = $dbh->prepare("select bank_code, bank_name from bank");
$sth1->execute();
# ---------------------
# fetch thru result set
# ---------------------
while( $row = $sth1->fetch() )
{
# --------
# show row
# --------
//echo "<pre>";
//print_r($row);
//echo "</pre>";
echo $row[BANK_CODE] . ' - ' . $row[BANK_NAME] . '<br/>';
}
$dbh = null;

?>

Tuesday, May 13, 2008

Informix meets wampserver 2

Ok, so here's the story. The easy part is getting the PDO_informix object turned on in Wampserver. You just need to click right click on the wampserver icon, go to PHP > PHP extensions > php_pdo_informix.

Then create a new php file, and type this:


<?php
$i=0;
try {
$db = new PDO(
"informix:host=it;service=1526;database=stores_demo;server=ol_it;
protocol=olsoctcp;EnableScrollableCursors=1;DB_LOCALE=EN_US.8859-1",
"informix",
"informix");
}
catch (PDOException $e) {
echo "Could not connect to Informix servr:\n" . $e->getMessage() . "\n";
}
?>

Source: http://www.ibmdatabasemag.com/showArticle.jhtml?articleID=191502698
On my system, the web browser will puke out an error:


Could not connect to Informix server: SQLSTATE=HY000, SQLDriverConnect: -23101 [Informix][Informix ODBC Driver][Informix]Unable to load locale categories.


which is eerily similar to the case where you try to use the iLogin demo that comes with the Informix installation.

Strange thing is if you tried Server Studio, you don't get the locale error.

The time now is 1715 and happily I write with a solution to my problem.
SOLUTION:

On WindowsXP, set the INFORMIXDIR and INFORMIXSERVER in Environment Variables. They should look like:


INFORMIXDIR = C:\Program Files\IBM\Informix\Connect
INFORMIXSERVER = ol_[computer name]


but should be a bit different for you if you installed Informix in a different folder.
See the screenshot below for my trophy. PHP connects to the demo database stores_demo. I did a simple "SELECT * FROM customer" query.



What else did I try but did not work?


SetEnv INFORMIXDIR C:\Program Files\Informix
SetEnv INFORMIXSERVER ol_it


I placed these two in httpd.conf and restarted the server. They did appear in Apache Environment but it is not what I need. I need it to appear in Environment.

The running ol_[computer name] batch file in Start Menu > Informix Dynamic Server 9.40 ol_[computer name]. It gives you the illusion that the environments are set, but aren't.

Some useful links for reference, http://www.ffnn.nl/pages/articles/linux/vmware-player-image-creation.php
to create empty vmware disks. You don't really need VM Workstation anymore.

Sunday, May 04, 2008

Trip to Kranji Reservoir

Actually, we were looking for Sungai Buloh Wetlands Reserve, but this reservoir place is also a cool place to hang out, especially when Singapore is experiencing a heat wave.
The 'water keys' or whatever they call it, it controls water flow when there is high tide from Selat Tebrau. On the other side is Kranji Reservoir.
This is the reservoir. There are a lot of people fishing here when we went.
Suaku-1 posing for photo...hehe...
Suaku-3 pointing where we are.
People fishing. Not sure if they caught anything the whole evening there though. I am not a fishing person, just don't have the patience to wait for the fish or prawn to bite.It is so huge! I saw an eagle or some predatory bird flying around catching fish. Unfortunately, my little camera is not powerful enough to capture the event. Looks like I need to upgrade to a digital SLR with telescoping lenses.
A family enjoying their Sunday quietly observing Johor Bahru.
Some other people watching some other thing....
Swamp land, quite wet and sticky (duh!). Nothing much to see. Some baby crabs, no mudskippers.
You can actually see Johor Bahru from here!A picture tells a thousand words.
That's me on a tree. Well, technically not 'on' the tree, I'm just standing on its roots.
Nice view of the sun through the swamp tree leaves.
Can you see the sun?
Colourful slippers, wet and smelly too!
Swamp sun.
Suaku-1 and Suaku-2 looking at fisherman throwing net.
Can you see the spider?
No? Try this picture.
Mrs Kitty Cat minding her own business when I took this photo.

Next time, we'll be visiting the Sungai Buloh Wetlands Reserve. We know where it is now!