Programmer Personality

You like coding at a High level.
The world is made up of objects and components, you should create your programs
in the same way.

You work best in a Solo situation.
The best way to program is by yourself. There’s no communication problems, you
know every part of the code allowing you to write the best programs possible.

You are a Conservative programmer.
The less code you write, the less chance there is of it containing a bug. You
write short and to the point code that gets the job done efficiently.

See http://www.doolwind.com/blog/programmer-personality-test/.

Advertisements

CakePHP, MongoDB primer

For your reference, and mine as well.

FIrst you need MongoDB to run on your system. It’s always easy on Debian/Ubuntu. Simply add:

deb http://downloads.mongodb.org/distros/ubuntu 9.4 10gen

to your /etc/apt/sources.lst for Ubuntu Jaunty (9.4).

$ sudo apt-get update; sudo apt-get install mongodb-stable

Once everything is downloaded — it takes awhile! — ps should show you something like:

$ ps -aef | grep mongodb
.
.
.
mongodb 8322 1 2 17:49 ? 00:02:59 /usr/bin/mongod --dbpath /var/lib/mongodb --logpath /var/log/mongodb/mongodb.log run --config /etc/mongodb.conf

Next you need PECL mongo, which allows PHP to communicate with MongoDB:

$ pecl install mongo

Remember to add ‘extension=mongo.so’ to your php.ini file! For my implementation, I created a separate mongo.ini in /etc/php5/conf.d/.

And then you’ll need the MongoDB datasource:

cd path/to/cakephp/app/plugins/; git clone git://github.com/ichikaway/cakephp-mongodb.git mongodb

Alternatively if you don’t have git, you can always download the source from https://github.com/ichikaway/cakephp-mongodb. Once the clone (or download) is complete, you should have mongodb/ in app/plugins.

app/config/database.php should have a config like:

var $mongo = array(
'database' => 'someApp',
'driver' => 'mongodb.mongodbSource',
'host' => 'localhost',
'port' => 27017
);

Your model should have, at the very least:

var $mongoSchema = array('type' => 'string'),
'created' => array('type' => 'date'),
'modified' => array('type' => 'date')
);
var $useDbConfig = 'mongo';

For such testing, CakePHP scaffolding will come in handy. Once some data is inserted, connect to the console:

$ mongo localhost:27017/someApp
MongoDB shell version: 1.6.4
connecting to: localhost:27017/someApp
> db.somes.count();
44220
>

Skipping incompatible lclntsh

Received this error whilst make-ing oci8 for PHP. It was a fresh install of 64-bit CentOS 5.4 w/ Oracle XE 10g installed; e.g.

$ sudo make
.
.
.
/usr/bin/ld: skipping incompatible /usr/lib/oracle/10.2.0.4/client/lib/libclntsh.so when searching for -lclntsh
/usr/bin/ld: cannot find -lclntsh
$

So I checked for /usr/lib/oracle/10.2.0.4/client/lib/libclntsh.so — it was there, but for some reason it was “incompatible”. Google helped once again. The problem was that the 10g RPM was 32-bit, but I was compiling a 64-bit version of oci8. how vague is that?

To resolve the issue, I installed the 64-bit -basic, -devel versions of Oracle Instant Client. Obviously I was being a smart-ass, since I thought that the XE RPM would’ve been sufficient, not!

When running the configure script, prepend with the path to Oracle Instsnt Client:

$ phpize
$ ./configure -with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib
$ sudo make
$ sudo make install

Hopefully this helps the next one confounded by “skipping incompatible lcntsh”.