Deleting 1335 spam messages is fun

July 2nd, 2009

That was pretty exciting, but al fun things must come to an end. Onto the next items on my list. This blog now runs wordpress 2.8! Its fairly exciting that I can do that, but anyway. There is a lesson I have learnt over the past few months which has made me rethink about this blog and what I can post. You see, a few stray words around the place become bullets for people who probably exist to annoy me.

THUS! I shall not be talking about work anymore, cept the outside projects of course. If a project at work is finished I shall simply mention is by name and by nothing else. I am actually quite proud of some of the recent stuff that is being developed at the moment, and its a reason to get this thing up and running again. There will also be some mentions of politics and what not later on, as Stephen Conroy and Kevin Rudd are pretty lame whilst being the biggest hypocrites known to man. Probably time to whip out that kevin84.com domain I bought.

And don’t forget, you can now order toys made from Michael Jackson’s spare nose collection from Funeral tour later this year. Pretty exciting stuff. Wouldn’t be a blog post without mentioning his death.

Btw everybody needs to get: School of Seven Bells – Alpanisms , awesome album!

Share this article:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • DZone
  • Furl
  • Ma.gnolia
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

OptusScrape – A PHP Class to scrape your optusNet usage data

April 24th, 2009
OptusScrape

OptusScrape

I spent the day today writing up a php class that would give me an XML page of my optusnet usage. Previously you could hook into two pages they had running to get a text version of your usage details – but in Janurary they finally closed off the service in favor of their flashy advertising. Whirlpool link Here

Introducing OptusScrape: hosted @ http://code.google.com/p/optusscrape/ and released open source for anyone who wants to fiddle and help with ongoing maintence and development.

It has had no testing so far, and is the result of about 5 hours work – so don’t expect the world. It will probably fail badly if something goes wrong – but from my trials today it seems to work well if you have the right requirements.

It uses curl and PHP DOMXPath object to grab the elements. And returns DOMDocument objects with nice clean XML of the usage data. Thanks for FireBug for quickly getting my the XPath coords.

Next time I have time I will utilize the PHP Curl library, but for now it works well on *nix systems.

Here’s a snippit of the output and fields it supports.

Any feedback would be great!

Share this article:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • DZone
  • Furl
  • Ma.gnolia
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Installing PHP5.3 beta on Ubuntu 8.10

March 6th, 2009

I wanted to try out the new feature available in PHP 5.3 a while ago. And ran into a few obstacles trying get it installed. Since then I’ve installed it a few times successfully.

In each case I already has apache, php and mysql installed according to the instructions in the Ubuntu Documentation.

Download the latest release candidate or snapshot of PHP 5.3. Extract the source.

The first issue I had was with apxs2, to get PHP installed for Apache. I didn’t have the expected apxs2 file. To resolve this I installed apache2-threaded-dev
sudo apt-get install apache2-threaded-dev

Then I was ready to run (with any addition options you need/want)
./configure --with-apxs2=usr/bin/apxs2 --with-mysql

I got the error “xml2-config not found. Please check your libxml2 installation.”
I needed to install libxml2-dev
sudo apt-get install libxml2-dev

Running the configure command again, it succeeded.

Next to run the make file sudo make
Followed by sudo make install
However it alerts you that you need to have at least one LoadModule in your httpd.conf. Ubuntu doesn’t use httpd.conf to load modules so unless you have added something already, then your httpd.conf will be blank. All you need to do is add a LoadModule line. It doesn’t matter if the module exists or not. I simply added LoadModule whatever.

Now the install should work. Finally you might need to enable the php5 module, and restart apache.
a2enmod php5
apache2ctl restart

Checking phpinfo(), you should now be running PHP 5.3

Share this article:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • DZone
  • Furl
  • Ma.gnolia
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Facebook Badges

January 12th, 2009

<script src=”http://badge.facebook.com/badge/541375514.1051.1339555837.js”></script><noscript><a href=”http://www.facebook.com/people/Jesse-Collis/541375514″>Jesse Collis’s Facebook Profile</a></noscript>

Share this article:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • DZone
  • Furl
  • Ma.gnolia
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Icc Color Profile changing the colors in safari.

October 18th, 2008

I recently came across a nifty situation where, as applying background images in css the image colors would be different in safari and not in firefox. A strange strange situation indeed. But what could’ve been causing it.

After going through sites on google and some experimentation with color profiles I discovered that it was actually the Icc Color Profile in the save for web setting.

Icc Color Profile

Icc Color Profile

So by unselecting the Icc Color Profile box all my images displayed in the colors they should’ve in Safari.

Learn something new everyday aye. Noob goes down by -1. Dont know why it was selected in the first place!

Share this article:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • DZone
  • Furl
  • Ma.gnolia
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Apple Releases Security Update 2008-007 and Breaks my Apache

October 11th, 2008

As soon as I installed the Apple Security Update 2008-007 this afternoon, restarted and re-opened firefox to all my previous tabs I knew something was up  when my localhost suddenly wasn’t responding.

According to Apple, this fix updates to a new version of Apache 2:

Apache is updated to version 2.2.9 to address several vulnerabilities, the most serious of which may lead to cross site request forgery.

In order to get Apache Running, the first thing I tried was openening System Preferences and enabling/disabling web sharing a couple of times – which did nothing.

Second thing was trying to run httpd from the command line. Again, no success but it gave me some useful errors. For some reason it was attempting to load some old set of config files that I hadn’t used for ages – so I promptly removed those and solved those ’syntax errors’ (cleanups are good!)

Once my config files were in order, I was back to square one with this error…

httpd: Syntax error on line 116 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/libphp5.so into server: dlopen(/usr/libexec/apache2/libphp5.so, 10): no suitable image found.  
Did find:\n\t/usr/libexec/apache2/libphp5.so: mach-o, but wrong architecture

All this meant was that the compiled version of PHP5.3 I had (see my other post on running php 5.3) was compiled at 32bit, and Apple had set Apache back to 64Bit. Two commands solved this problem…

sudo cp /usr/sbin/httpd /usr/sbin/httpd-fat
sudo lipo /usr/sbin/httpd -thin i386 -output /usr/sbin/httpd

Note that the first command simply backs up httpd.

Since I’ve got web-sharing enabled, I assume that there’s some system that keeps track of the httpd processes, – as soon as killed the running 64bit httpd processes in Activity Monitor, it all seemed to be working again.

Just one note here: I did re-compile PHP again with the command line I posted earlier. There were no errors, and no differences so I don’t think that it was necessary, but I did try it.

Share this article:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • DZone
  • Furl
  • Ma.gnolia
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Clean Feeds and The Australian Government

October 6th, 2008

Something came to my attention in my random internet musings tonight, which is the governments new clean feed policy to stop pedophiles (oh no) from accessing questionable content  on the net. Oh and the children. Of course one would think that providing a filter program which the government wasted 84 million dollers on last year would be enough. But no, family first want more. So now we have a Mandatory Filter plan being installed.

While information has been incredibly scarce (read: people hiding it) there has been a few leaks as to how it would work. Of course one would assume that they would offer people to be able to opt out of the system right?

It appears not.

‘The Government’s plan is for there to be two blacklists, one for “unsuitable for children,” and another one for “unsuitable for adults.”

The much-touted “opt-out” would merely involve switching from blacklist number 1 to blacklist number 2.

Under their current proposal, there’s no scope at all to switch to no blacklist at all. Regardless of your personal preference, your traffic will pass through the censorship box.’

So we now have a tiered internet system coming our way. One way where you can protect “The Children” and the other one where the government tells every adult here what we can view and what we cant. Seems like this country is moving closer to China everyday, not only in Chinese speaking politicians but in ideology as well. May as well throw Network Neutrality out the window as well, clearly is doesn’t apply when terrorists and pedophiles are involved.

The ignorance of Australian politicians when it comes to technology is beggining to astound me. Not only  from this but the outright banning of games which arn’t appropriate for people for the age of 15 to “protect” us because some old fart in South Australia wont pass an R18+ guideline really makes you wonder if maybe, its best to go overseas to pursue your career instead in this technological backwater.

Good to be living in a Nanny state.

Everyone should read up on http://nocleanfeed.com and write to their local member about it, as the implications of this passing is bigger than people just losing access to porn.

Share this article:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • DZone
  • Furl
  • Ma.gnolia
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Late Static Binding with PHP 5.3

October 6th, 2008

With the Alpha3 Release of PHP 5.3 out and about it’s looking like the much anticipated late static binding functionality is starting to solidify. Once I finally got PHP 5.3 running (see my previous post) I worked through creating an  ActiveRecord-like class to see if I could make a PHP object do act in a similar way  similar to Ruby’s Active Record.

Lets see where I ended up…

class ActiveRecord {
  public static function find($id){
    $called_class = get_called_class(); //a new function as of a2
    return new $called_class();
  }
  //A derived example to show the late static binding in action
  public static function testLSB(){
    return static::$table;
  }
}
class BasicModel extends ActiveRecord {
  public static $table = 'basicModel';
}
//Output examples
echo get_class(BasicModel::Find(1)); //Output - BasicModel
echo BasicModel::testLSB();          //Output - basicModel
echo BasicModel::$table;             //Output - basicModel
First place I saw the get_called_class() method was on the PHP Late Static Binding Manual Page

The above example is celarly a bit derived, but I’m quite excited at where this is heading. I still have a bit of work to do if I want to end up accessing all my models in the Rails/Active Record fashion.

$user = new User(1); //by passing a user id directly to the constructor
$user = User::Find(1); //by static::find();
$users = Users::FindAll(); //by static::findAL() returning an array of User objects.

I don’t see these requirements too difficult to achieve but it will require some trickery. The problem will lie if I decide to put all the database logic into static::Find(). If static::Find() returns a new instance of the class, and the constructor of each class blindly returns the results of a static::Find() call, it won’t work. The code below  doesn’t work because a constructor can’t return a new object instance and $this can’t be reassigned (like you can in some languages).

public function __construct($id){
 if (is_array($id)){
    $this-&gt;data = $id;
  }else{
    $this = static::find($id); //fatal error, can't reassign $this
    return static::find($id); //also won't do anything useful
  }
}

From fist impressions I think the idea of using is_array() to check if the $id parameter is a good way for static::Find() to pass an array to the constructor without ending up in a loop. This suggests that there needs to be a similar check inside static::Find() to return only an array in some cases instead of a new object.

So I’ve come up with this idea to solve the above issue.

public function __construct($id){
 if (is_array($id))
    $this-&gt;data = $id;
 else
    $this-&gt;data = static::find($id,true); //static::find() returns an array;
}
public static function Find($id,$returnArray = false){
  $foundResults = insert_SQL_function_here();
  if ($returnArray === true)
    return $foundResults; //return basic array
  else{
    $called_class = get_called_class();
    return new $called_class($foundResults);
  }
}

I’m not 100% convinced this is the best way to solve this. Ideally I’d like a solution that didn’t require the checks in __construct() and static::find(), but this is a start, and it’s a a reasonable exercise in using LSB.

Share this article:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • DZone
  • Furl
  • Ma.gnolia
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Installing PHP 5.3 on Mac OS X Leopard

October 6th, 2008

After many frustrating hours and three separate attempts I am finally running PHP 5.3.0alpha3 on my MacBook Pro using the default Leopard Apache installation (the one you can turn on/off with web sharing). This post is as much a summary for my own records as it is how-to to people in the same boat. I’d like to point out that I’m not very experienced with compiling software from source, and for some reason I was determined to utilise the default Leopard installation of Apache.

The problem with the whole process was the Apple compiled version of Apache runs at 64Bit, and at present it’s not possible to compile the  PHP 5.3 Apache module to be compatible. The solution is to cut the Apache binary back to run at 32Bit. That can be done quite simply and is explained by Tony Bibbs back in June with PHP 5.3 on Mac OS X 10.5.

Once you’ve cut Apache back to 32Bit, you just need to install MySQL. Before I read Tony’s post I went to all the effort of compiling MySQL 5.1RC in 64Bit, then found out that PHP wasn’t compatible with the 64bit. Installing a released version of MySQL is simple, and in my opinion not worth going through the effort of compiling from source (unless you need some special functionality). I just took the latest release from the MySQL download site and installed it (after removing numerious other versions first, see below).

After MySQL was running, I downloaded the latest snapshot of PHP 5.3 from snaps.php.net , extracted, then ran the following configure command.

./configure --prefix=/usr/local/php53 \
--with-apxs2=/usr/sbin/apxs --with-config-file-scan-dir=/usr/local/php53/php.d \
--with-iconv --with-openssl=/usr --enable-ftp --enable-sockets \
--enable-mbstring --enable-calendar --enable-bcmath \
--with-curl=shared,/usr/local/php53 --with-zlib-dir=/usr  \
--with-mysqli=/usr/local/mysql/bin/mysql_config

Note my use of –prefix=/usr/local/php53 – this was my choice, as I didn’t want it to potentially overwrite my php 5.2 installation that was there.

The important elements here are –prefix and –with-mysqli

Also – I’m not 100% on what –with-config-file-scan-dir does, but it caused no problems.

After configure succeeds I ran

sudo make

Then after a cofee/beer I ran

sudo make install

From what I could gather, the install procedure created the libphp5.so file inside the /libexec/apache2/ directory (overwriting the one that was previously there), and also added the ‘loadModule’ line within the apache config file @ /private/etc/apache2/httpd.conf. If I did this again, I would backup previous php libraries.

Finally, a sudo apachectl restart restarts the apache server and I was on my way.

Footnotes:

Here’s some locations I found useful

Apache’s Httpd.conf is @ /private/etc/apache2/httpd.conf

The APXS libraries are @ /usr/sbin/apxs

PHP & MySQL (by default) install to /usr/local/

MySQL

Throughout this whole trial and error process, I think I installed MySQL about three different times. Before finally just downloading the latest 5.0 release I took some steps to remove the previous installations. If you’ve installed MySQL many times (like I did) and you’re a bit conscious about having junk all over the place then best place to start looking for information on what’s installed where is the Readme.txt file that comes with the OS X package installer, and also the Mysql Installation notes for OS X

An article I found that also helped me search for some lost MySQL installs, and shed some light on what to do was this post titled Removing MySql – by Lee Hambly.

Share this article:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • DZone
  • Furl
  • Ma.gnolia
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Yaey new blog

September 25th, 2008

So its time to create a skin for this now, get some style!

Well at least you can all now read out political diatribe and random musings on web design and development!

Okay its not that exciting right now, but wait for it!

Going forward is fun eh.

Share this article:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • DZone
  • Furl
  • Ma.gnolia
  • NewsVine
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati