Archive for the ‘php’ Category

fun with anagrams

<?php define(’WORD_LIST_FILENAME’, ‘/usr/share/dict/words’); class AnagramLookup {     private $lookup;     //  Loads a file with one word per line     private function load_word_list($filename)     {         $lines = file($filename);                     // One word per line         [...]

Posted by Matthew on March 28th, 2008

Filed under php, programming | 1 Comment »

phpt testing framework

PHPT is the kind framework that encourages testing simply by making everything so easy. All that’s needed is a file with your PHP code and expected output. It wont replace SimpleTest or PhpUnit for anything complicated (say, like PHP itself…) but it seems to be just what I’m after. There’s little documentation about (PHP QA [...]

Posted by Matthew on February 12th, 2008

Filed under php, programming | No Comments »

Awful code I’ve written today

$row = $table->tr(); if(!($amIAltOrNot = !$amIAltOrNot)) {     $row->class = "alt"; } //  Edit: Much better now $row = $table->tr(); $row->class = ($amIAltOrNot = !$amIAltOrNot) ? "" : "alt";

Posted by Matthew on January 29th, 2008

Filed under php, programming | No Comments »

Now with added Slicehost

This website is now hosted on Slicehost (along with section99.net). It’s a little early to know how it will turn out, but so far I’m loving having not only a shell, but root access. Signing up was completely painless and the the VPS was provisioned within minutes with several different operating system options (though I’m [...]

Posted by Matthew on January 26th, 2008

Filed under linux, mysql, php, website | No Comments »

More useless PHP – Inplace Reverse

Code <?php /*     PHP implementation of a common programming problem:         Reversing a singly linked list */     error_reporting(E_ALL | E_STRICT);     //  This is our basic node     class WordNode     {         public $word;         public $nextNode;   [...]

Posted by Matthew on January 23rd, 2008

Filed under php, programming | 1 Comment »

Very Simple (Pretend) SQL Paramaters

<?php /*     Some hacked up code for Very Simple (Pretend) SQL Paramaters     — For when you don’t have PDO, or just can’t be bothered     Examples:         >>> SQL("SELECT * FROM users WHERE id=? AND name LIKE ?", 123, ‘"123\"’);         SELECT * FROM [...]

Posted by Matthew on December 10th, 2007

Filed under mysql, php, programming | No Comments »