Archive for the 'programming' Category

ERROR: Date_Calc is not installed – Dreamhost

September 2, 2008

ERROR: Date_Calc is not installed. You must install the date library. (with Dreamhost shared hosting)

ssh into ~

pear config-create $HOME .pearrc

install pear:

pear install -o PEAR

then install the date module

pear install pear/date

update the paths (can never get this part to work, so using the other method below)

export PHP_PEAR_PHP_BIN=/usr/local/php5/bin/php
export PATH=/home/*****/pear:/usr/local/php5/bin:$PATH

or include it this way: (index.php)

ini_set(
  'include_path',
  ini_get( 'include_path' ) . PATH_SEPARATOR . "/home/*****/pear/php"
);

the night after

October 16, 2007

it was a real surreal walk into work this morning. have a deadline this morning for a contract. deadline was confirmed yesterday. programming in a language you are unfamiliar with. after 3-4 hours sleep. and a night of solid word. no wind, very sunny. half open eyes. a few birds. a few, not to many, but some. the light. so bright. STILL NOT FINISHED.

amazing js

September 23, 2007

was reading a post on ajaxian and in the comments found this:

({false:function(w){alert(w)},true:function(){return this}})['b' in {'a':1,'b':1}]()[!1]("it’s just JavaScript")

now im new to javascript, well, maby not new, but new enough to be quite impressed by this.

problem of the day: usort

September 6, 2006

PHP:

OK, I need to sort a multi dimensional array by an element in the inner array. At the moment I’m doing a dirty double for loop, but i have something like(below) this in mind. Only trouble is that uSort needs to call the function as a parameter. _But I need this in a class. So something like this just doesn’t seem to work. Any ideas?

usort($this->rows, ‘cmpi’);

function cmpi($a, $b){

global $sort_field;
return strcmp($a[$sort_field], $b[$sort_field]);

}

UPDATE: OK so here we go. Soultion:

usort( $this->rows, array( $this, ‘cmpi’ )  );

Now I can make the ‘cmpi’ function inside my class and then call it using the above.

Problem for the day: Solved.